algorithmgraph-algorithmshortest-pathfloyd-warshall

modify current algorithm - APSP


I have the below APSP algorithm:

enter image description here

This computes the shortest path. The length of the path is the sum of weights of edges of path.

How can i modify the above algorithm in order to compute the shortest path where length is the weight of the heaviest edge on this path.

Any help would be great!!!


Solution

  • On 7th line instead of

    cost = D[i, k] + D[k, j]
    

    you just should put

    cost = Max(D[i, k], D[k, j])