私はこのロジックを使用して、隣接行列で何が起こっているのかを理解しようとしていますが、abcd の間隔についてどこに書かれているのか非常に混乱しています.....
ここで何が起こっているのか誰か説明できますか?
ありがとうございます (Java としてタグ付けされているのは、これが実証された言語であるため、誰かがコード例を投稿した場合、その言語であることがわかります)
http://compprog.wordpress.com/2007/11/15/all-sources-shortest-path-the-floyd-warshall-algorithm/
コードは次のとおりです。
for (k = 0; k < n; ++k) {
for (i = 0; i < n; ++i)
for (j = 0; j < n; ++j)
/* If i and j are different nodes and if
the paths between i and k and between
k and j exist, do */
if ((dist[i][k] * dist[k][j] != 0) && (i != j))
/* See if you can't get a shorter path
between i and j by interspacing
k somewhere along the current
path */
if ((dist[i][k] + dist[k][j] < dist[i][j]) ||
(dist[i][j] == 0))
dist[i][j] = dist[i][k] + dist[k][j];