File tree Expand file tree Collapse file tree 1 file changed +5
-3
lines changed Expand file tree Collapse file tree 1 file changed +5
-3
lines changed Original file line number Diff line number Diff line change @@ -25,7 +25,9 @@ class Graph {
25
25
}
26
26
27
27
~Graph () {
28
- for (int i = 0 ; i < vertexNum; i++) delete[] edges[i];
28
+ for (int i = 0 ; i < vertexNum; i++) {
29
+ delete[] edges[i];
30
+ }
29
31
delete[] edges;
30
32
}
31
33
@@ -36,7 +38,7 @@ class Graph {
36
38
};
37
39
38
40
// Utility function to print distances
39
- void print (int dist[] , int V) {
41
+ void print (const std::vector< int > dist, int V) {
40
42
cout << " \n The Distance matrix for Floyd - Warshall" << endl;
41
43
for (int i = 0 ; i < V; i++) {
42
44
for (int j = 0 ; j < V; j++) {
@@ -77,7 +79,7 @@ void FloydWarshall(Graph graph) {
77
79
dist[i][j] = dist[i][k] + dist[k][j];
78
80
79
81
// Convert 2d array to 1d array for print
80
- int dist1d[ V * V] ;
82
+ std::vector< int > dist1d ( V * V) ;
81
83
for (int i = 0 ; i < V; i++)
82
84
for (int j = 0 ; j < V; j++) dist1d[i * V + j] = dist[i][j];
83
85
You can’t perform that action at this time.
0 commit comments