There is a connected undirected graph, given by the adjacency matrix, which is processed by the Floyd-Worshell algorithm. Given that the edges between the vertices may not be (then they are given as -1 ), we get the following algorithm:
for(i=0;i<n;i++) for(j=0;j<n;j++) for(l=0;l<n;l++) if ((d[i][l]>d[i][j]+d[j][l]||d[i][l]<0)&&d[i][j]>=0&&d[j][l]>=0) d[i][l]=d[i][j]+d[j][l]; It seems to be all right, but for some reason several edges are not processed.
For example, processing the graphs given by such a matrix:
0 -1 1 2 -1 0 -1 5 1 -1 0 4 2 5 4 0 The result is:
0 7 1 2 7 0 9 5 1 8 0 3 2 5 3 0 Ie it is unknown how the length of the edge 9 appears.
What is the problem? Where is the error in writing the algorithm?