Created
April 25, 2020 14:17
-
-
Save knknkn1162/3f04627fef38ab88fd4784fc8a3cf7cd to your computer and use it in GitHub Desktop.
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
struct fuel traverse(uint64_t graph[][VERTEX_MAX], int via[][VERTEX_MAX], struct pair p, struct fuel val) { | |
int v = via[p.start][p.end]; | |
if(v == VIA_NONE) { | |
// do something | |
} | |
struct fuel val2 = traverse(graph, via, (struct pair){p.start, v}, val); | |
return traverse(graph, via, (struct pair){v, p.end}, val2); | |
} | |
// Warshall-floyd | |
for(k = 0; k < vs; k++) { | |
for(i = 0; i < vs; i++) { | |
for(j = 0; j < vs; j++) { | |
if(graph[i][j] > graph[i][k] + graph[k][j]) { | |
graph[i][j] = graph[i][k] + graph[k][j]; | |
via[i][j] = k; | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment