18.6
|
Program 18.6 Edge connectivity
The constructor in this DFS class counts the bridges in a graph so that
class GraphECC { private Graph G; private int cnt, bcnt; private int[] low, ord; private void searchC(Edge e) { int w = e.w; ord[w] = cnt++; low[w] = ord[w]; AdjList A = G.getAdjList(w); for (int t = A.beg(); !A.end(); t = A.nxt()) if (ord[t] == -1) { searchC(new Edge(w, t)); if (low[w] > low[t]) low[w] = low[t]; if (low[t] == ord[t]) bcnt++; // w-t is a bridge } else if (t != e.v) if (low[w] > ord[t]) low[w] = ord[t]; } GraphECC(Graph G) { this.G = G; bcnt = 0; cnt = 0; ord = new int[G.V()]; low = new int[G.V()]; for (int v = 0; v < G.V(); v++) { ord[v] = -1; low[v] = -1; } for (int v = 0; v < G.V(); v++) if (ord[v] == -1) searchC(new Edge(v, v)); } int count() { return bcnt+1; } }
|
As we did for regular connectivity in Program 18.4, we may wish to use Program 18.6 to build a class for testing whether a graph is edge-connected or to count the number of edge-connected components. If desired, we can proceed as for Program 18.3 to gives clients the ability to create (in linear time) objects that can respond in constant time to queries that ask whether two vertices are in the same edge-connected component (see Exercise 18.36).
We conclude this section by considering other
When we speak of removing a vertex , we also mean that we remove all its incident edges. As illustrated in Figure 18.19, removing either of the vertices on a bridge would disconnect a graph (unless the bridge were the only edge incident on one or both of the vertices), but there are also other vertices, not associated with bridges, that have the same property.
This graph has two edge-connected components and one bridge. The edge-connected component above the bridge is also biconnected; the one below the bridge consists of two biconnected components that are joined at an articulation point .
Definition 18.2 An articulation point in a graph is a vertex that, if removed, would separate a connected graph into at least two disjoint subgraphs .
We also refer to articulation points as
separation vertices
or
cut vertices
. We might use the
Definition 18.3 A graph is said to be biconnected if every pair of vertices is connected by two disjoint paths .
The requirement that the paths be disjoint is what distinguishes biconnectivity from edge connectivity. An alternate definition of edge connectivity is that every pair of vertices is connected by two edge-disjoint paths ”these paths can have a vertex (but no edge) in common. Biconnectivity is a stronger condition: An edge-connected graph remains connected if we remove any edge, but a biconnected graph remains connected if we remove any vertex (and all that vertex's incident edges). Every biconnected graph is edge-connected, but an edge-connected graph need not be biconnected. We also use the term separable to refer to graphs that are not biconnected, because they can be separated into two pieces by removal of just one vertex. The separation vertices are the key to biconnectivity.
Property 18.7
A graph is biconnected if and only if it has no separation vertices (articulation points) .
Proof : Assume that a graph has a separation vertex. Let s and t be vertices that would be in two different pieces if the separation vertex were removed. All paths between s and t must contain the separation vertex; therefore the graph is not biconnected. The proof in the other direction is more difficult and is a worthwhile exercise for the mathematically inclined reader (see Exercise 18.40).
We have seen that we can partition the edges of a graph that is not connected into a set of connected subgraphs and that we can partition the edges of a graph that is not edge-connected into a set of bridges and edge-connected subgraphs (which are connected by bridges). Similarly, we can divide any graph that is not biconnected into a set of bridges and biconnected components , which are each biconnected subgraphs. The biconnected components and bridges are not a proper partition of the graph because articulation points may appear on multiple biconnected components (see, for example, Figure 18.20). The biconnected components are connected at articulation points, perhaps by bridges.
This graph is not biconnected. The vertices , 4 , 5 , 6 , 7 , and 11 (shaded) are articulation points. The graph has five biconnected components: one comprising edges 4-9 , 9-11 , and 4-11 ; another comprising edges 7-8 , 8-10 , and 7-10 ; another comprising edges 0-1 , 1-2 , 2-6 , and 6-0 ; another comprising edges 3-5 , 4-5 , and 3-4 ; and the single vertex 12 . Adding an edge connecting 12 to 7 , 8 , or 10 would biconnect the graph .
A connected component of a graph has the property that there exists a path between any two vertices in the graph. Analogously, a biconnected component has the property that there exist two disjoint paths between any pair of vertices.
We can use the same DFS-based approach that we used in Program 18.6 to determine whether or not a graph is biconnected and to identify the articulation points. We omit the code because it is very similar to Program 18.6, with an extra test to check whether the root of the DFS tree is an articulation point (see Exercise 18.43). Developing code to print out the biconnected components is also a worthwhile exercise that is only slightly more difficult than the corresponding code for edge connectivity (see Exercise 18.44).
Property 18.8
We can find a graph's articulation points and biconnected components in linear time .
Proof : As for Property 18.7, this fact follows from the observation that the solutions to Exercises 18.43 and 18.44 involve minor modifications to DFS that amount to adding a few constant-time tests per edge.
Biconnectivity generalizes simple connectivity. Further generalizations have been the subjects of
Definition 18.4 A graph is k-connected if there are at least k vertex-disjoint paths connecting every pair of vertices in the graph. The vertex connectivity of a graph is the minimum number of vertices that need to be removed to separate it into two pieces .
In this terminology, "1-connected" is the same as "connected" and "2-connected" is the same as "biconnected." A graph with an articulation point has vertex connectivity 1 (or 0), so Property 18.7 says that a graph is 2-connected if and only if its vertex connectivity is not less than 2. It is a special case of a classical result from graph theory, known as
Whitney's theorem
, which says that a graph is
k
-connected if and only if its vertex connectivity is not less than
k
. Whitney's theorem follows directly from
Menger's theorem
(see Section 22.4), which says that the minimum number of vertices whose removal disconnects two vertices in a graph is equal to the maximum number of vertex-disjoint paths between the two vertices (to
Definition 18.5 A graph is k “edge-connected if there are at least k edge-disjoint paths connecting every pair of vertices in the graph. The edge connectivity of a graph is the minimum number of edges that need to be removed to separate it into two pieces .
An edge-connected graph has edge connectivity greater than 1, and a graph with at least one bridge has edge connectivity 1) so, in this terminology "2 “edge-connected" is the same as "edge-connected." Another version of Menger's theorem says that the minimum number of vertices whose removal disconnects two vertices in a graph is equal to the maximum number of vertex-disjoint paths between the two vertices, which implies that a graph is k “edge-connected if and only if its edge connectivity is k .
With these definitions, we are led to generalize the connectivity problems that we
st-connectivity What is the minimum number of edges whose removal will separate two given vertices s and t in a given graph? What is the minimum number of vertices whose removal will separate two given vertices s and t in a given graph?
General connectivity Is a given graph k -connected? Is a given graph k “edge-connected? What is the edge connectivity and the vertex connectivity of a given graph?
Although these problems are much more difficult to solve than are the simple connectivity problems that we have considered in this section, they are
18.33 If a graph is a forest, all its edges are separation edges; but which vertices are separation vertices?
18.34 Consider the graph
Draw the standard adjacency-lists DFS tree. Use it to find the bridges and the edge-connected components.
18.35 Prove that every vertex in any graph belongs to exactly one edge-connected component.
18.36 Add a method to Program 18.6 that allows clients to test whether two vertices are in the same edge-connected component.
18.37 Consider the graph
Draw the standard adjacency-lists DFS tree. Use it to find the articulation points and the biconnected components.
18.38 Do the previous exercise using the standard adjacency-matrix DFS tree.
18.39 Prove that every edge in a graph either is a bridge or belongs to exactly one biconnected component.
18.40 Prove that any graph with no articulation points is biconnected. Hint : Given a pair of vertices s and t and a path connecting them, use the fact that none of the vertices on the path are articulation points to construct two disjoint paths connecting s and t .
18.41 Write a class for determining whether a graph is biconnected, using a brute-force algorithm that runs in time proportional to V ( V + E ). Hint : If you mark a vertex as having been seen before you start the search, you effectively remove it from the graph.
18.42 Extend your solution to Exercise 18.41 to develop a class that determines whether a graph is 3-connected. Give a formula describing the approximate number of times your program examines a graph edge, as a function of V and E .
18.43 Prove that the root of a DFS tree is an articulation point if and only if it has two or more (internal) children.
18.44 Write a class that prints the biconnected components of the graph.
18.45 What is the minimum number of edges that must be present in any biconnected graph with V vertices?
18.46 Modify Program 18.6 to simply determine whether or not the graph is edge-connected (returning as soon as it identifies a bridge if the graph is not) and instrument it to keep track of the number of edges examined. Run empirical tests to study this cost, for graphs of various sizes, drawn from various graph models (see Exercises 17.64 “76).
18.47 Write a class that allows clients to create objects that know the number of articulation points, bridges, and biconnected components in a graph.
18.48 Run experiments to determine empirically the average values of the
quantities described in Exercise 18.47 for graphs of various sizes, drawn from various graph models (see Exercises 17.64 “76).18.49 Give the edge connectivity and the vertex connectivity of the graph