I copy this answer and adding also the addition of my proof of the correctness of the algorithm:
I would use some Dijkstra's option. I took the pseudo code below directly from Wikipedia and only changed 5 little things:
- Renamed
dist to width (from line 3) - Initialize each
width to -infinity (line 3) - Initialize the width of the source to
infinity (line 8) - Set the termination criterion to
-infinity (line 14) - Updated update function and sign (line 20 + 21)
1 function Dijkstra(Graph, source): 2 for each vertex v in Graph: // Initializations 3 width[v] := -infinity ; // Unknown width function from 4 // source to v 5 previous[v] := undefined ; // Previous node in optimal path 6 end for // from source 7 8 width[source] := infinity ; // Width from source to source 9 Q := the set of all nodes in Graph ; // All nodes in the graph are 10 // unoptimized β thus are in Q 11 while Q is not empty: // The main loop 12 u := vertex in Q with largest width in width[] ; // Source node in first case 13 remove u from Q ; 14 if width[u] = -infinity: 15 break ; // all remaining vertices are 16 end if // inaccessible from source 17 18 for each neighbor v of u: // where v has not yet been 19 // removed from Q. 20 alt := max(width[v], min(width[u], width_between(u, v))) ; 21 if alt > width[v]: // Relax (u,v,a) 22 width[v] := alt ; 23 previous[v] := u ; 24 decrease-key v in Q; // Reorder v in the Queue 25 end if 26 end for 27 end while 28 return width; 29 endfunction
Some (manual) explanation of why this works: you start from the source. From there you have an infinite capacity for yourself. Now you check all source neighbors. Suppose the ribs do not have the same capacity (in your example, say (s, a) = 300 ). Then there is no better way to reach b , then through (s, b) , so that you know the maximum capacity of b . You continue to walk to the best neighbors of a known set of peaks until you reach all the peaks.
Proof of the correctness of the algorithm:
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.