The above answer has been very well explained. Just in case, if someone needs an explanation of the correctness of the algorithm, you are here:
Evidence:
At any point in the algorithm there will be 2 sets of vertices A and B. The vertices in will be the vertices for which the correct path of maximum minimum capacity is found. And the set B has peaks for which we did not find the answer.
Inductive hypothesis . At each step, all the vertices in the set A have the correct path values of the maximum minimum capacity for them. those. all previous iterations are correct.
The correctness of the base case : when the set A has only the vertex S. Then the value of S is equal to infinity, which is true.
In the current iteration, we set
val [W] = max (val [W], min (val [V], width_between (VW)))
Inductive step . Suppose that W is a vertex in the set B with the largest val [W]. And W was put out of the queue from the queue, and W the answer val [W] was set.
Now we need to show that every other SW path has a width of & lt; = val [W]. This will always be true, because all other ways to reach W will go through some other vertex (let's call it X) in B.
And for all other vertices X in the set B val [X] <= val [W]
Thus, any other path to W will be limited to val [X], which will never be more than val [W].
Thus, the current val [W] estimate is optimal and, therefore, the algorithm calculates the correct values for all vertices.