Skip to content

Commit debe9d4

Browse files
Update floyd_warshall.cpp
Fix Segmentation fault do to graph being passed by object and there not being a copy constructor. Adding the '&' for the Graph parameter changes the passing of the parameter to pass by reference, thus avoiding the segmentation fault.
1 parent f789e3b commit debe9d4

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

dynamic_programming/floyd_warshall.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ void print(int dist[], int V) {
5151

5252
// The main function that finds the shortest path from a vertex
5353
// to all other vertices using Floyd-Warshall Algorithm.
54-
void FloydWarshall(Graph graph) {
54+
void FloydWarshall(Graph& graph) {
5555
int V = graph.vertexNum;
5656
int dist[V][V];
5757

0 commit comments

Comments
 (0)