Contract every 2-edge-connected component of an undirected graph to a single node, keeping only the bridges as edges. The result is a tree (or forest), because every remaining edge is a bridge and bridges cannot lie on cycles.
Construction —
- Find all bridges with the low-link DFS.
- Union the endpoints of every non-bridge edge in a DSU. Each resulting set is a 2-edge-connected component.
- For each bridge , add a tree edge between
find(u)andfind(v).
// step 1: bridges (see the bridges page), marked in isBridge[edgeId]
DSU dsu(n);
for (auto [id, u, v] : edges)
if (!isBridge[id]) dsu.unite(u, v);
vector<vector<int>> tree(n);
for (auto [id, u, v] : edges)
if (isBridge[id]) {
int a = dsu.find(u), b = dsu.find(v);
tree[a].push_back(b);
tree[b].push_back(a);
}An alternative one-pass construction assigns component ids directly during the bridge DFS (do not descend across a bridge), which avoids the DSU entirely.
Properties
- The bridge tree has one node per 2-edge-connected component and one edge per bridge.
- for a connected graph.
- A graph is 2-edge-connected iff its bridge tree is a single node.
- Every edge of the bridge tree is a bridge of the original graph.
What it answers
| Question | On the bridge tree |
|---|---|
| Number of bridges on any path | tree distance between their components |
| Are still connected if edge fails? | is a bridge on their tree path |
| Vertices disconnected from by removing bridge | subtree size on the far side of |
| Minimum edges to add for 2-edge-connectivity | where = number of leaves of the bridge tree |
| Maximum bridges any path crosses | the tree’s diameter |
The "" result is worth remembering: pair up leaves across the tree (leaf with leaf in DFS order), and each added edge kills two leaves. It is the standard answer to “make the road network resilient to any single road closure”.
The vertex analogue
Block-cut trees do the same for vertex connectivity. Bridge trees are simpler and more common; reach for the block-cut tree only when the problem removes vertices rather than edges.
Worked example: “count pairs of vertices whose connection survives every single edge failure”
Build the bridge tree, note the component sizes , and the answer is — pairs inside a 2-edge-connected component have two edge-disjoint paths (Menger), so no single edge failure separates them. Pairs in different components are separated by the bridges between them.
Related: strong orientation
Robbins’ theorem. A connected undirected graph has an orientation making it strongly connected iff it is bridgeless. Concretely: orient every DFS tree edge downward and every back edge upward. If a bridge exists, no orientation works — because a bridge oriented one way makes the far side unreachable. See Strong Orientation.
See also: Bridges and Articulation Points · Block-Cut Tree · DSU