22-2 Articulation points, bridges, and biconnected components
Let be a connected, undirected graph. An articulation point of is a vertex whose removal disconnects . A bridge of is an edge whose removal disconnects . A biconnected component of is a maximal set of edges such that any two edges in the set lie on a common simple cycle. Figure 22.10 illustrates these definitions. We can determine articulation points, bridges, and biconnected components using depth-first search. Let be a depth-first tree of .
a. Prove that the root of is an articulation point of if and only if it has at least two children in .
b. Let be a nonroot vertex of . Prove that is an articulation point of if and only if has a child such that there is no back edge from or any descendant of to a proper ancestor of .
c. Let
Show how to computer for all vertices in time.
d. Show how to compute all articulation points in time.
e. Prove that an edge of is a bridge if and only if it does not lie on any simple cycle of .
f. Show how to compute all the bridges of in time.
g. Prove that the biconnected components of partition the nonbridge edges of .
h. Give an -time algorithm to label each edge of with a positive integer such that if and only if and are in the same biconnected component.
a. First suppose the root of is an articulation point. Then the removal of from would cause the graph to disconnect, so has at least children in . If has only one child in then it must be the case that there is a path from to each of 's other children. Since removing disconnects the graph, there must exist vertices and such that the only paths from to contain .
To reach from , the path must first reach one of 's children. This child is connect to via a path which doesn't contain .
To reach , the path must also leave through one of its children, which is also reachable by . This implies that there is a path from to which doesn't contain , a contradiction.
Now suppose has at least two children and in . Then there is no path from to in which doesn't go through , since otherwise would be an ancestor of . Thus, removing disconnects the component containing and the component containing , so is an articulation point.
b. Suppose that is a nonroot vertex of and that has a child such that neither nor any of 's descendants have back edges to a proper ancestor of . Let be an ancestor of , and remove from . Since we are in the undirected case, the only edges in the graph are tree edges or back edges, which means that every edge incident with takes us to a descendant of , and no descendants have back edges, so at no point can we move up the tree by taking edges. Therefore is unreachable from , so the graph is disconnected and is an articulation point.
Now suppose that for every child of there exists a descendant of that child which has a back edge to a proper ancestor of . Remove from . Every subtree of is a connected component. Within a given subtree, find the vertex which has a back edge to a proper ancestor of . Since the set of vertices which aren't descendants of form a connected component, we have that every subtree of is connected to . Thus, the graph remains connected after the deletion of so is not an articulation point.
c. Since is discovered before all of its descendants, the only back edges which could affect are ones which go from a descendant of to a proper ancestor of . If we know for every child of , then we can compute easily since all the information is coded in its descendants.
Thus, we can write the algorithm recursively: If is a leaf in then is the minimum of and where is a back edge. If is not a leaf, is the minimum of , where is a back edge, and , where is a child of . Computing for a vertex is linear in its degree. The sum of the vertices' degrees gives twice the number of edges, so the total runtime is .
d. First apply the algorithm of part (c) in to compute for all . If = if and only if no descendant of has a back edge to a proper ancestor of , if and only if is not an articulation point.
Thus, we need only check versus to decide in constant time whether or not is an articulation point, so the runtime is .
e. An edge lies on a simple cycle if and only if there exists at least one path from to which doesn't contain the edge , if and only if removing doesn't disconnect the graph, if and only if is not a bridge.
f. A edge lies on a simple cycle in an undirected graph if and only if either both of its endpoints are articulation points, or one of its endpoints is an articulation point and the other is a vertex of degree . There's also a special case where there's only one edge whose incident vertices are both degree . We can check this case in constant time. Since we can compute all articulation points in and we can decide whether or not a vertex has degree in constant time, we can run the algorithm in part (d) and then decide whether each edge is a bridge in constant time, so we can find all bridges in time.
g. It is clear that every nonbridge edge is in some biconnected component, so we need to show that if and are distinct biconnected components, then they contain no common edges. Suppose to the contrary that is in both and .
Let be any edge in and be any edge in .
Then lies on a simple cycle with , consisting of the path
Similarly, lies on a simple cycle with consisting of the path
This means
is a simple cycle containing and , a contradiction. Thus, the biconnected components form a partition.
h. Locate all bridge edges in time using the algorithm described in part (f). Remove each bridge from . The biconnected components are now simply the edges in the connected components. Assuming this has been done, run the following algorithm, which clearly runs in where is the number of edges originally in .
VISIT-BCC(G, u, k)
u.color = GRAY
for each v ∈ G.Adj[u]
(u, v).bcc = k
if v.color == WHITE
VISIT-BCC(G, v, k)