Simple Algorithm
Algorithms & Data Structures · Optimal · 26 min

Bridges, Articulation Points & Biconnectivity

Low-link values and the edges whose removal disconnects a graph.

Cut one cable and half the network goes dark: that cable is a bridge, and a router whose failure splits the network is an articulation point. Testing every edge separately takes O(m(n+m))O(m(n + m)) time. One depth-first search finds them all in O(n+m)O(n + m), by computing a single number per vertex: how high in the DFS tree its subtree can climb.

What you’ll learn

  • Define bridges, articulation points, 2-edge-connected and biconnected components, and low-link values on a DFS tree.
  • Prove the bridge criterion low[v]>d[u]\mathrm{low}[v] > d[u] and the articulation-point criteria, and implement both in O(n+m)O(n + m), parallel edges included.
  • Find the biconnected components with an edge stack, and build the bridge tree and the block-cut tree.
  • Prove Robbins's theorem on one-way streets with a DFS orientation, and place these algorithms among parallel and dynamic connectivity results.

Cut edges, cut vertices and the DFS tree

The obvious algorithm deletes each edge in turn and runs a BFS: O(m(n+m))O(m(n + m)) time. Depth-first search does better because of a fact from the Optimized lesson: in an undirected DFS every edge is a tree edge or a back edge, so every non-tree edge joins a vertex to one of its ancestors. Removing a tree edge (u,v)(u, v), with uu the parent, cuts off the subtree TvT_v, and the graph stays connected exactly when some back edge leaves TvT_v and lands above vv.

VertexParentddlow\mathrm{low}Why
A—11the root
BA21its child C reaches A
CB31back edge C–A
DC44its subtree reaches no higher than D
ED54its child F reaches D
FE64back edge F–D
GF77a leaf with no back edge
A running example: two triangles A–B–C and D–E–F joined by the edge C–D, plus the pendant edge F–G. DFS from A, taking neighbors in alphabetical order, runs down the single path A, B, C, D, E, F, G; the back edges are C–A and F–D.

The two criteria, proved

DerivationProof
  1. w→ tree path x→ back edge ww \xrightarrow{\ \text{tree path}\ } x \xrightarrow{\ \text{back edge}\ } w

    Non-tree edges lie on cycles. A back edge (x,w)(x, w) joins xx to its ancestor ww, so with the tree path from ww down to xx it closes a cycle, and an edge on a cycle is not a bridge:

  2. low[v]≤d[u]\mathrm{low}[v] \le d[u]

    Which edges leave a subtree. Delete the tree edge (u,v)(u, v). Any other edge with exactly one end in TvT_v is a back edge from some x∈Tvx \in T_v to a proper ancestor ww of vv, because non-tree edges join ancestors and descendants. Proper ancestors of vv are discovered no later than uu, and vertices of TvT_v no earlier than vv, so such an edge exists if and only if

  3. ∃ a child v of u:low[v]≥d[u]\exists \text{ a child } v \text{ of } u:\quad \mathrm{low}[v] \ge d[u]

    Articulation points. Delete a non-root uu. The rest of the tree outside TuT_u stays connected through uu's parent, and the subtrees of uu's children are joined by no edge, since there are no cross edges. The subtree TvT_v of a child stays attached exactly when a back edge leaves it for a proper ancestor of uu, that is, when low[v]<d[u]\mathrm{low}[v] < d[u]; a back edge landing on uu itself vanishes with uu. So uu is a cut vertex if and only if

  4. r is a cut vertex  ⟺  r has at least two childrenr \text{ is a cut vertex} \iff r \text{ has at least two children}

    The root. Its children's subtrees are joined by no edge, again because there are no cross edges, so deleting the root separates them exactly when there are at least two. With one child, everything else lies in that child's subtree, which stays connected.

In the running example, the tree edges with low[v]>d[u]\mathrm{low}[v] > d[u] are C–D (4>34 > 3) and F–G (7>67 > 6): the two bridges. The articulation points are C (child D: 4≥34 \ge 3), D (child E: 4≥44 \ge 4) and F (child G: 7≥67 \ge 6). B fails the test (1<21 < 2), and the root A has a single child.

python
import sys

def bridges_and_cut_vertices(n, edges):
    """edges: (u, v) pairs, parallel edges allowed. Returns (bridge indices, cut vertices)."""
    sys.setrecursionlimit(10_000 + 2 * n)
    adj = [[] for _ in range(n)]
    for i, (u, v) in enumerate(edges):
        adj[u].append((v, i))
        adj[v].append((u, i))
    disc, low = [0] * n, [0] * n
    bridges, cut = [], set()
    clock = 0

    def dfs(u, parent_edge):
        nonlocal clock
        clock += 1
        disc[u] = low[u] = clock
        children = 0
        for v, i in adj[u]:
            if i == parent_edge:
                continue                       # skip the edge we came in on, not the parent vertex
            if disc[v]:
                low[u] = min(low[u], disc[v])  # back edge
            else:
                children += 1
                dfs(v, i)
                low[u] = min(low[u], low[v])
                if low[v] > disc[u]:
                    bridges.append(i)          # v's subtree cannot climb above v
                if parent_edge != -1 and low[v] >= disc[u]:
                    cut.add(u)                 # v's subtree cannot climb above u
        if parent_edge == -1 and children >= 2:
            cut.add(u)                         # a root with two or more children

    for s in range(n):
        if not disc[s]:
            dfs(s, -1)
    return bridges, sorted(cut)

One DFS, O(n+m)O(n + m) time. Skipping the arrival edge by its index makes a parallel edge to the parent count as a back edge, so a doubled edge is correctly not a bridge. On the running example (vertices A–G numbered 0–6) it returns the edges F–G and C–D and the cut vertices C, D and F. For inputs with very long paths, prefer an explicit stack or C++.

Check your understanding

For a tree edge (u,v)(u, v), with uu not the root, the DFS finds low[v]=d[u]\mathrm{low}[v] = d[u]. Which statement is right?

  1. (u,v)(u, v) is a bridge and uu is an articulation point
  2. (u,v)(u, v) is a bridge, but uu is not an articulation point
  3. (u,v)(u, v) is not a bridge, but uu is an articulation point
  4. (u,v)(u, v) is not a bridge, and uu is not an articulation point
Show the answer

C. (u,v)(u, v) is not a bridge, but uu is an articulation point

low[v]=d[u]\mathrm{low}[v] = d[u] means that the best back edge out of TvT_v lands exactly on uu. That edge keeps TvT_v attached when the edge (u,v)(u, v) is removed, so it is no bridge; but it disappears when uu itself is removed, so TvT_v falls off and uu is a cut vertex. In the running example, D with its child E is this case: low[E]=d[D]=4\mathrm{low}[E] = d[D] = 4.

Blocks, the block-cut tree and one-way streets

Bridges split a graph into 2-edge-connected components: delete every bridge, and the pieces that remain are the maximal subgraphs without a bridge of their own. Contract each piece to a single vertex and the bridges become the edges of a forest, the bridge tree, which is a tree when GG is connected (a cycle in it would put a bridge on a cycle of GG). In the running example the pieces are {A, B, C}, {D, E, F} and {G}, joined in a path by C–D and F–G.

Articulation points split the edges instead. Call two edges equivalent when they are equal or lie on a common simple cycle; the classes are the biconnected components, or blocks. A bridge is a block by itself, two blocks share at most one vertex, and a vertex lies in two or more blocks exactly when it is an articulation point. The running example has four blocks: the triangle A–B–C, the edge C–D, the triangle D–E–F and the edge F–G.

The block-cut tree has a node for every block and a node for every articulation point, with an edge from each articulation point to each block containing it. For a connected graph it is a tree, and it turns questions about separation into questions about tree paths: when x,y≠cx, y \ne c, every path from xx to yy passes through the articulation point cc exactly when cc lies on the tree path between the nodes of xx and yy (a vertex's node is its block, or itself if it is an articulation point). With binary lifting on that tree (see the lesson Lowest Common Ancestors), each such query takes O(log⁡n)O(\log n) time.

DerivationProof by a DFS orientation
  1. A bridge defeats every orientation. It is the only link between its two sides, so whichever way it points, the side it points into can never get back.

  2. r⇝vfor every vertex vr \rightsquigarrow v \quad\text{for every vertex } v

    Orient along a DFS. Run a DFS from any vertex rr; direct each tree edge from parent to child and each back edge from descendant to ancestor. The root reaches every vertex along tree edges:

  3. v⇝x→w⇝rv \rightsquigarrow x \to w \rightsquigarrow r

    Every vertex climbs back to the root. Induct on d[v]d[v]. For v≠rv \ne r with parent uu, the edge (u,v)(u, v) is not a bridge, so low[v]≤d[u]<d[v]\mathrm{low}[v] \le d[u] < d[v]: some x∈Tvx \in T_v has a back edge to a vertex ww with d[w]=low[v]d[w] = \mathrm{low}[v]. Walk down tree edges from vv to xx, cross to ww, and finish by induction, since d[w]<d[v]d[w] < d[v]:

  4. Every vertex reaches rr and rr reaches every vertex, so the orientation is strongly connected, and it was built in O(n+m)O(n + m) time.

Check your understanding

Which connected graph has no bridge but does have an articulation point?

  1. A path on four vertices
  2. A cycle on five vertices
  3. Two triangles joined by one extra edge
  4. Two triangles that share one vertex
Show the answer

D. Two triangles that share one vertex

In this "bowtie" every edge lies on a triangle, so none is a bridge, yet deleting the shared vertex leaves two separate pieces. It is 2-edge-connected but not biconnected, and its blocks are the two triangles. The reverse cannot happen: if a connected graph with at least three vertices has a bridge, at least one end of the bridge is an articulation point.

Beyond two: connectivity at larger scale

Bridges and articulation points are the case k=2k = 2 of a general notion. A graph is kk-vertex-connected if it has more than kk vertices and stays connected after deleting any k−1k - 1 of them, and kk-edge-connected if it stays connected after deleting any k−1k - 1 edges. Menger's theorem (1927) turns separators into paths: the fewest vertices whose removal separates two non-adjacent vertices ss and tt equals the largest number of ss–tt paths that share no inner vertex, and the same holds for edges and edge-disjoint paths. For k=2k = 2 it gives Whitney's characterization: a graph with at least three vertices is biconnected exactly when every two of its vertices lie on a common cycle.

Depth-first search goes further than k=2k = 2. Hopcroft and Tarjan (1973) also split a biconnected graph into its triconnected components in linear time; the published algorithm contained errors, which Gutwenger and Mutzel corrected in 2001, and it underlies the SPQR trees used in planarity testing and graph drawing. Schmidt (2013) found a much simpler certifying test, a chain decomposition of a DFS into paths and cycles from which both 2-edge- and 2-vertex-connectivity can be read off in O(n+m)O(n + m).

In directed graphs the analogues are strong bridges and strong articulation points, whose removal increases the number of strongly connected components. Low-links no longer suffice, but the dominator trees of the graph and of its reverse do, and Italiano, Laura and Santaroni (2012) find all of them in linear time.

When the graph changes, recomputing from scratch costs O(n+m)O(n + m) per update. Holm, de Lichtenberg and Thorup (2001) maintain connectivity under edge insertions and deletions in O(log⁡2n)O(\log^2 n) amortized time per update, 2-edge connectivity in O(log⁡4n)O(\log^4 n) and biconnectivity in O(log⁡5n)O(\log^5 n), all deterministically.

Key takeaways

  • In an undirected DFS every non-tree edge joins a vertex to an ancestor, so removing a tree edge or a vertex cuts off a subtree exactly when no back edge climbs out of it far enough.
  • With low[v]\mathrm{low}[v] the earliest discovery time reachable from TvT_v through one back edge: (u,v)(u, v) is a bridge iff low[v]>d[u]\mathrm{low}[v] > d[u]; a non-root uu is an articulation point iff some child has low[v]≥d[u]\mathrm{low}[v] \ge d[u]; the root iff it has two or more children.
  • One DFS with an edge stack yields every biconnected component in O(n+m)O(n + m). Contracting the 2-edge-connected components gives the bridge tree, and blocks with cut vertices form the block-cut tree.
  • A connected graph can be oriented to be strongly connected exactly when it has no bridge (Robbins, 1939), and a DFS builds such an orientation in linear time.

Check yourself

In the interactive lesson these are scored with your confidence, and what you miss comes back for review.

Question 1

A bridge-finding DFS skips every edge that leads back to the parent vertex. On a graph whose only edges are two parallel edges between uu and vv, what does it report?

  1. No bridge, which is correct
  2. One of the two edges as a bridge, although neither is one
  3. Both edges as bridges
  4. uu as an articulation point
Show the answer

B. One of the two edges as a bridge, although neither is one

DFS from uu crosses the first edge to vv. At vv the second edge also leads to the parent vertex uu, so it is skipped too, low[v]\mathrm{low}[v] stays d[v]>d[u]d[v] > d[u], and the first edge is reported. Skipping only the index of the arrival edge treats the parallel edge as a back edge and gives the right answer: the two edges form a cycle.

Question 2

The root of a DFS tree has exactly one child. Is it an articulation point?

  1. Yes, whenever its degree is at least 2
  2. Only if the low-link of its child equals 1
  3. No: every other vertex lies in the child's subtree, which stays connected without the root
  4. Yes, always: the search started there
Show the answer

C. No: every other vertex lies in the child's subtree, which stays connected without the root

All other vertices are descendants of the single child cc, and TcT_c is held together by tree edges that avoid the root. Extra edges at the root are back edges into TcT_c, which change nothing. The test low[c]≥d[root]\mathrm{low}[c] \ge d[\text{root}] holds for every child of the root, which is why the root needs its own rule.

Question 3

A connected road network has exactly one bridge. Can every road be made one-way so that every intersection can still reach every other one?

  1. No: whichever way the bridge points, one side can never reach the other
  2. Yes: orient the tree edges of a DFS downward and the back edges upward
  3. Yes, provided the network has an even number of roads
  4. Only if the bridge's two ends both have degree at least 3
Show the answer

A. No: whichever way the bridge points, one side can never reach the other

A bridge is the only link between its two sides, so once it points one way, nothing can come back. Robbins's theorem says that this is the only obstacle: without bridges, the DFS orientation is strongly connected.

Question 4

When the DFS returns from a child vv to its parent uu and finds low[v]≥d[u]\mathrm{low}[v] \ge d[u], it pops edges from the edge stack down to and including (u,v)(u, v). What do the popped edges form?

  1. All the edges of the subtree TvT_v
  2. One biconnected component, the block that contains (u,v)(u, v)
  3. One 2-edge-connected component
  4. A simple cycle through uu
Show the answer

B. One biconnected component, the block that contains (u,v)(u, v)

Every block nested deeper in TvT_v was popped earlier, when the search returned through its own articulation point. The edges still above (u,v)(u, v) are those of the block containing (u,v)(u, v), and since low[v]≥d[u]\mathrm{low}[v] \ge d[u] that block cannot reach above uu. A bridge comes out as a block of one edge.

Further reading

  • J. Hopcroft & R. E. Tarjan, "Algorithm 447: Efficient algorithms for graph manipulation," Communications of the ACM 16(6) (1973), 372–378.
  • R. E. Tarjan, "A note on finding the bridges of a graph," Information Processing Letters 2(6) (1974), 160–161.
  • H. E. Robbins, "A theorem on graphs, with an application to a problem of traffic control," American Mathematical Monthly 46(5) (1939), 281–283.
  • J. Holm, K. de Lichtenberg & M. Thorup, "Poly-logarithmic deterministic fully-dynamic algorithms for connectivity, minimum spanning tree, 2-edge, and biconnectivity," Journal of the ACM 48(4) (2001), 723–760.
  • S. Even, Graph Algorithms, 2nd ed., edited by G. Even (Cambridge University Press, 2011), the chapter "Depth-First Search".