UNIVERSITY OF ILLINOIS LIBRARY AT URBANA-CHAMPAIGN CENTRAL CIRCULATION AND BOOKSTACKS The person borrowing this material is re- sponsible for its renewal or return before the Latest Date stamped below. You may be charged a minimum fee of $75.00 for each non-returned or lost item. Theft, mutilation, or defacement of library materials can be causes for student disciplinary action. All materials owned by the University of Illinois Library are the property of the State of Illinois and are protected by Article 16B of Illinois Criminal Law and Procedure. TO RENEW, CALL (217) 333-8400. University of Illinois Library at Urbana-Champaign OEC 1 jo 5g When renewing by phone, write new due date below previous due date. L162 Digitized by the Internet Archive in 2013 http://archive.org/details/npcompletematchi967plai 2_ Watt UIUCDCS-R-79-967 UILU-ENG 79 1713 An NP-Complete Matching Problem by David A. Plaisted April 1979 »n DEPARTMENT OF COMPUTER SCIENCE UNIVERSITY OF ILLINOIS AT URBANA-CHAMPAIGN URBANA, ILLINOIS Corrections to University of Illinois Departmental Report "An NP- Complete Matching Problem" by David A. Plaisted page 1 line 13 "vertex of El" should be "edge of El." page 9 line -2 "q edges" should be "q triples" An NP-Complete Matching Problem by David A. Plaisted 222 Digital Computer Lab Department of Computer Science University of Illinois Urbana, Illinois 61801 This research was partially supported by the National Science Foundation under grant MCS 77-22830. Abstract We show that a restricted form of the perfect matching problem for bipartite graphs is NP-complete. The restriction involves partitions of the vertices of the graph. This problem is still NP-complete if the degrees of the vertices are restricted to be 3 or less. For degrees restricted to 2 or less, a polynomial time algorithm exists. -1- 1. Introduction The general perfect matching problem can be solved in polynomial time [4], but certain related problems are NP-complete [2, 3]. We show that a more restricted version of the perfect matching problem is still NP-complete. Much of this work was done together with Shmuel Zaks. Suppose G = (V, E) is an undirected graph, where V is the set of vertices and E is the set of edges. We represent an edge joining v.| and v^ by the set {v-j, v^} for vertices v, and v~. Suppose G is a bipartite graph. That is, V = V, u \l V, n \l = 0, and every edge joins a vertex in V, with a vertex in \L. We represent such a bipartite graph by G = (V r V 2 , E). The perfect matching problem is to determine if there is a subset El of E such that every vertex of G is incident with exactly one vertex of El. We are interested in the following problem, which we call "perfect matching with node partitions." Given an undirected bipartite graph G = (V, , V~, E) and given partitions P, and P~ of V, and V« s respectively, to determine if there is a subset El of E such that El is a perfect matching for G and such that no distinct edges {v,, v ? } and {w, , w~} of El have the property that v, and w, are in the same block of P, and v ? and w ? are in the same block of P ? . We say that such a matching El is a perfect matching consistent with the node partitions P, and P ? . This problem is a specialization of the 3-dimensional matching problem [3] and of the restricted matching problem treated in [2]. Both of these latter problems are known to be NP-complete -2- A motivation for the perfect matching problem with node partitions is the following: Let V ] be a set of people and let V 2 be a set of offices in various committees. Let E be a set of pairs {v, s v 2 > indicating that person v 1 is eligible for office v 2< We may partition V 1 into families and V 2 into committees. The problem is to assign people to committees so that no two people from the same family are on the same committee. It is easy to see that this is an instance of the perfect matching problem with node partitions. 2. NP-Completeness We now show that this restricted perfect matching problem is NP-complete. Clearly it is in NP. We show that it is NP-hard by reducing from the one-in-three 3-SAT problem, known to be NP-complete [5 ]. The final form of this reduction is mostly due to S. Zaks. The one-in-three 3SAT problem is as follows: Given a set X of variables and a set S of clauses over X such that for all C e S, C has 3 literals, to determine if there is a 1 -truth assignment (a truth assignment making exactly one literal in each clause true). First we reduce the one-in-three 3SAT problem to a related version of the one-in-three 3SAT problem. The difference is that for all variables x in X, at most 3 clauses in S contain either x or x. However, some clauses in S may have only 2 literals. This reduction proceeds as follows: Suppose x or x appears in C, , C ? , . . . , C , for clauses C e S, and x or x appears in no other clauses of S. Suppose m > 3. Introduce new variables yj , y 2 , ..., y m . Let C| ' be C i with x replaced by y. . Let S' be with C i replaced by C^ ' , for 1 < i < m, and with the additional clauses -3- y-\ v y 2 » y 2 v y 3' y 3 v y 4' ■•" y m-l v y m' y m v y l added - Now n is clear that S' has a 1-truth assignment iff S does, since any interpretation satisfying the clauses y^ v y 2 , ^2 v y 3' • * " ' y m v y l must give a11 y i the same truth value. Also, each y. appears in exactly three clauses. Hence by repeating this step, we obtain a set T of clauses which has a 1-truth assignment iff S does, and such that for each variable x, at most 3 clauses contain x or x. We now reduce the restricted one-in-three 3SAT problem to the restricted matching problem. Suppose S is a set of clauses over the variables X. Suppose each clause C in S has 3 or fewer literals, and for each x in X, at most 3 clauses of S contain either x or x. We construct a bipartite graph G = (v^, V 2 , E) and partitions P ] of V, and P„ of V 2 such that G has a matching as desired iff S has a 1-truth assignment. This construction of G from S can be done in polynomial time, as will be clear. In fact, the construction can be done in linear time. Let L be X u {x: x e X}. Thus L is the set of literals of S. We say L e C if L is a literal appearing in clause C. Thus x e {x v y v z} but x t {x v y v z). For literals L in L we define L in the following way: If L is x then L is x; if L is x then L is x. We call L the complement of L. Let S x be {C e S: x e C or x e C} for x e X. The graph G is the "union" of graphs obtained from the clauses and variables in S. We define the union of graphs G 1 = (V, ' , V ? ', E') and G" = (V^', V 2 ", E") to be the graph G' u G" = (V ] ' u V " V 2 ' u V 2 ", E 1 u E") For each variable x in X, we define a graph G(x) in a manner to be described, and for each clause C in S we define a graph G(C) in a manner to be described. The final graph G is then ( U G(x) ) u ( r U c G(C) ) . Also, the XcA Leo -4- partitions P, and ? 2 are defined by P. = ( x y x P i^ x ^ u ^c U S P l^ C ^ and P 2 = ^xeX P 2^ X ^ U ^CeS P 2^ C ^ Where V*)' p -|( C )' p 2 ^' and P 2^ remain to be defined. We define G(C) and G(x) by cases. Suppose x e X and |S | = 3. Let {A, B, C} be the set of three (distinct) clauses in which x or x appears. Then G(x) = (V^x), V 2 (x), E(x)) where V-,(x) = «x, 1), (x, 2), }, V„(x) = {, , , },«x, 1>, }, {, },{(x, 2), (x, C>}, {,},«x, 3>, , }, {, < x, B>},{, }}. Diagram: V^x) V 2 (x) G(x) The ovals illustrate the blocks of the partition. Note that there are only two restricted matchings of this graph. One of them leaves the vertices , , and , , and < x, C> free. (For example, if < x, 1 > matches (X, B> then < x, 2) can't match so < x, 2> matches and so on.) The former matching corresponds to an interpretation making x true and the latter matching corresponds to an interpretation making x false. -5- If IS I = 2 or IS i = 1 , similar constructions for G(x) are used. 1 x 1 'x 1 Suppose |S | = 2 and S = {A, B}. We then have V,(x) = A A ' {, , < x, B>, < x, B>} and P^x) = (V^x)} and P 2 (x) = {{},{(x, B>, < x, B>}}. Also, E(x) = {«x, 1>, (X, A)},«x, 1), , },«x, 2>, }}. Suppose |S | = 1 and S = {A}. We then have V,(x) = {< x, 1 >} and xx i V 2 (x) = {(x, A>, ) and P^x) = (V^x)} and P 2 (x) = (V 2 (x)}. Also, E(x) = {{, , , (C, 2), } and V 2 (C) = «L1, C>, , , , }, «C, 2>}, «C, 3>}} and P 2 (C) = {{, }, «L3, C>, , (LI, C>}, {, }, «C, 1>, (L3, C>}, {, < 11 , C>}, {, }, {}, {(C, 3>, }}. Diagram: v 2 (c) The vertex , and can then match (L, C> for all L e C such that < C, 1 ) does not match < L, C>. We cannot have ( C, 1 > -6- matching < LI , C> and < C, 2> matching < LI , C) because only one of < LI , C) and < LI , C> will be left free, by allowable matchings on G(x) for x = L or x = L. If , this corresponds to LI being true in an interpretation and L2 and L3 being false (as required by one-in-three 3-satisfi ability), and similarly if < C , 1> matches (L2, C) or. The construction for C = LI v L2 or for C = LI is similar. Finally, G = ( U x G(x)) u ( U S G(C)) as stated earlier. We now show that G has a matching consistent with the constraints represented by P, and ? ? iff S has a 1-truth assignment. Assume G has such a matching. Then each G(x) has a matching consisting of |S | edges. Also, this matching is consistent with the node partitions P-,(x) and P 2 (x) of G(x). Each such matching corresponds to a truth value for x as indicated above. Consider the interpretation I of X giving all x e X truth values as specified by these matchings of G(x) , for x e X. Since each G(C) has a matching, at least one literal of C must be true in I. By the con- struction of G(C), if such a matching exists then the other two literals of C must be false in I. Hence I is a 1-truth assignment for S. Conversely, if a 1-truth assignment I for S exists, a matching for G(x) exists corresponding to the truth value of x in I , for x e X. This matching will be consistent with the node partitions P, (x) and P 2 (x) of G(x). Also, matchings for G(C) can be obtained since exactly one literal of C is true in I. These matchings can be combined to obtain a matching for G consistent with the node partitions. This completes the proof. 3. Further restrictions Note that the above graph G has the property that no node has -7- degree larger than three and that no block of P, or P~ has more than three elements. We now indicate how this result can still be obtained if we restrict the blocks of P-. and Pp to have no more than two elements, while maintaining the bound of three on node degrees. The idea is to define G as above except that G(x) is defined differently for x e X. In particular, if |S | = 3, let A, B, and C be the three (distinct) A clauses in which x or x appears. Then G(x) = (V^(x), V 2 (x), E(x)) where V^x) = {x, x} x {1, 2, 3} and V 2 (x) = ({x, x} x {A, B, C}) u {x} x {4, 5, 6}. Here x indicates Cartesian product. Also, E(x) = {{}, {, , < x, B>}, {, }, {, }, {, < x, C>}} u {{, (x, 4>}, {, < x, 5>}, {, }, {, }} and P^x) = {{}, «x, 2>, }, {< x, 3>, < x, 3>}} and P 2 (x) = {{}, {, }, «x, C>, }, «x, 4>}, «x, 5>}, {}} Diagram: G(x) ■8- The idea is that if matches must match . Therefore < x, 2> must match < x, B> and so on. If < x, 1 > matches < x, 6> then < £, 3> must match so must match and so on. In the former case, the nodes , and of V ? (x) are free, and in the latter case , (x, B>, and E), with |V ] | = |V 2 | and given partitions P ] and ? 2 of V ] and V 2 , respectively, we construct a problem closely related to 3-dimensional matching. Let W be V, , let Y be V 2 , and let Z be P ] x ? r Let M be {< V] , v 2 , < p ] , p 2 >> : V] e V,, v 2 e V 2 , {v r v 2 ) e E, and p ] E P ] , p £ E P 2 and V] e p ] , v 2 e p 2 ). That is, p 1 and p 2 are the blocks of P 1 and P 2 containing v, and v ? , respectively. Now, a matching M' of M corresponds to a matching of G in which no two distinct edges join vertices in the same block of P, with vertices in the same block of ? r Hence a matching M 1 exists with l M ' I = l V ]l = ! V 2l iff G nas a perfect matching consistent with the node partitions. However, we do not have | M " J = |Z| since it may be that |V-, | f |Z| and |V 2 | + |Z|. Despite this, it is easy to use this modified form of 3-dimensional matching to show that the general 3-dimensional matching problem is NP-complete. ■11 References [1] Cook, S. A. The complexity of theorem proving procedures, Proc . 3rd Annual ACM Symposium on Theory of Computing (1971) 151-158. [2] Itai, A. Rodeh, M. and Tanimoto, S. L. Some matching problems for bipartite graphs, J. ACM 25(1978) 517-525. [3] Karp, R. M. Reducibility among combinatorial problems, in Miller, R. E. and Thatcher, J. W. , Complexity of Computer Computations (Plenum Press, New York, 1972) 85-104. [4] Lawler, E. Combinatorial Optimization (Holt, Rinehart, and Winston, New York, 1976^ [5] Schaefer, T. J. The complexity of satisfiability problems, Proc . 10th Annual ACM Symposium on Theory of Computing (1978) 216-226. BIBLIOGRAPHIC DATA SHEET 1. Report No. UIUCDCS-R-79-967 4 T • > ->nj Subt it le An NP-Complete Matching Problem 3. Recipient's Accession No. 5. Report Date April 1979 7. Author(s ) David A. Plaisted 8. Performing Organization Rept. No. rtorming Organization Name and Address Dept. of Computer Science 222 Digital Computer Lab University of Illinois Urbana, Illinois 61801 10. Project/Task/Worlc Unit No. 11. Contract /Grant No. NSF MCS 77-22830 nsoring Organization Name and Address National Science Foundation Washington, D.C. 13. Type of Report & Period Covered 14. '5. .pplementary Notes :racts We show that a restricted form of the perfect matching problem for bipartite graphs is NP-complete. The restriction involves partitions of the vertices of the graph. This problem is still NP-complete if the degrees of the vertices are restricted to be 3 or less. For degrees restricted to 2 or less, a polynomial time algorithm exists. v ttords and Document Analysis. 17a. Descriptors perfect matching, 3-dimensional matching, graph algorithms, NP-complete. 17k Identif iers/Opcn-Ended Terms '7c iA ri Field/Group m Availability Statement 19. Security Class (This Report) unclassified 20. Security Class (This Page UNCLASSIFIED 21. No. of Pages 22. Price • NT IS- 35 ( 1( USCOMM-DC 40329-P71 1979 AUb 1 b N