Skip to main content
. 2020 Apr 22;20(8):2378. doi: 10.3390/s20082378
Algorithm 2 The improved 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:     t=dis(i,k)
9:      for j=1 to i do
10:      dis(i,j)=min(dis(i,j),t+dis(k,j));
11:      dis(j,i)=dis(i,j);
12:      end for
13:   end for
14: end for
15: return dis;