Skip to content

Instantly share code, notes, and snippets.

@knknkn1162
Created April 25, 2020 14:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save knknkn1162/3f04627fef38ab88fd4784fc8a3cf7cd to your computer and use it in GitHub Desktop.
Save knknkn1162/3f04627fef38ab88fd4784fc8a3cf7cd to your computer and use it in GitHub Desktop.
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