Finding the edge connectivity of directed graphs

Finding the edge connectivity of directed graphs

JOURNAL OF ALGORITHMS l&76-85 Finding (1989) the Edge Connectivity Directed Graphs of YISHAYMANSOUR* Laboratory for Computer Science, Massachu...

577KB Sizes 36 Downloads 138 Views

JOURNAL

OF ALGORITHMS

l&76-85

Finding

(1989)

the Edge Connectivity Directed Graphs

of

YISHAYMANSOUR* Laboratory

for Computer Science, Massachusetts Institute Cambridge, Massachusetts 02139

of Technology,

AND BARUCHSCHIEBER IBM-

Research Division, T. J. Watson Research Yorktown Heights, New York 10598

Center,

Received February 26,1988; accepted April 19,1988

We present two algorithms for finding the edge connectivity of a given directed graph G. The first algorithm runs in O( nm) time, where n is the number of vertices and m is the number of edges in G. The second algorithm runs in 0(Azn2) time, where A is the edge connectivity of G. Combining both algorithms yields an O(MIN( m, A2n}n) time algorithm for finding the edge connectivity of directed graphs. We also present an O(MIN( m, k*n ) n) time algorithm for deciding whether the edge connectivity of a given directed graph G is at least k. Both algorithms are superior to the best known algorithms for finding the edge connectivity of directed graphs. 0 1989 Academic PRY.S. hc.

1. INTRODUCTION Connectivity of graphs is considered as one of the classical subjects in graph theory. (See, e.g., [Be-76, Ha-69, Ev-791.) Connectivity in general, and edge connectivity in particular, have many practical applications. For example, in chip and circuit design, reliability of communication networks and cluster analysis. This paper considers the problem of determining the

*Supported by an ISEF fellowship and by NSF Contract CCR8611442.

76 0196-6774/89 $3.00 Copyright All rights

0 1989 by Academic Press, Inc. of reproduction in any form reserved.

EDGE

CONNECTIVITY

OF

DIRECTED

GRAPHS

77

edge connectivity of directed graphs. We present two algorithms for finding the edge connectivity of a given directed graph G. The first algorithm runs in 0( nm) time, where n is the number of vertices and m is the number of edges in G. The second algorithm runs in 0(X%*) time, where X is the edge connectivity of G. Combining both algorithms yields an O(MIN{ m, A’n} n) time algorithm for finding the edge connectivity of directed graphs. A directed graph G is k-edge connected if its edge connectivity is at least k. We present an O(MIN( m, k*n}n) time algorithm for testing whether a given directed is k-edge connected. Much effort was made to find efficient algorithms for determining the edge connectivity of graphs. Two efficient algorithms are known for this problem. Even and Tarjan’s algorithm [ET-751 finds the edge connectivity of a given directed graph G in O(MIN( n213, m’/*}nm) time. Schnorr [SC-791 gave an O(knm) time algorithm for testing whether a given directed graph G is k-edge connected. Schnorr’s algorithm can be used to derive an O(Xnm) time algorithm for finding the edge connectivity of G. Combining both algorithms yields an O(MIN( A, n213}nm) time algorithm for finding the edge connectivity and an O(MIN{ k, n*/‘}nm) time algorithm for testing k-edge connectivity of directed graphs. (Remarks. (1) Observe that MIN{ A, n2’3 } is always 2 ml/*. (2) Both algorithms have the same complexity bounds when applied to undirected graphs.) Our algorithms are superior to the best known algorithms for any value of n, m, A, and k. Moreover, note that when m = Q(n*) we can test whether G is k-edge connected using our algorithm in linear time, for any fixed k. Matula [Ma-871, following Esfahanian and Hakimi [EH-841, revealed an interesting relation between dominating sets and minimum cuts in undirected graphs. Based on this relation, Matula [Ma-871 gave efficient algorithms for testing k-edge connectivity and finding the edge connectivity of undirected graphs. Both his algorithms and their time complexity are heavily based on observations which are valid only for undirected graphs. This paper reveals a similar, but weaker, relation between dominating sets and minimum cuts in directed graphs. We derive our algorithms from this relation. Our O(A*n*) time algorithm combines ideas from [Ma-871 and [SC-791 together with a different technique for analyzing the time complexity of the algorithm. Our O(nm) time algorithm is based on the respective algorithm given in [Ma-871 combined with observations that are needed for the directed case. The paper is organized as follows. Section 2 establishes a relationship between minimum cuts and dominating sets. Section 3 presents an O(nm) time algorithm for finding the edge connectivity of a given directed graph G. Section 4 presents an 0( k*n*) time algorithm for testing k-edge connectivity and shows how to use this algorithm to derive an O(A’n*) time algorithm for finding the edge connectivity.

78

MANSOUR AND SCHIEBER 2. EDGE CONNECTIVITY AND DOMINATING

SETS

Let G( V, E) be a directed graph with no self loops or multiple edges. Let u and u be two distinct vertices in V. A u - u edge separator is a set of edges S c E, such that every directed path from u to u uses at least one edge from S. Define M(u - u) as the minimum cardinality of a u - u edge separator. The edge connectivity h of G is defined as X = MIN{ M( u - u): (2.4,u) E v x v, u f u}. Motivation for the algorithms. Suppose that the edge connectivity of G is A. Then, there are at least two vertices u and u in V such that M(u - u) is X. The problem is how to find two such vertices. The naive way is to check all n( n - 1) possible ordered pairs of vertices in V. Schnorr [SC-791 has shown that it is sufficient to check the minimum cardinality of an edge separator for only n pairs. We identify a smaller set of pairs for which we have to check the minimum cardinality of an edge separator. DEFINITIONS. (1) A set 0 E. V is an outgoing dominating set if for every vertex u E V - 0 there is a vertex u E 0 such that (u, u) E E. (Throughout this paper the ordered pair (a, u) will denote the edge directed from u to u.) (2) A set I c V is an ingoing dominating set if for every vertex u E V - I there is a vertex u E I such that (u, U) E E. (3) Let A c V be a subset of vertices in G. The cut (A : A> is the set of all edges directed from vertices in A to vertices in A = V - A. The size of the cut is the cardinality of the set.

It is well known that if the edge connectivity of G is X then there exists a cut (A : x) in G of size h. Moreover, for any pair u E A and u E AT M(u - u) is X. Let 6, (resp. S,,,) denote the minimum indegree (resp. outdegree) in G. ‘Let 6 be MIN{ 6,, a,,,}. The following lemmas are the basis for the algorithm. LEpL4 1. Let 0 be an outgoing dominating set in G. For euery cut (A : A) of size smaller than S, at least one of the vertices in 0 is in A.

ProoJ: Let the size of (A : A> be c < ai,. Consider the sum of the indegrees over all vertices in x On one hand, this sum can not be more than c + (5 - l)Z, where 5 = 1x1. On the other hand, it is at least 26,. Thus, c + (5 - l)Z 2 ifain, implying that (Z - l)(Z - 6,) 2 8, - c > 0. Since Z - 1 is nonnegative we must have that Z > 6, 2 c. Note that all the vertices in A can dominate at most c vertices in A. This is, since the number of edges directed from vertices in A to vertices in Ais c. However,

EDGE

CONNECTIVITY

OF

DIRECTED

79

GRAPHS

there are more than c vertices in Aand hence at least one of them must be in 0. 0 LEMMA 2.

Let I be an ingoing dominating set in G. For every cut (A : A)

of size smaller than S,,, at least one of the vertices in I is in A.

Proof: The proof follows the lines of the proof of Lemma 1, and hence is omitted. 0 Suppose the edge connectivity of G is X < 6. This implies that there exists a cut (A : x) in G of size h < 6. To compute the connectivity correctly it is sufficient to check the minimum cardinality of an edge separator of a “good” pair of vertices, that is, a pair a - b such that a E A and b E x Let v be a vertex in V. Let 0 = {v = x0,. . . , xi} be an outgoing dominating set and I = {v = y,,, . . . , yk} be an ingoing dominating set. We claim that there must be at least one “good” pair among the pairs v - x, for x E 0 and y - v, for y E I. To show this consider the following two cases: Cu.se A. v is in A. By Lemma 1 at least one vertex from 0 is in x Hence there is at least one “good” pair among the pairs v - x, for x E 0. Case B. Not Case A, that is, v is in x By Lemma 2 at least one vertex from I is in A. Hence there is at least one “good” pair among the pairs y - v, for y E I. Clearly, if the minimum cardinality of an edge separator of all these pairs is greater or equal to 8, then the edge connectivity of G is 6.

3.

ALGORITHM

I:

FINDING

EDGE

CONNECTIVITY

IN

O(nm) TIME

This section describes an algorithm for finding the edge connectivity of a directed graph in O(nm) time. Clearly, this algorithm can be used also for testing k-edge connectivity in O(nm) time. The algorithm for computing the connectivity has two phases. The first phase “grows” an outgoing dominating set 0 = {v = x,,, xi, x2,. . . }, starting from some vertex v and computes the maximum number of edge disjoint paths between {v = xO9* * * 7 xi-l } and xi,for i- 1,2 ,... . The second phase “grows’ an ingoing dominating set I = {v = yo, y,, y,, . . . }, starting from the same vertex v and computes the maximum number of edge disjoint paths between yi and {v =y,,..., yiel}, for i = 1,2,. . . . If the minimum over all these

MANSOUR

80

AND SCHIEBER

maxima is less than 6 then it is the edge connectivity, otherwise, the edge connectivity is 6. Below is a detailed description of the algorithm. INITIALIZATION

Let k * 8. Let v be a vertex with a maximum outdegree. (Remark. complexity analysis do not depend on the choice of v.)

Step Step

0.1. 0.2.

Step

1.1. Let 0 +- {v), U * V - 0 - (u: (v, u) E E) and T + {u: (v, u) E E). (Remark. The set T is only needed in the analysis and can be dropped from the algorithm.) 1.2. If U = 0 then start Phase 2.

Step

The

correctness and the

DEFINITIONS. For a vertex u, and a subset of vertices X c V, let diz( u) be the number of edges directed from a vertex in X to u. Similarly, let d$( u) be the number of edges directed from u to a vertex in X. Step Step

1.3. Find a vertex u E U for which d:,(u) 2 dE( u). 1.4. Compute k’, the maximum number of edge disjoint paths from the vertices in 0 to u. This is done by finding the maximum flow from the vertices in 0 to u in the network defined by assigning a unit capacity to each edge in G. If k’ -C k then let

Step

1.5. Let 0 + 0 U (u), T + and return to Step 1.2.

k +

PHASE

k’. T u (w:

(u,

w)

E E},

LI *

t!/ -

{u}

-

(w:

(u,

w)

E E}

2.

Let I + (v}, U + V - I - (u: (u, v) E E} and T + {u: (u, v) E E}. If U = 0 then stop and report that the connectivity of G is k. Find a vertex u E U for which d:(u) 2 d$(u). Step Compute k’, the maximum number of edge disjoint paths from u to the vertices in I. If k’ < k then let k + k’. Srep2.5.LetI~IU(u),T~T~(w:(w,u)~E},U~Li-(u)-(w:(w,~)~E} and return to Step 2.2. Step Step Step

2.1. 2.2. 2.3. 2.4.

CORRECTNESS THEOREM. any directed graph G.

Algorithm

I computes the edge connectivity

of

Proof. Suppose the algorithm reports that the connectivity of G is k. Clearly, the edge connectivity of G is at most k, since at some point an edge separator of size k was found. We show that the connectivity of G is indeed k. Assume that the connectivity of G is less than k. Then there exists a cut (A : A> in G of size less than k I 6. There are two cases: Case A. u is in A. (Recall that u is the first vertex added to 0 in Phase 1 of the algorithm.) When Phase 1 terminates 0 is an outgoing dominating set. Thus, by Lemma 1, at least one vertex in 0 is in x Let TVbe the first vertex added to 0 which is in Aand let 0’ be the set of vertices which were in 0 when u was found in Step 1.3. Since, 0’ c A and u E A\ there are no k edge disjoint paths from the vertices in 0’ to u. Thus, no k such paths could be found in Step 1.4.

EDGE

CONNECTIVITY

OF

DIRECTED

81

GRAPHS

Case B. Not Case A, that is, u is in x By Lemma 2 there is a u E I such that u E A. A contradiction is reached along the same lines as Case A. To conclude the Correctness Theorem we show that in Steps 1.3 and 2.3 some vertex is always found. Recall that in Step 1.3 (resp. Step 2.3) the algorithm searches for a vertex u E lJ, such that d:,(u) 2 d:(u) (resp. d:(u) 2 dg,( u)). Such a vertex always exists, since the sum of the indegrees of vertices in U is equal to the sum of the outdegrees of vertices in U. Hence, there must be at least one vertex u for which d:,(u) 2 d:(u) (resp. disl(U) 2 d$(U)). El TIME

COMPLEXITY

The time complexity

THEOREM.

of Algorithm

I is

0( nm).

Proof. We show that the complexity of Phase 1 is O(nm); the arguments for the complexity of Phase 2 are analogous. Consider iteration i of Phase 1. Let Oi, Ir;., and Vi denote the sets 0, T, and U, respectively, at the start of iteration i. Recall that in iteration i we choose a vertex u E Vi for which dt;,( u) 2 d$(u) and compute the maximum number of edge disjoint paths from the vertices in Oi to u. This maximum number is computed by finding the maximum flow from the vertices in 0, to u in the network defined by assigning a unit capacity to each edge in G. This is done by successive constructions of flow augmenting paths from the vertices in Oi to u. (For details see [Ev-791.) Observe that d,Ti(u) such paths can be constructed in constant time per path. This is done by adding to each edge (t, u) outgoing from a vertex t E q an edge incoming from a vertex in Oi to t, extending it into a path. (Such an edge always exists by the definition of q.) Summing this over all iterations gives O(m) time. The number of remaining flow augmenting paths is bounded by d$(u). Each such path can be constructed in O(m) time. The time needed to construct a path is amortized over the dz;,( u) vertices that are moved from Vi and added to T at the end of iteration i. Since d$,(u) 2 &(u) the amortized time per vertex is bounded by O(m), hence the total time complexity is O(nm). 0

4.

ALGORITHM

II: IN

FINDING o(A2n2)

EDGE

CONNECTIVITY

TIME

In this section we present an O(X2n2) time algorithm for finding the edge connectivity of G, and an 0( k2n2) time algorithm for testing if G is k-edge connected. First, we describe the algorithm for testing k-edge connectivity. This algorithm is used as a subroutine in the edge connectivity algorithm.

82

MANSOUR

AND SCHIEBER

4.1. Testing k-Edge Connectivity The structure of our algorithm for testing k-edge connectivity is similar to the structure of the algorithm for finding the edge connectivity described in Section 3. Suppose we need to test the k-edge connectivity of G, for Motivation. some k. If k > S then G is not k-edge connected. Assume that k I S and that the edge connectivity of G, X is less than k. This implies that there exists a cut (A : A> in G of size X, such that X < k _<6. To decide if this is the case we check the minimum cardinality of an edge separator of a “good” pair of vertices, that is a pair a - b such that a E A and b E 2 Let v be a vertex in V. As before, we claim that for any outgoing dominating set 0 and ingoing dominating set Z both containing v there must be at least one “good” pair among the pairs v - x, for x E 0 and y - v, for y E I. THE ALGORITHM. The algorithm for testing k-edge connectivity has two phases. The first phase “grows” an outgoing dominating set 0 = (u = x0, Xl, x2,. . * >, starting from some vertex u and checks whether there are k edge disjoint paths between {v = x0,. . . , xi-i} and xi, for i = set Z = 1,2,... . The second phase “grows” an ingoing dominating starting from the same vertex v and checks whether {~=Yo,Yl,Y2,...)~ there are k edge disjoint paths between y, and {U = yo,. . . , yj-i}, for i= I,2 )... . G is k-edge connected only if all these checks did not fail. Below is a detailed description of the algorithm. Step 0.1. Step 0.2.

If 6 < k then stop and report that the graph is not k-edge connected. Each vertex w, w E V, has a counter COUNT(w). Initially COUNT(w) for each w E V. Step 0.3. Let u be the vertex with the maximum outdegree.

PHASE 1. Step 1.0. Step 1.1. Step 1.2. Step 1.3. Step 1.4.

PHASE

Let 0 + 0 and U +- V. UPDATE-O(e). (Procedure UPDATE-O is described below.) If U = 0 then start Phase 2. Find a vertex u E V with the maximum d;,(u). Check whether there are k edge disjoint paths from the vertices in 0 to u. This is done by testing if there exists a feasible flow of value k from the vertices in 0 to a, in the network defined by assigning a unit capacity to each edge in G. If there are no k edge disjoint paths then stop and report that G is not k-edge connected. Otherwise, call the procedure UPDATE-O(u) and return to Srep 1.2.

2.

Step 2.0. Step 2.1. Step 2.2. Step 2.3.

is set to 0,

Let I * 0 and U + V. UPDATE-I(u). If lJ = 0 then stop and report that G is k-edge connected. Find a vertex u E U with the maximum dg( u).

EDGE

CONNECTIVITY

OF

DIRECTED

83

GRAPHS

Step 2.4. Check whether there are

k edge disjoint paths from u to the vertices in I. If there are no k edge disjoint paths then stop and report that G is not k-edge connected. Otherwise, call the procedure UPDATE-f(u) and return to Step 2.2.

We describe the recursive procedure UPDATE-O, UPDATE-I is similar and hence not described.

the procedure

hOCEDURE UPDATE-O(u): (l)LetO+Ou{u}andU+LI-(u). (2) For each vertex w E II such that (u, w) E E increment COUNT(w) by one. If the counter equals k then call UPDATE-O(w). Note that for each vertex w E LI, COUNT(w) counts the number of edges directed from 0 to w.

CORRECTNESS THEOREM. For any directed graph G, Algorithm whether G is k-edge connected.

II tests

Proof. Observe that a vertex u is added to 0 in Phase 1 of the algorithm only if there are at least k edge disjoint paths between the vertices currently in 0 and u. Similarly, a vertex u is added to I in Phase 2 of the algorithm only if there are at least k edge disjoint paths between u and the vertices currently in I. Based on this observation and using arguments similar to the ones given in the proof of the correctness of Algorithm I, we establish the correctness of Algorithm II. 0 TIME O(k2n2).

COMPLEXITY

THEOREM.

The time complexity

of Algorithm

II is

ProoJ We prove that the complexity of Phase 1 is O(k2n2); the arguments for the complexity of Phase 2 are analogous. First, note that the total time complexity of all the activations of the recursive procedure UPDATE-O is linear in the number of edges. Hence, it is sufficient to analyze the time needed to construct the edge disjoint paths. Consider iteration i of Phase 1. Let Oi and q denote the sets 0 and U at the start of iteration i. Recall that in iteration i we pick a vertex u E U with the maximum d:;,(u) and check if there exists a feasible flow of value k from the vertices in Oj to u in the network defined by assigning a unit capacity to each edge in G. This is done by successive constructions of up to k flow augmenting paths. The time needed to construct one such path is bounded by O(m’), where m’ is the number of edges in the subgraph induced by Vi. This is since each flow augmenting path contains only edges from this subgraph plus one edge which goes from a vertex in Oi to a vertex in v]:. For a vertex w E V, define LEVEL(i, w) as the minimum between k and the number of edges directed from vertices in Oi to w. We amortize the time needed to construct the k paths in iteration i over the difference Di = c ,,.LEVEL(i + 1, w) - XweY LEVEL(i, w). That is, we amortize the time over the total change in the levels of the vertices in iteration i.

84

MANSOUR AND SCHIEBER

Since in iteration i the vertex u is added to O,, Di 2 dz,(u). Note that the outdegree of U, in the subgraph induced by V,, is d:;,(u). Since u was chosen as the vertex with the maximum outdegree in this subgraph, its outdegree is at least the average outdegree which is ml/ 1Uil 2 m’/n and thus Di 2 ml/n. Recall that a construction of a path requires O(m’) time; hence the construction of k paths requires O(km’) time. The amortized complexity per a unit increase of LEVEL is O(km’/D,), which is bounded from above by O(km’/(m’/n)) = O(kn). Let t - 1 be the last iteration in Phase 1. We conclude that the total time is bounded by 0( kn) . (Ei-lDj) = O(kn) * (C ,vE .LEVEL(t, LEVEL(l, w)). For each w E V, w) - Cwcv LEVEL(t, w) _< k and LEVEL(1, w) = 0. Thus the total time is bounded by O(k*n*). q 4.2. Finding

Edge Connectivity

We present an algorithm for finding the edge connectivity of G using the algorithm for testing k-edge connectivity as a subroutine. Start by testing if G is k-edge connected, for k = 1,2,4,. . _ until the first failure. Let 2’ be the last value checked. We conclude that 2’-’ I X < 2’. Clearly, all these testings are done in O(A*n*) time. To find the exact value of X we test whether G is MIN{2’, 6}-edge connected. For this we apply again Algorithm II but with the following modification. We do not stop when a failure is detected, but record the maximum number of paths found at each iteration. If the minimum among these maxima is less than 6 then it is also the edge connectivity, otherwise G is S-edge connected. Clearly, this step is also done in O(A*n*) time. ACKNOWLEDGMENT We thank Baruch Awerbuch and Shay Kutten for helpful comments. Note added in proof [Al-881. Let o be a vertex in V, 0 be an outgoing dominating set and I be an ingoing dominating set. In Section 2 we show that to compute the connectivity correctly it is sufficient to compute the minimum cardinality of an edge separator of the pairs u - x, for x E 0 and y - v, for y E I. Bach such computation can be done in O(n2’3m) time using the max flow algorithm of (ET-75J. It can be shown that using the greedy algorithm we can construct an outgoing dominating set and an ingoing dominating set of size 0(( n/S)log S), where 8 is the minimum degree in G. This gives an alternative algorithm for fiiding the edge connectivity of directed graphs which runs in O((n5/3m/8)log 8) time. A similar algorithm with the same time complexity can be designed for the undirected case.

REFERENCES [Al-881 [Be-761

N. &ON, Personal communication. C. BERGE, “Graphs and Hypergraphs,” North-Holland,

Amsterdam, 1976.

EDGE

[EH-841 [Ev-791 [ET-751 [Ha-691 [Ma-871 [SC-791

CONNECTIVITY

OF

DIRECTED

GRAPHS

85

H. ESFAHAMAN AND S. L. HAKIM, On computing the connectivities of graphs and digraphs, Networks (1984), 355-366. S. EVEN, “Graph Algorithms,” Computer Science Press, Rockville, MD, 1979. S. EVEN AND R. E. TARIAN, Network flow and testing graph connectivity, SIAM J. Comput. (1975), 507-518. F. HARARY, “Graph Theory,” Addison-Wesley, Reading, MA, 1969. D. W. MATULA, Dete rmining edge connectivity in O(nm), in “Proceedings, 28th Symp. on Foundations of Computer Science, 1987,” pp. 249-251. C. P. SCNORR, Bottlenecks and edge connectivity in unsymmetrical networks, SIAM J. Compur. (1979), 265-274.

A.