summaryrefslogtreecommitdiff
path: root/graph/floydWarshall.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'graph/floydWarshall.cpp')
-rw-r--r--graph/floydWarshall.cpp15
1 files changed, 9 insertions, 6 deletions
diff --git a/graph/floydWarshall.cpp b/graph/floydWarshall.cpp
index f5c950d..30d463a 100644
--- a/graph/floydWarshall.cpp
+++ b/graph/floydWarshall.cpp
@@ -1,8 +1,11 @@
-//initialize adjmat, adjmat[i][i] = 0, adjmat[i][j] = INF if no edge is between i and j, length otherwise
-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];
+// Laufzeit: O(|V|^3)
+// Initialize adjmat: adjmat[i][i] = 0, adjmat[i][j] = INF if no edge is between i and j, length otherwise.
+void floydWarshall() {
+ for (k = 0; k < NUM_VERTICES; k++) {
+ for (i = 0; i < NUM_VERTICES; i++) {
+ for (j = 0; j < NUM_VERTICES; 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
+}