Graph 2-isomorphism is NP-complete

Graph 2-isomorphism is NP-complete

Volume 9. number 2 INFORMATION PR6CESSING LETTERS 17 August 1979 GRAPH 2-ISOMORPHISM IS NP-COMPLETE * t . Frances YAO Computer Science Department...

532KB Sizes 4 Downloads 96 Views

Volume 9. number 2

INFORMATION PR6CESSING LETTERS

17 August 1979

GRAPH 2-ISOMORPHISM IS NP-COMPLETE * t .

Frances YAO

Computer Science Department, Stanford University, Stanford, CA 94305, U.S.A. Received 15 January 1979; revised version received 24 May 1979

Complexity, graph, graph isomorphism, NP-complete

Given two graphs ’ G = (V, E) and G’(V’, E’) with the same number of edges, by a k-isomorphismofG and G’ we mean a partition of E = El U Ez U **U i& :::ld a partition of E’ = E; U E; U - U EL such that as graphs, Ei and Ef are isomorphic for 1 G i < k. Let U(G, G’) be the minimum value of k for which a k-isomorphism of G and G’ exists. (See [ 11 for a study of k-isomorphism of graphs.) in general, the determination of whether LJ(G,C’) < k for two graphs G, G’, and positive integer k is an NP-complete problem. It clearly belongs to NP; and if we take G’ to be a star graph (with the same number of edges as G), then LJ(G,G’) is simply the minimum size of a vertex cover for G, a wellknown NP-complete problem [4]. The question “Is U(G, G’) = I?‘- is the familiar graph isomcrphism problem, which is not known either to be NP-complete or soIvab!e in polynomial time [2,4]. In this note we show-that graph-Xsomorphism (GX), i.e., to decide whether LJ(G,G’) < 2, is an NP-complete problem. We will use a tra--‘ llaldrrnation from the following problem, which is known to be NP-complete [2] :

i.e., a subfamily 3’ C _ 3 such that every element of X occurs in exactly one member of 3’?

l

Exact cover by 3-sets (X3C) Instance: Set X = { 1, 2, .... n} and a family

J = {Ai} of 3-element subsets of X. Question: Does 3 contain an exact cover for X,

Theorem 1. X3C is polynomially transformable to G2I. Therefore, the graph 2-isomorphism problem is NP-complete. Proof. Given an instance of X3C, we may assume without loss of generality that n = 3m 2 9,]3i= m t k >, m, and X Z Ugik Ai. We shall construct a pair of graphs G and H corresponding to (X, J), as shown in Fig. 1. Graph G contains a connected component TSi corresponding to each Ai in J. If Ai = [p, q, r), then TSi is a triangle, with, additionally, three stars of size p + 1, q + 1 and r + 1 attached to the vertices of the triangle. We will denote lJ/$ik TSi by TS. In addition to TS, graph G contains a connected component M, which is a complete graph on n vertices with m disjoint triangles removed. Graph H is the disjoint UIlion of four subgraphs KS, N, T, and S. In KS, we have a complete graph on n vertices {VI, v2, .... v,), together with an i-star attached to each vi. The complete graph of KS will be referred tc as K, henceforth. Subgraph N consists of n disjoint edges, and T consists of k disjoint triangles. Finally, S consists of 3k disjoint stars, one of size p + 1 for each p that occurs in the multiset /m+k

\

\i=t

/

JI U Ail-X. * This research was supported in part I-!; National Science Foundation grant MCS 77-05 3 13. * We foilow [ 31 for the terminology on graphs. 68

Clearly, G and in polynomial ‘tim

ic,

INFORMATION PROCESSINGLETTERS

Volume 9, number 2

17 August I979

Step I: Suppose Ai = {p, q, r), where i G i < m. In the corresponding TSi, we take a subgraph consisting of the triangle together with stars of size p, q, r, and map it into the triangle in KS incident at {vp, vs, v,) with the matching stars. At the same time map the triangles of TSj, for m + 1 < j < m t k, onto the k triangles of T. Step 2: The subgraph that is left in G consists of n = 3m isolated edges from !.& TSi, which are

U(G, H) is at least 2. We now show that U(G, H) < 2 if and only if 3 contains an exact cover for X. Lemma 1.. U(G, H) < 2 if J contains an exact cover

for X. Proof. Without loss of generality, assume that

(Al, A25 ...qA,) forms an exact cover for X. We decompose G and H in two steps as follows:

G

p+l

-5

r+l

/

42

1

9+1

. .

e

e

e

e

J

--

n

TA &AY!I.!..

TS m+Q

l.’ e

a

*

.

.

.

w

\

’ :

V

i

35?

l

.

.

. .

(dotted lines are the missing edges) Fig. 1. The graphs G and IQ.

69

Volume 9,

number 2

INFORMATION PROCESSING LETTERS

isomorphic to N; 3k stars from whk+l TSi, iscmorphic to S; and subgraph M, which is isomorphic to the remainder of KS. We mention in passing that actually U(G, H) < 3 for the graphs (G, H) constructed from any (X, 3). For we can first map all m + k triangles of TS into Kn and T; next map the 3(rn + k) stars of TS into KS and S; what is left then in both graphs is isomorphic to M U N. The rest of this note is devoted to proving the converse of Lemma 1. Lemma 2. U(G, g) < 2 only if 3 contains an exact cover for X. We first introduce some notations. Under the assumption U(G, H) < 2, let E(G) = G(l) U Gt2), E(H) = H(l) U Ht2) be fixed partitions of the edge sets, with i:;Gmorphism mappings $r : G(l) + H(l) and e2 : Gt2) + Ht2). For any subgraph F of G (or H), we use F(‘) to denote F n G@ (or F n H(‘), respectively); also, let (F(% be the isomorphic image of F(‘) under Qti) (or (@)-‘, respectively). For a graph F = (V, Ej, we use e(F) to denote lE1.Define vertexcover(F) to be the minimum size ol: a subset V’ C V such that for every edge (u, vj E’E, at least one of u and v belongs to V’. The following facts will be useful. Fact 1. If F C K, and vertexcover K, - F contains an (n - a)-clique.

< a, then

Fact 2. Let F be a connected component in G. Any that is incident with a vertex of (F(l)) but ined in (F(l)) must belong to Ht2). hoof of Lemma 2. First, we show that any 2-isomorphism of G and H must decompose KS into M and a collection of triangles with stars. Indeed, since KS has more edges than M, we must have either (KS(‘)) n TS # 0 or (KSt2$ n TS # 8. Assume it is the former. Proposition 1. Under the assumption that U(G, H) = 2 and (KS(‘)) 17TS # 8, we must have (KS(~))= (Kf)) = M. roof. Let TSi be SUCK that (KS(“)) n ‘fSi # 0. Consrder the image of TS[r) in et (vi,, Viz,.*+) Vi ) be the Verticesof K, that are contained in (TSf$ 70

17 August 1979

Fact 3. (i) (TS$‘)) n K, contains at most h edges, (iij (TS(‘j) n K, contains n - 1. Then since K, has no edges disjoint from {vi,, viz, .... vi,), we must have Kg) C (TSf’)). This implies that vertexcover(Ki’)) < verte&wer(TSi) = 3. By Fact 1, K%) must contain a (n - 3)clique. Since G does not contain a (n - 3). clique when n > 9, this is impossible. (b) Next suppose h = 1. Then by Fact 2, an (n - I)star R must be contained in Kk). Since the maximum degree of a vertex in M is n - 3, we must have R C (TSj’$ for some j. But then (TSfZ)) is incident with n vertices of Kn, and the same argument as given in (a), with Step 1 and Step 2 interchanged. shows that this is impossible. This proves Fact 4. Fact 5. (KSt2)) = (Kkr) C M. Proof,Given2)n K,. This is possible only if the latter contains e(M) = Cn) - n edges and the former contains n edges, &cause of Fact 3(ii). But then, (M(r)) n K, = fl by Fact 3(iii), which implies that e((Mf2)) n K,,) = (i)- n, and hence (Kg)> = M. This proves Proposition 1. We can now complete the proof of Lemma 2. It follows from Proposition 1 that KSt2) is the isomorphic image of M, while KS(‘) consists of m disjoint triangles, each attached with three stars. Without loss of generality, write

Volume 9, number 2

lNFORMATION PROCESSING LETTERS

where for 1 f i < m, TSf’) is a subgraph of TSi and moreover, they are triangles with stars of size {p’, q’, r’} and {p + 1, q + 1, r + 1) respectively, with p’ < p, q’ G q and r’ < r. If 3 does not contain an exact cover for X, then we will not have p’ = p, q’ = q, r’ = r in TSf’) and TSi for all 1 < i G m. Hence TSF) U TS9) U a*U TS(,) will contain fewer than n isolated edges. This makes it necessary, because of the subgraph N in H, for TSm+l U TSm+Z U **U TSm+k to yield 6 > 1 isolated edges in either Step 1 or 2. Assume without loss of generality that TS,+ 1 contributes an isolated edge (u, v) in Step 1. We examine two cases. C&seI.- Suppose (u, v) is in the triangle of TS,+r . Then TSf& contains a path of length 4, which does not exist in N U T U S of H (Fig. 2(a), 2(b)). &se 2: Suppot;t (u, \ ) is in one of the stars of TS,+r- Then in TS&, u is a vertex of degree 33, and hence must be mapped by e2 into a star of S. This implies that TSg& contains a path of length >3, which again does not exist in N U T U S (Fig. 2(c), 2(d))* Thus we can have U(G, H) = 2 only if 3 contains an exact cover for X, and this completes the proof of Lemma 2 and Theorem 1.

17 August 1979

l

T

l

R6

M

Fig. 3. An example with U(G’, H’) = 2.

We wish to point out that in our construction, it is necessary to employ a different representation for elements of X in TS than in KS (such as using (p + 1) stars versus p-stars for p E X). The fohowitlg example shows that, for instance, if just p-stars were used in both G’ and H’, then one could have U(G’, H’) = 2 even though 3 does not contain an exact cover for X. Example. Let X = { 1,2, .... 6) and J = {AI = { 1,2,5), A2 = {4,5,6), As = (2,3,4)). (See Fig. 3. e use P to denote a p-star.) One calI first map two

Fig. 2.

71

Volume 9, number 2

INFORMATION PROCESSING LETTERS

References [ 1] F. Chung, P. Erdos, R. Graham, S. Ulam and F. Yao, Minimal decompositions of two graphs into pairwise isomorphic subgraphs, Proc. 10th Southeastern Conference on Combinatorics, Graph Theory, and Computing (1979). [2] 5% Garey and D. Johnson, Computers and Intractability

72

17 August 1979

(Freeman, San Francisco, CA, 1979). [ 31 F. Harary, Graph Theory (Addison-Wesley, Reading, MA, 1969). [4) R. Karp, Reducibility among combinatorial problems, in: R. Miller and J. Thatcher, Eds,, Complexity of Cornputer Computations (Plenum Press, New York, 1972) 85-104.