Graph Bottleneck Paths And Connectivity
Asked of: Software Engineer
Last updated
What's being tested
This tests the minimax path pattern: minimizing the largest edge on a path rather than minimizing the total weight. You must recognize equivalent solutions using connectivity, Dijkstra-style bottleneck relaxation, or Kruskal/Union-Find, while handling parallel edges, disconnection, and start == target.
Patterns & templates
-
Bottleneck relaxation:
dist[v] = min(dist[v], max(dist[u], weight)); use a min-heap forO((V+E) log V)time. -
Kruskal connectivity sweep: sort edges ascending, union endpoints, and stop when source and target connect;
O(E log E)time. -
Union-Find with path compression and union by rank gives near-constant operations:
O(E log E + E α(V))overall after sorting. -
For
start == target, return bottleneck0(or the problem’s neutral value); no edges need to be traversed. -
Parallel edges are valid: retain every edge, since the lightest relevant connection may determine the answer.
-
Disconnected vertices have no feasible path; return the specified sentinel such as
-1,None, or infinity. -
Prefer Kruskal when only one source-target query exists; prefer Dijkstra-like search when adjacency is already built or queries vary.
Common pitfalls
Pitfall: Using ordinary shortest-path addition (
dist[u] + w) solves the sum-minimization problem, not the maximum-edge objective.
Pitfall: Returning the first edge that touches the target is incorrect; connectivity through multiple lower-weight edges must be considered.
Pitfall: Forgetting stale heap entries or visited handling in bottleneck Dijkstra can cause redundant work or incorrect early termination.
Practice these
The practice cards below cover the canonical variants — solve all of them and time yourself.
Practice questions
Related concepts
- Graph Algorithms, Dependency Resolution And ConnectivityCoding & Algorithms
- Graph, Grid, And Connectivity AlgorithmsCoding & Algorithms
- Graph Traversal And Shortest PathsCoding & Algorithms
- Tree And Graph ConnectivityCoding & Algorithms
- Graph Search, Pathfinding, And ConnectivityCoding & Algorithms
- Graphs, Grids, And ReachabilityCoding & Algorithms