演算法›Ch4 圖論演算法
第 95 題/共 111 題
◀ AL 95/111
95. Floyd-Warshall Algorithm、All-Pairs Shortest Path
#AL-04-095中Floyd-Warshall AlgorithmAll-Pairs Shortest Path

Given a directed weighted graph G=(V,E)G=(V, E), where each edge (i,j)∈E(i,j) \in E has weight w(i,j)w(i,j). The adjacency matrix WW is defined as below

W(i,j)={w(i,j),(i,j)∈E∞,(i,j)∉EW(i,j) = \begin{cases} w(i,j), & (i,j) \in E \\ \infty, & (i,j) \notin E \end{cases}

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 圖論演算法
本章題號 · 81–100 / 111