Critical Connections in a Network
Master this topic with zero to advance depth.
Critical Connections in a Network
There are n servers numbered from 0 to n - 1 connected by undirected server-to-server connections forming a network where connections[i] = [a_i, b_i] represents a connection between servers a_i and b_i.
Any connected graph with no cycles is a tree. A critical connection is a connection that, if removed, will make some servers unable to reach some other server.
Return all critical connections in the network in any order.
Visual Representation
Servers: 4, Connections: [[0,1],[1,2],[2,0],[1,3]]
0---1---3
\ /
2
Removing [1,3] splits the graph.
Removing [0,1], [1,2], or [2,0] doesn't split it (cycle 0-1-2).
Result: [[1,3]]Examples
[1,3] is the only bridge.
Level I: Brute Force (Edge Removal + Connectivity)
Intuition
Try removing each edge one by one and check if the graph remains connected. If it doesn't, that edge is a critical connection.
Complexity
- Time:
- Space:
Detailed Dry Run
4 nodes, edges [[0,1],[1,2],[2,0],[1,3]]. Remove [1,3]: unreachable. Critical!
Level III: Optimal (Tarjan's Bridge-Finding Algorithm)
Intuition
Tarjan's algorithm uses DFS to find bridges by tracking discovery times and the lowest discovery time reachable via back-edges.
Pattern: Bridge Finding (Tarjan)
Detailed Dry Run
Graph: 0-1, 1-2, 2-0, 1-3. Bridge condition: low[v] > disc[u]. At node 1, child 3 has low[3]=3, disc[1]=1. 3 > 1 is TRUE. [1,3] is bridge.
Found an issue or have a suggestion?
Help us improve! Report bugs or suggest new features on our Telegram group.