演算法›Ch4 圖論演算法第 95 題/共 111 題
95. Floyd-Warshall Algorithm、All-Pairs Shortest Path
#AL-04-095中Floyd-Warshall AlgorithmAll-Pairs Shortest Path
Given a directed weighted graph , where each edge has weight . The adjacency matrix is defined as below
Below is an algorithm for finding shortest paths of all vertex pairs in a directed weighted graph.
F (G,W)
{ n=|V|
D(0)=W
for (k = 1; i<= n; k=k+1)
for (i = 1; i<=n; i=i+1)
for (j = 1; j<= n; j=j+1)
if D(k-1)[i,j]>D(k-1)[i,k] + D(k-1)[k,j]
then D(k)[i,j]=D(k-1)[i,k] + D(k-1)[k,j]
else D(k)[i,j]=D(k-1)[i,j]
return D(n)
}
Which of the following statements are true?
📄 中央114
▤完整推導請見《WH 資工筆記 · 演算法》Ch4 圖論演算法