Mankato State University, P.O. Box 8400. Mankato, MN 56002-8400, USA. Received (received date). Revised (revised date). Communicated by (Name of Editor).
Parallel Processing Letters
c World Scienti c Publishing Company
BIPARTITE EXPANDER MATCHING IS IN NC DAVID J. HAGLIN Computer and Information Sciences Department Mankato State University, P.O. Box 8400 Mankato, MN 56002-8400, USA Received (received date) Revised (revised date) Communicated by (Name of Editor) ABSTRACT A work-ecient deterministic NC algorithm is presented for nding a maximum matching in a bipartite expander graph with any expansion factor > 1. This improves upon a recently presented deterministic NC maximum matching algorithm which is restricted to those bipartite expanders with large expansion factors ( ; > 0), and is not work-ecient [1]. Keywords: Bipartite Matching, Expander Graphs, NC, Network Flow.
1. Introduction
Finding maximum cardinality matchings in bipartite expander graphs has many applications such as routing networks, sorting networks, permutation networks, and path selection. Note that by Hall's Theorem there is a perfect matching in a bipartite expander graph with expansion factor > 1. Thus we are really nding one of the (potentially many) perfect matchings. Bipartite expander graphs are an important part of the design of routing networks such as concentrators and superconcentrators [2]. They are also used in self-routing permutation networks [3]. Another application of bipartite expander matching is in on-line path selection in a non-blocking network, where a maximum matching to a bipartite expander graph problem can be used to extend a set of vertex-disjoint paths by one level [4]. Nonblocking networks arise in many situations such as telephone networks and parallel machine architectures. In this paper we present an algorithm that nds a maximum cardinality matching in O(log6 n= log3 ) time on an EREW PRAM using O(m) processors when given a bipartite expander graph (with expansion factor > 1) as input. Spencer shows how to nd a maximum matching in a bipartite expander in (logn)O(log log n) time on an EREW PRAM using O(nm) processors [5]. Our algorithm runs asymptotically faster and requires fewer processors. Kelsen provides an NC algorithm for 1
nding a maximum matching in a bipartite expander provided > , for any > 0 [1]. Our algorithm does not have any bound on the expansion factor (other than strictly larger than one), and uses fewer processors. Furthermore, for a xed , our algorithm is also work-ecient, unlike the previously known algorithms. The rest of this paper is presented as follows: in section 2 we review terminology and provide some background on this problem, in section 3 we present our algorithm, and in section 4 we prove our algorithm correct and analyze its performance.
2. Background 2.1. De nitions
Let G = (X; Y; E) be a bipartite graph with bipartition (X; Y ) such that E X Y , jX j = jY j = n, and jE j = m. A matching is a set M E such that no two edges in M are incident to the same vertex. A maximal matching is a matching M such that for any edge (u; v) 62 M, the edge set f(u; v)g [ M is not a matching. A maximum matching is a matching M such that for any matching M, jM j jM j. In this paper, we consider the cardinality matching problem which is de ned by letting jM j denote the number of edges in M. That is, there are no weights associated with the edges. If jM j = n, then G has a perfect matching. When there exists a perfect matching and the input graph has weights associated with each edge, the maximum weighted perfect matching problem is that of nding a perfect matching that has total weight at least as large as the total weight of every other perfect matching. Given a vertex set A X [ Y , the set of neighbors of vertices in A is denoted by ?(A). If, for every subset A X (or B Y ) such that jAj jX j (jB j jY j), it is the case that j?(A)j jAj (j?(B)j jB j) for > 1, then we say G is a bipartite expander with expansion factor , denoted by (; )-expander. Clearly 1= . If = 1= , then imposing the restriction jAj jX j (jB j jY j) is super uous. The results in this paper apply to (1= ; )-expanders, and so we drop the restriction and refer to the graphs simply as -expanders. If a bipartite graph exhibits the expansion property from X to Y but not (necessarily) from Y to X, then we call the graph a one-sided expander. All results in this paper require the less restrictive one-sided expanders, which are assumed throughout the rest of this paper. Given a graph G = (V; E) and a matching M, we call a vertex free if it has no incident matched edges. An alternating path is a path where exactly one of the two path edges incident on a given vertex is in M. An augmenting path is an alternating path with both endpoints free. We will make use of a network ow problem which is modeled by a directed acyclic graph G = (V; A) with capacities w(a) 0, for every a 2 A (the arc set), a designated source vertex s 2 V and a designated sink vertex t 2 V . An s ? t ow is an assignment of ow values f(a) for each a 2 A subject to the capacity constraints 0 f(a) w(a). Furthermore, the preservation of ow is not violated. Hence, for 2
every vertex v 2 V ? f s; t g, the sum of the ow along all arcs coming into v (call the incoming arc set in(v)) is equal to the sumPof the ow along P all arcs leaving v (call the outgoing arc set out(v)). Formally, a2in(v) f(a) = a2out(a) f(a), for all v 2 V ? f s; t g. A blocking ow is a ow that satis es the feasibility constraints described above and cannot be increased by simply adding more ow to any s ? t path. Note that although we call the edges in this network arcs to emphasize that they are directed, we will later construct a network from a graph by taking edges and directing them one way or the other. In this case, we will sometimes refer to the arcs as edges since there is a direct correlation between the edges in the graph problem and the arcs in the network problem. 2.2. History
Ecient serial algorithms for several variations of the matching problem are well established [6, 7, 8]. There have been many contributions that provide parallel solutions to the various matching problems. It is known that the maximum cardinality matching problem is in RNC [9, 10]. An NC algorithma exists for nding a maximal matching in general graphs [11, 12]. But the fastest parallel maximum matching algorithm known for general graphs runs in O(n logn) time [13]. Restricting the input to bipartite graphs allows us p to nd a maximum matching in O(n2=3 log3 n) time [14], which was improved to O( m polylog(n)) for sparse graphs (m 2 o(n4=3)) [15]. The only known NC maximum matching algorithms are for classes of graphs more restricted than the bipartite graphs, such as regular bipartite graphs [16] or planar bipartite graphs, where a perfect matching can be found [17]. Curiously, fast deterministic algorithms for nding matchings in parallel seem elusive, though the problem is not known to be P -complete. Since there is a lack of deterministic parallel maximum matching algorithms many approximation algorithms have been presented for these problems. First, there are several results for the maximum cardinality matching problems. An NC approximation scheme is presented in [18], but the processor requirement is very high and depends (exponentially) on the relative error, though it works for the general graph cardinality matching problem. For bipartite graphs, Spencer presents an algorithm (an NC approximation scheme) requiring O(n + m) processors (not dependent upon the relative error) and runs in O((1=)2 log3 n) time [19]. Cohen also describes an NC approximation scheme requiring O(n + m) processors running in O((1=)3 log2 n log(n(1=))) time [20]. For the weighted matching problem there are a few results. Mulmuley, Vazirani, and Vazirani show how to construct a maximum weight perfect matching, provided the edge weights are given in unary, that requires O(log2 n) randomized parallel time and O(n3:5mW) processors, where W is the weight of the heaviest edge [10]. Spirakis demonstrates that there is a fullyb RNC a The term N C is used exclusivelyto mean deterministic N C. We use RN C when randomization is allowed. b The term fully means that an approximation algorithm in the scheme (for a xed relative error ) uses a polynomial number of processors and time polylogarithmic in the size of the input and 1=.
3
approximation scheme for the maximum weight perfect matching problem and for the maximum weight problem [21]. He also shows that there exists a fully NC approximation scheme for the maximum ow, maximumweighted perfect matching, and the maximum weighted matching problems if and only if there exists an NC algorithm to construct a maximum cardinality matching [21]. In this paper, we are considering the class of graphs that are bipartite expanders. Given such a graph, a maximum matching can be found in (log n)O(log log n) time on an EREW PRAM using O(nm) processors [5]. Arora, Leighton, and Maggs showed how to nd a matching when the expansion factor is large relative to the size of the largest degree of a vertex, speci cally, =2 [4]. Kelsen improved this to , > 0 with an algorithm that runs in O(log4 n) time and requires O(n2+2== logn) processors on an EREW PRAM [1].
3. The Algorithm
Our algorithm is based on the Hopcroft and Karp serial algorithm where each iteration (or round) nds and augments length l augmenting paths until no length l augmenting paths exist. (The value of l increases with each round.) We run an entire round of our algorithm in parallel, allowing us to achieve the desired results. We make use of the following lemma: Lemma 1. [6] Given a graph G = (V; E) and a matching M , if M 0 is constructed from M by augmenting along a maximal set of vertex-disjoint augmenting paths of shortest length, then the length of a shortest augmenting path in M 0 is larger then the length of a shortest augmenting path in M 2. Thus our problem is reduced to nding a maximal set of vertex-disjoint augmenting paths of length l (where l is the length of the shortest augment path). We follow the technique of Hopcroft and Karp [6] by constructing an alternate graph (network ow problem) which has the matched edges oriented from the Y vertex to the X vertex, and the unmatched edges directed from the X vertex to the Y vertex. We then add a source vertex s to our directed graph with edges from s to all free vertices in X. Now we do a breadth rst search from s, stopping when we reach a free vertex in Y or upon creating some arbitrary maximum of L levels in the BFS tree. All edges not spanning from one level to the next in the BFS tree are then removed. And nally, we add a sink vertex t and edges (arcs) from all the free vertices in Y (reachable from s) to t. What remains is a network that can immediately be converted to a maximum ow problem by assigning ow capacities of one to each edge. We call this converted graph/network G0 (see g. 1). Note that the depth of this network ow problem is l + 2. We will see later that setting L = (logn= log ) for the case of -expander graphs allows us to nd all augmenting paths in the graph. Now we nd an integral ow in our network. We don't require a maximum ow, merely that the ow is blocking. We show (lemma 2) that an integral blocking ow in G0 corresponds to a maximal set of vertex disjoint augmenting paths in G. We can use an algorithm of Cohen to nd such a ow in O(l2 log3 n) time on an EREW PRAM using O(m=l) processors [20]. 4
g
X:
a
b
c
d
b
e a s
f h
c
i
d
e
Y:
f
g
h
i
a. Bipartite Expander Graph G
j
t j
b. Corresponding Network Flow Problem G0
Fig. 1. Network Flow Graph
A more precise presentation of the algorithm is in g. 2. Note that the algorithm terminates when no more short (length L) augmenting paths exist, unlike the original Hopcroft and Karp algorithm. 1. Find a maximal matching (see [12]). 2. Iterate the following steps until there are no more augmenting paths of length L or less. The value l (l L) will represent the length of the shortest augmenting path. 2.1. Construct a directed graph G0 by orienting matched edges from the Y endpoint to the X endpoint, and the unmatched edges from the X endpoint to the Y endpoint (see [6]). 2.2. Add a source vertex s with edges to all free vertices in X. 2.3. Perform a breadth- rst search from s, stopping as soon as one of the free Y vertices is found, or when L levels of the BFS tree have been created. 2.4. If no free Y vertex is found, the algorithm is done. Otherwise, remove all edges not going from one level to the next in the BFS tree, then add a vertex t with edges from all free Y vertices to t. 2.5. Convert G0 to a network
ow problem by assigning a capacity of one to each arc in G0. 2.6. Use an algorithm of Cohen to nd an integer blocking ow in G0 [20]. 2.7. The blocking ow of step 2.6 corresponds directly to a maximal set of vertex-disjoint augmenting paths in G (with respect to the current matching). These paths are augmented thus eliminating the existence of augmenting paths of length l. Fig. 2. Maximum Matching Algorithm
5
4. Analysis 4.1. Correctness
There are several observations we need in order to show that our algorithm is correct. Hopcroft and Karp ([6]) show that the technique works. Of course, we need to guarantee that the integer blocking ow does indeed give rise to a maximal set of vertex-disjoint augmenting paths and that all augmenting paths in the -expanders are short (length L). Lemma 2. Given a bipartite graph G = (X; Y; E), a matching M , and its corresponding network ow problem G0 as described in the previous section, an integer blocking ow in G0 implies a maximal set of vertex-disjoint augmenting paths.
Proof. Since all arcs in G0 have a unit ow capacity, an integer ow has f(a) = 0 or 1 for every a 2 A. Moreover, the ow conservation constraint implies that every vertex v 2 X [ Y has either no ow through it, or one incoming and
one outgoing arc with a unit ow. The free vertices of X have only one incoming arc (with unit capacity) and the free vertices of Y have only one outgoing arc. All of the vertices inside have the ow going through (either into or out from) an arc corresponding to a matched edge. Hence these vertices cannot support a ow in excess of one. Thus, the unit ow edges form s ? t paths which are vertex disjoint everywhere except for s and t. Removing s and t along with their adjacent arcs, leaves us with vertex-disjoint paths connecting free X vertices to free Y vertices; essentially these are augmenting paths in G. The maximality of this set of augmenting paths comes from the fact that the integer ow in G0 was a blocking
ow 2. What remains to be shown is that all augmenting paths in an expander graph are short. Both Motwani and Kelsen present such results [22, 1]. Lemma 3 paraphrases Kelsen's Lemma 1 and its proof in [1]. Lemma 3. [22, 1] Let M 0 be a maximal, but sub-maximum matching in G = (X; Y; E) and U be the set of free vertices. There exists an augmenting path in G of length at most 2(log(n=jU j)= log ) ? 1. Proof. For notational convenience, let Vi be the set of matched vertices, Vi X [ Y , reachable from a vertex in U by an alternating path of length at most 2i. Assume that there is no augmenting path of length 2l ? 1 for some l 1. P We rst show that jU j lj =1 j jXl j by showing inductively that jU j Pij=1 j jXij, for 1 i l. The base case (i = 1) can be seen by noticing that there are no augmenting paths of length one. Thus, all vertices in ?(U) are matched and hence ?(U) = X1 , which implies jX1j jU j. Suppose the P claim holds for i < k, where k l. Then j?(Xk?1 [ U)j (jXk?1 j + jU j) jU j kj=1 j . Since there is no augmenting path of length 2l ? 1, there is not an augmenting path of length 2k ? 1. Therefore all vertices in ?(XP k ?1 [ U) are matched and hence ?(Xk?1 [ U) = Xk which implies jXk j jU j kj=1 j . Notice that since Xl contains all matched vertices, jXl j < n. Merging the inequalities jXl j < n and 6
jU j Plj =1 j jXl j, we get jU j Plj =1 j n. Furthermore, this implies that jU j l < n, hence l < log(n=jU j)= log 2. Using these observations, we now have the following theorem.
Theorem 1. The algorithm in gure 2 correctly nds a maximum matching in a -expander graph, when L = 2 logn= log 2. 4.2. Work Analysis Theorem 2. The algorithm in gure 2 runs in O(log6 n= log3 ) time on an EREW PRAM using O(m log = logn) processors.
Proof.
Step 1 can be done in O(log3 n) time using O(m= log3 n) processors [12]. By setting L = 2 logn= log , we see that the number of iterations (rounds) of step 2 is bounded by O(logn= log ). Each iteration consists of constructing the directed graph (an O(logn) time, O(m= log n) processor step), performing a breadth- rst search layering down L levels (an O(log2 n= log ) time, O(m= log n) processor step using standard techniques), and a call to Cohen's integer blocking ow algorithm with a network of depth O(L). The integer blocking ow algorithm is the most expensive operation within the iteration requiring O(L2 log3 n) = O(log5 n= log2 ) time and O(m=L) processors. Thus, the entire algorithm will require O(log6 n= log3 ) time and O(m log = log n) processors on an EREW PRAM 2.
5. Summary
Previously, nding maximum matchings in bipartite expanders with large expansion factor ( , > 0) was known to be in NC [1]. We have demonstrated that bipartite expander matching is in NC for any expansion factor > 1. Moreover, our algorithm is work-ecient, unlike previously known algorithms. Finding larger classes of graphs for which maximum matching is in NC has been a challenging problem. Of course, nding an NC algorithm for bipartite matching would answer many questions related to parallel graph matching.
Acknowledgements
The author wishes to thank Marty Wolf for helpful discussions and the anonymous referees for suggestions that greatly improved this paper.
References 1. P. Kelsen, Fast parallel matching in expander graphs, in Proc. 5th Annual Symposium on Parallel Algorithms and Architectures, 1993. 2. O. Gabber and Z. Galil, Explicit constructions of linear-sized superconcentrators, Journal of Computer and System Sciences 22 (1981) 407{420. 3. C. Jan and A. Yavuz Oruc, Fast self-routing permutation networks, in bibit Proc. 20th Annual International Conference on Parallel Processing, 1991, I{263{269.
7
4. S. Arora, T. Leighton and B. Maggs, On-line algorithms for path selection in a nonblocking network, in Proc. 22nd Annual ACM Symposium on Theory of Computing, 1990, 149{158. 5. T. Spencer, Parallel matching on expanders, in Proc. 3rd Annual Symposium on Parallel and Distributed Computing, 1991, 752{758. 6. J. Hopcroft and R. Karp, An n5=2 algorithm for maximum matching in bipartite graphs, SIAM J. Computing 2 (1973) 225{231. 7. R. Lipton and R. Tarjan, Applications of a planar separator theorem, SIAM Journal on Computing 9(3) (1980) 615{627. 8. S. Micali and V. Vazirani, An O(jV j0:5 jE j) algorithm for nding maximum matchings in general graphs, in Proc. 21st Annual Symposium on Foundations of Computer Science, 1980, 17{27. 9. R.M. Karp, E. Upfal, and A. Wigderson, Constructing a maximum matching is in random nc, Combinatorica 7 (1986) 35{48. 10. K. Mulmuley, U.V. Vazirani, and V.V. Vazirani, Matching is as easy as matrix inversion, Combinatorica (1987) 105{131. 11. A. Israeli and Y. Shiloach, An improved parallel algorithm for maximal matching, Information Processing Letters bibbf 22 (1986) 57{60. 12. P. Kelsen, An optimal parallel algorithm for maximal matching, Information Processing Letters to appear. 13. B. Shieber and S. Moran, Slowing sequential algorithms for obtaining fast distributed and parallel algorithms: Maximum matchings, in Proc. 15th Annual Symposium on Principles of Distributed Computing, 1986, 282{292. 14. A.V. Goldberg, S. Plotkin, and P. Vaidya, Sublinear-time parallel algorithms for matching and related problems. in Proc. 29th Annual Symposium on Foundations of Computer Science, 1988, 174{185. 15. A.V. Goldberg, S.K. Plotkin, D.B. Shmoys and E . Tardos, Interior point methods in parallel computation. in Proc. 30th Annual Symposium on Foundations of Computer Science, 1989, 350{355. 16. G.F. Lev, N. Pippenger, and L.G. Valiant, A fast parallel algorithm for routing in permutation networks, IEEE Transaction on Computers C-30 (1981) 93{100. 17. G.L. Miller and J. Naor, Flow in planar graphs with multiple sources and sinks, in Proc. 30th Annual Symposium on Foundations of Computer Science, 1989, 112{117. 18. T. Fischer, A. V. Goldberg, D. J. Haglin and S. Plotkin, Approximating matchings in parallel, Information Processing Letters 46 (June, 1993) 115{118. 19. T. Spencer, Parallel approximate matching, in Proc. 26th Hawaii International Conference on System Sciences, 1993. 20. E. Cohen, Approximate max ow on small depth networks, in Proc. 33th Annual Symposium on Foundations of Computer Science, 1992, 648{658. 21. P. G. Spirakis, PRAM models and fundamental parallel algorithmic techniques:
8
Part II (randomized algorithms), in Lectures on Parallel Computation, eds. A. Gibbons and P. Spirakis, (Cambridge University Press, 1993), 41{66. 22. R. Motwani, Expanding graphs and the average-case analysis of algorithms for matchings and related problems, in Proc. 21st Annual Symposium on Theory of Computing, 1989, 550{561.
9