learngraphtheory.org

Guest User

Using app without sign in

Cover of the book Graph Theory Through Problems

Practice book

Graph Theory Through Problems

300 Exercises with Hints, Worked Algorithms and Complete Solutions

By Mohammed Islam Hadjoudj

Learn graph theory by solving problems: 300 exercises, from routine checks to challenging proofs, each with a complete solution.

Available inKindlePaperback

13 chapters

Also by the authorGraph Algorithms for Coding Interviews100 solved interview problems with visual explanations and Python solutions.View on Amazon
Algorithm Selection

Select an algorithm and generate steps to begin visualization

Biconnected Components Calculator

The pieces that survive losing any one vertex

Splits an undirected graph into blocks that survive losing any one vertex, and finds the cut vertices

Time: O(V + E)
Space: O(V + E)
Use Case: Single points of failure, block-cut trees, network reliability
Showing the example graph for this algorithm.
Algorithm Execution

Select an algorithm and generate steps to begin visualization

About Biconnected Components

A biconnected component, or block, of an undirected graph is a maximal subgraph that stays connected after deleting any single vertex. Every edge belongs to exactly one block, two blocks share at most one vertex, and the shared vertices are exactly the cut vertices (articulation points). A bridge is a block with a single edge. Hopcroft and Tarjan gave the linear-time algorithm in 1973.

How it works

A depth-first search numbers the vertices in the order it reaches them, disc(v), and computes low(v): the smallest disc that v's part of the DFS tree can reach with one back edge. Every edge the search uses, tree edge or back edge, is pushed on a stack. When the search returns from a child v to its parent u and low(v) ≥ disc(u), nothing below v reaches above u, so u separates that part from the rest: the edges on the stack down to u - v are popped as one block. The vertex u is then a cut vertex, unless it is the DFS root with a single child. One DFS does everything in O(V + E) time.

Applications

Blocks and cut vertices measure how fault-tolerant a network is: a cut vertex is a single point of failure in communication, power and transport networks. The block-cut tree built from them is used in planarity testing, in algorithms for 2-SAT and Hamiltonicity, and in network design that adds the fewest links to remove every single point of failure. Biconnectivity is a standard topic after articulation points and bridges in graph theory courses.

Pseudocode

The Hopcroft-Tarjan algorithm finds the biconnected components, or blocks, in one depth-first search. It keeps the edges on a stack and pops off a whole block whenever a vertex turns out to separate its subtree from the rest.

Biconnected(graph):
    time = 0,  edgeStack = []
    for each vertex u not yet visited: visit(u, none)

visit(u, parent):
    disc[u] = low[u] = ++time
    for each neighbor v of u:
        if v not visited:                    // tree edge
            push (u, v) on edgeStack
            visit(v, u)
            low[u] = min(low[u], low[v])
            if low[v] >= disc[u]:            // u separates v
                pop edges down to (u, v): one block
        else if v != parent and disc[v] < disc[u]:   // back edge
            push (u, v) on edgeStack
            low[u] = min(low[u], disc[v])

low[v] is the smallest discovery time reachable from the subtree of v using tree edges down and at most one back edge up. When low[v] >= disc[u], nothing below v can climb above u, so the edges pushed since (u, v) form a block that meets the rest of the graph only at u. A vertex that closes such a block is a cut vertex, except that the DFS root is one only if it has two or more tree children.

Worked example, step by step

Find the blocks of the example this page loads, which is the same graph as the articulation points and bridges pages: two triangles joined through a path, plus a pendant vertex.

Example graph: Undirected edges A-B, A-C, B-C (first triangle), C-D (a link), D-E, D-F, E-F (second triangle) and F-G (a pendant edge).

  1. Descend from A. The DFS visits A, B and C with disc 1, 2 and 3, pushing A-B and B-C. At C the edge back to A is a back edge, so it is pushed too and low(C) becomes 1.
  2. Into the second triangle. From C the DFS crosses C-D to D (disc 4), then E (5) and F (6). At F the edge back to D is a back edge, pushed, and low(F) becomes 4.
  3. Block {F, G}. F has one more neighbour, G (disc 7), a leaf. On returning, low(G) = 7 >= disc(F) = 6, so the single edge F-G is popped as block 1, and F is a cut vertex.
  4. Block {D, E, F}. Back at E, low(E) takes the 4 from F. Returning to D, low(E) = 4 >= disc(D) = 4, so the edges E-F, F-D and D-E are popped as block 2. D is a cut vertex.
  5. Blocks {C, D} and {A, B, C}. Back at C, low(D) = 4 >= disc(C) = 3, so C-D alone is block 3 and C is a cut vertex. Finally low(B) = 1 >= disc(A) = 1 pops the triangle A-B-C as block 4. A is the root with a single child, so it is not a cut vertex.

There are four blocks, {F, G}, {D, E, F}, {C, D} and {A, B, C}, and three cut vertices, C, D and F, each belonging to two blocks. The two blocks with a single edge, C-D and F-G, are exactly the bridges of the graph. Joining each block to its cut vertices gives the block-cut tree, here a simple path: {A, B, C}, C, {C, D}, D, {D, E, F}, F, {F, G}.

Complexity, and where it comes from

Time: O(V + E) · Space: O(V + E)

The DFS visits each vertex once and examines each edge once from each endpoint. Every edge is pushed onto the edge stack exactly once, as a tree edge or as a back edge, and popped exactly once, so the stack operations add O(E) in total. The arrays disc and low take O(V) and the edge stack up to O(E). The whole decomposition therefore costs the same as a single DFS, which is what made the 1973 Hopcroft-Tarjan paper a landmark.

When to use Biconnected Components, and when not to

Biconnected components refine several simpler connectivity questions. Choose the one that matches what may fail in your network.

AlternativePrefer it whenCost
Articulation pointsYou only need the vertices whose removal disconnects the graph, not the pieces between them.O(V + E)
BridgesLinks fail rather than nodes, so you want the single edges whose removal disconnects the graph.O(V + E)
2-edge-connected componentsYou want the pieces that survive the loss of any one edge. They are what remains after deleting all bridges.O(V + E)
SPQR treesYou need the next level, triconnected components, for example in graph drawing or planarity testing.O(V + E)

Common pitfalls

  • Partitioning vertices instead of edges. Blocks partition the edges, not the vertices. A cut vertex belongs to every block it joins, so C appears in both {A, B, C} and {C, D}. Code that assigns each vertex to one block cannot represent this.
  • Popping vertices instead of edges. Keeping a vertex stack, as for strongly connected components, loses the cut vertices, which must be shared. Keep an edge stack and pop edges down to and including the tree edge (u, v).
  • Pushing each back edge twice. An undirected back edge is seen from both ends. Push it only from the deeper endpoint, the one with the larger discovery time, or the same edge ends up in two blocks.
  • Treating the root like any other vertex. The root always satisfies low[v] >= disc[root], so the block test still works, but the root is a cut vertex only if it has at least two DFS children. Reporting it otherwise is a classic bug.

Frequently asked questions

What is a biconnected component?
A maximal subgraph that stays connected when any single vertex is removed, also called a block. Every edge lies in exactly one block, two blocks share at most one vertex, and the shared vertices are the cut vertices of the graph.
How do you find biconnected components?
With one depth-first search that records discovery times and low values, and keeps the visited edges on a stack. Whenever a child v of u has low[v] >= disc[u], the edges on the stack down to (u, v) form one block.
What is the time complexity of finding biconnected components?
O(V + E). It is a single DFS, and each edge is pushed onto and popped from the edge stack exactly once.
What is the difference between articulation points and biconnected components?
Articulation points are the individual vertices whose removal disconnects the graph. Biconnected components are the pieces between them. The same DFS finds both: each time a block is popped, the vertex at its top is an articulation point, except for the root with one child.
What is a block-cut tree?
A tree with one node for each block and one for each cut vertex, where a cut vertex is joined to every block containing it. It shows how the blocks hang together, and many problems on general graphs reduce to simpler problems on this tree.

Related algorithms: Articulation Points, Bridge Finding, Connected Components, Tarjan's SCC Algorithm

Interactive Controls

Zoom Controls

34%
Nodes: 7
Edges: 8