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 {
2525 }
2626
2727 ~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+ }
2931 delete[] edges;
3032 }
3133
@@ -36,7 +38,7 @@ class Graph {
3638};
3739
3840// Utility function to print distances
39- void print (int dist[] , int V) {
41+ void print (const std::vector< int > dist, int V) {
4042 cout << " \n The Distance matrix for Floyd - Warshall" << endl;
4143 for (int i = 0 ; i < V; i++) {
4244 for (int j = 0 ; j < V; j++) {
@@ -77,7 +79,7 @@ void FloydWarshall(Graph graph) {
7779 dist[i][j] = dist[i][k] + dist[k][j];
7880
7981 // Convert 2d array to 1d array for print
80- int dist1d[ V * V] ;
82+ std::vector< int > dist1d ( V * V) ;
8183 for (int i = 0 ; i < V; i++)
8284 for (int j = 0 ; j < V; j++) dist1d[i * V + j] = dist[i][j];
8385
You can’t perform that action at this time.
0 commit comments