I am trying to modify the Floyd-Warshall algorithm to find all-pairs minimax paths in a graph. (That is, the shortest length paths such that the maximum edge weight along a path is minimized.)
Floyd-Warshall algorithm contains the following loop to enhance the distance (ds) and the next vertex (ns) matrices at each iteration.
for (int k = 0; k < n; k++) for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) if (ds[i][k] != inf && ds[k][j] != inf) { final int d = ds[i][k] + ds[k][j]; if (d < ds[i][j]) { ds[i][j] = d; ns[i][j] = k; } } I replaced ds with two new matrices: ws (weights) and ls (lengths). Further, updated the iteration step as follows:
for (int k = 0; k < n; k++) for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) if (ws[i][k] != inf && ws[k][j] != inf) { final int w = Math.max(ws[i][k], ws[k][j]); final int l = ls[i][k] + ls[k][j]; if (w < ws[i][j] || (w == ws[i][j] && l < ls[i][j])) { ws[i][j] = w; ls[i][j] = l; ns[i][j] = k; } } However, the modified algorithm finds paths with loops, that is, paths such as 1-3-2-3-4. While the maximum edge weight of the paths 1-3-2-3-4 and 1-3-4 are identical, the latter has a shorter path length and supposed to be returned by the enhanced Floyd-Warshall. Any ideas?
A working Java version of both algorithms and a test case which produces a path with loop can be found here.
Edit: Since no solutions were presented yet, I implemented my own shortest minimax path algorithm using incremental link removal method. Java sources to the solutions can be accessed from the above link.
ws[i][j] = links.get(i).get(j)andls[i][j] = 1lines in the code. $\endgroup$