diff options
Diffstat (limited to 'graph/floydWarshall.cpp')
| -rw-r--r-- | graph/floydWarshall.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/graph/floydWarshall.cpp b/graph/floydWarshall.cpp new file mode 100644 index 0000000..ee56441 --- /dev/null +++ b/graph/floydWarshall.cpp @@ -0,0 +1,8 @@ +//initialize adjmat, adjmat[i][i] = 0, adjmat[i][j] = INF if no edge is between i and j +for (k = 0; k < MAX_V; k++) { + for (i = 0; i < MAX_V; i++) { + for (j = 0; j < MAX_V; j++) { + if (adjmat[i][k] + adjmat[k][j] < adjmat[i][j]) adjmat[i][j] = adjmat[i][k] + adjmat[k][j]; + } + } +}
\ No newline at end of file |
