learngraphtheory.org

Guest User

Using app without sign in

Cover of the book Graph Theory Through Problems

Practice book

Graph Theory Through Problems

300 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.

Available inKindlePaperback

13 chapters

Also by the authorGraph Algorithms for Coding Interviews100 solved interview problems with visual explanations and Python solutions.View on Amazon
Algorithm Selection

Select an algorithm and generate steps to begin visualization

Widest Path Calculator

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

Time: O((V + E) log V)
Space: O(V)
Use Case: Bandwidth routing, weight-limited roads, max-flow augmenting paths
Showing the example graph for this algorithm.
Algorithm Execution

Select an algorithm and generate steps to begin visualization

About Widest Path (Max Bottleneck)

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.

How it works

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.

Applications

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.

Pseudocode

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 parent

The 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.

Worked example, step by step

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.

  1. Take A. width(A) is infinite. Its links give B width 4 and C width 9.
  2. Take C. C is the widest at 9, so its width is final. C-D gives D min(9, 3) = 3, and C-E gives E min(9, 7) = 7.
  3. Take E. E is next at 7. E-D gives min(7, 5) = 5, better than D's 3. E-F gives F min(7, 8) = 7.
  4. Take F. F is final at 7. F-G gives G min(7, 9) = 7.
  5. Take G. G now leaves the queue with width 7, ahead of D at 5 and B at 4. No wider route to it can appear, so the search stops.

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.

Complexity, and where it comes from

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.

When to use Widest Path (Max Bottleneck), and when not to

The widest path answers a bottleneck question. Similar sounding problems need different tools.

AlternativePrefer it whenCost
Dijkstra's algorithmThe 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 treeThe graph is undirected and you need widest paths between many pairs. The tree contains all of them.O(E log V)
Maximum flowTraffic may be split over several routes, so the total throughput can exceed the widest single path.O(V^2 E) with Dinic
Minimax pathThe 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)

Common pitfalls

  • Adding capacities. The width of a path is the minimum of its capacities, not their sum. Summing them rewards long paths and gives meaningless answers.
  • Starting the source at 0. The source must start with infinite width, because the empty path has no bottleneck. With 0, every min stays 0 and nothing ever improves.
  • Confusing it with maximum flow. A widest path carries all traffic on one route. If the network can split traffic, the maximum flow can be much larger, and that is the right model for total capacity.
  • Ignoring ties in bottleneck. Many routes often share the same bottleneck. If a secondary criterion matters, such as fewest hops among the widest routes, it must be built into the comparison explicitly.

Frequently asked questions

What is the widest path problem?
It asks for a path between two vertices whose smallest edge weight, the bottleneck, is as large as possible. It is also called the maximum capacity path or maximum bottleneck path problem.
How do you find the widest path?
With a modified Dijkstra: the source starts with infinite width, extending a path to a neighbour gives the minimum of the current width and the edge capacity, and the vertex with the largest width is always settled next.
What is the time complexity of the widest path algorithm?
O((V + E) log V) with a binary heap, the same as Dijkstra. For undirected graphs, a maximum spanning tree gives the widest paths between all pairs in O(E log V).
What is the relation between widest paths and maximum spanning trees?
In an undirected graph, the path between two vertices in any maximum spanning tree is a widest path between them. This follows from the cut property: the tree always keeps the heaviest edge across every cut.
Where is the widest path used?
In network routing to find the route with the highest bandwidth, in transport to find the route that allows the heaviest truck or the tallest load, in image segmentation, and as a step in the Edmonds-Karp variant that augments along the widest path.

Related algorithms: Dijkstra's Algorithm, Maximum Flow, Kruskal's MST Algorithm, Yen's K Shortest Paths

Interactive Controls

Zoom Controls

32%
Nodes: 7
Edges: 9