Skip to content

Instantly share code, notes, and snippets.

@hmthanh
Last active April 16, 2019 06:58
Show Gist options
  • Save hmthanh/fd5d72eba772f3c0ff96b20f019df8f5 to your computer and use it in GitHub Desktop.
Save hmthanh/fd5d72eba772f3c0ff96b20f019df8f5 to your computer and use it in GitHub Desktop.
Thuật toán FloyWarshall
path = vector<vector<int>>(length, vector<int>(length));
dist = vector<vector<int>>(length, vector<int>(length));
for (int i = 0; i < length; i++) {
for (int j = 0; j < length; j++) {
dist[i][j] = graph[i][j];
if (graph[i][j] != INF && i != j) {
path[i][j] = i;
}
else {
path[i][j] = -1;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment