Guest User
Using app without sign in

Practice book
Graph Theory Through Problems300 Exercises with Hints, Worked Algorithms and Complete Solutions
By Mohammed Islam Hadjoudj
Learn graph theory by solving problems: 300 exercises, from routine checks to challenging proofs, each with a complete solution.
Also by the authorGraph Algorithms for Coding Interviews100 solved interview problems with visual explanations and Python solutions.View on AmazonSelect an algorithm and generate steps to begin visualization
The route that carries the most
The path whose narrowest edge is as wide as possible: Dijkstra with min instead of sum and the widest vertex first
Select an algorithm and generate steps to begin visualization
The widest path problem, also called the maximum bottleneck or maximum capacity path problem, looks for the path between two vertices whose narrowest edge is as wide as possible. The width of a path is the smallest weight on it, its bottleneck, so a route is only as good as its weakest link. A lorry limited by the weakest bridge, a download limited by the slowest link and a pipe network limited by its thinnest pipe all ask this question. The answer is often not the shortest route.
The algorithm is Dijkstra's with two changes. A path's value is the minimum edge weight along it instead of the sum, and the priority queue hands out the vertex with the largest width first. The source starts at width infinity and every other vertex at 0. When a vertex leaves the queue its width is final, because every vertex still waiting is narrower and passing through it can only keep or lower a width. Relaxing an edge from u to v of capacity c offers v the width min(width(u), c). The widest paths from one vertex are also the paths of a maximum spanning tree, which gives a second way to compute them.
Widest paths route data through the links with the most spare bandwidth, find the heaviest load a vehicle can carry over bridges and roads with weight limits, and pick augmenting paths in the max-flow algorithm of Edmonds and Karp, whose widest-path variant needs few iterations. They also appear in image segmentation, in voting methods such as the Schulze method, and in reliability problems where a route is only as strong as its weakest component.
The widest path, or maximum capacity path, maximises the smallest edge weight along the route. A small change to Dijkstra solves it: compare bottlenecks instead of sums, and always settle the widest vertex first.
WidestPath(graph, s, t):
width[v] = 0 for every v, width[s] = infinity
queue = all vertices, keyed by width (largest first)
while queue is not empty:
u = queue.extractMax()
if u == t: stop
for each edge (u, v) with capacity c:
w = min(width[u], c)
if w > width[v]:
width[v] = w, parent[v] = u
return width[t], the path through parentThe argument is the same as for Dijkstra, with min in place of plus and max in place of min. Extending a path can never increase its bottleneck, so when the widest vertex in the queue is extracted, no later route can reach it with a larger width, and its value is final. The target can therefore be returned the moment it leaves the queue.
Find the route with the most bandwidth from A to G on the example this page loads. Edge weights are link capacities in Mbit/s.
Example graph: Undirected links A-B 4, A-C 9, B-D 8, C-D 3, C-E 7, D-E 5, D-G 6, E-F 8 and F-G 9. The top route A-B-D-G has the fewest hops.
The widest path is A-C-E-F-G with width 7, set by its bottleneck C-E. The top route A-B-D-G has only three hops, but its first link carries 4, so it is limited to 4. D and B were never settled, because the target was already final. As a check, the maximum spanning tree of this graph contains exactly the path A-C-E-F-G between A and G.
Time: O((V + E) log V) · Space: O(V)
The structure is identical to Dijkstra: each vertex is extracted once from a priority queue and each edge causes at most one key update. With a binary heap that is O((V + E) log V), and with a Fibonacci heap O(E + V log V). For undirected graphs there is an alternative: the widest path between every pair lies on a maximum spanning tree, so one run of Kruskal with the edges sorted in decreasing order answers all pairs at once. Since only comparisons between capacities are needed, the method works equally well with any totally ordered weights.
The widest path answers a bottleneck question. Similar sounding problems need different tools.
| Alternative | Prefer it when | Cost |
|---|---|---|
| Dijkstra's algorithm | The cost of a route is the sum of its edges, such as distance or delay, not its weakest link. | O((V + E) log V) |
| Maximum spanning tree | The graph is undirected and you need widest paths between many pairs. The tree contains all of them. | O(E log V) |
| Maximum flow | Traffic may be split over several routes, so the total throughput can exceed the widest single path. | O(V^2 E) with Dinic |
| Minimax path | The mirror problem: minimise the largest edge on the route, for example the steepest climb. Same algorithm with the order reversed. | O((V + E) log V) |
Related algorithms: Dijkstra's Algorithm, Maximum Flow, Kruskal's MST Algorithm, Yen's K Shortest Paths