Example 1
- Input
- n = 4, connections = [[0,1],[1,2],[2,0],[1,3]]
- Output
- [[1,3]]
The triangle has an alternate route around each of its edges. Server 3 is attached only through 1, so removing 1-3 isolates it.
Find every undirected network connection whose removal disconnects some servers. Discovery times and low links identify these bridges in one traversal.
A connected undirected network has n servers numbered from 0 to n - 1 and edges connections, where [a, b] joins two distinct servers. There are no repeated connections.
Return all connections whose removal makes some servers unable to reach others. These edges are called bridges. Edge orientation and answer order do not matter.
2 <= n <= 10^5n - 1 <= connections.length <= 10^5[0, n - 1]; there are no repeated connections.The triangle has an alternate route around each of its edges. Server 3 is attached only through 1, so removing 1-3 isolates it.
The single connection is the only route between the two servers, so it is a bridge.
Removing any one edge leaves the other two as a path connecting all three servers. Equality of a child low link with an ancestor discovery time must not create a bridge.
Removing a DFS tree edge disconnects its child subtree only if that subtree has no alternate route back to the parent or an earlier ancestor. In Example 1, 2 can reach 0 without using its parent edge, protecting the triangle 0-1-2. Server 3 has no such escape, so 1-3 is a bridge. A low link summarizes the earliest discovery reachable by going down tree edges and then taking one non-parent edge.
Reveal Tarjan Bridges: intuition, complexity, and code
A DFS subtree needs only its earliest alternate escape to decide whether its incoming edge is essential. Low links summarize that escape information in linear time.