Skip to main content
. 2020 Apr 22;20(8):2378. doi: 10.3390/s20082378
Algorithm 1 The Floyd-Warshall’s shortest path algorithm
Input:
   The initial weights of the graph: w(i,j)
   The number of vertices: n
Output:
   The final matrix of the shortest paths: dis(i,j)
1: for i=1 to n do
2:   for j=1 to n do
3:     dis(i,j)=w(i,j);
4:   end for
5: end for
6: for k=1  to n do
7:   for i=1 to n do
8:     for j=1 to n do
9:      dis(i,j)=min(dis(i,j),dis(i,k)+dis(k,j));
10:     end for
11:   end for
12: end for
13: return dis;