summaryrefslogtreecommitdiff
path: root/graph/floydWarshall.cpp
diff options
context:
space:
mode:
authorPaul Jungeblut <s_jungeb@i08pc55.atis-stud.uni-karlsruhe.de>2014-11-24 14:11:49 +0100
committerPaul Jungeblut <s_jungeb@i08pc55.atis-stud.uni-karlsruhe.de>2014-11-24 14:11:49 +0100
commit172dcb7d3fbfc93145e1c8a4bbd109539a36990e (patch)
tree7a9b43e816affbc18e1991ea1f5a2f51399ae18a /graph/floydWarshall.cpp
parenta4d473bfe1d1b77ebc0a6b061d4a126779f48c31 (diff)
parent3bf9e44bf552ef5ceef2a4eef87907cc1a8db09b (diff)
merge
Diffstat (limited to 'graph/floydWarshall.cpp')
-rw-r--r--graph/floydWarshall.cpp8
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