Last active
November 4, 2017 18:08
-
-
Save benjaminion/419d25c1643e803bd2d21f0d5e1aa96c to your computer and use it in GitHub Desktop.
Optimising APSP
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int a; int b; int c; | |
for (k = 0; k < n; ++k) { | |
for (i = 0; i < n; ++i) { | |
a = d[i * n + k]; | |
if (a == INF) continue; | |
for (j = 0; j < n; ++j) { | |
b = d[i * n + j]; | |
c = d[k * n + j]; | |
if (c == INF) continue; | |
else if (b == INF) d[i * n + j] = a + c; | |
else d[i * n + j] = a < b + c ? a : b + c; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment