on generating all maximal independent set

Upload: simon-piga-diaz

Post on 03-Jun-2018

216 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/12/2019 On Generating All Maximal Independent Set

    1/5

    Information Processing Letters 27 (1988) 119-123North-Holland

    25 March 1988

    ON GENER TING LL M XIM L INDEPENDENT SETS

    David S. JOHNSON and Mihalis YANNAKAKISAT 7 Bell Loboratories, Murr ay Hi ll, NJ 07974, U.S.A.

    Christos H. PAPADIMITRIOUDepartmeni of Computer Science, Stanford Uni versity, Stanford, CA 94305, U.S.A.

    Communicated by A.V. AboReceived 15 September 1986Revised 24 August 1987

    We present an algorithm that generates all maximal independent sets of a graph in lexicographic order, with onlypolynomial delay between the output of two successive independent sets. We also show that there is no polynomial-delayalgorithm for generating all maximal independent sets in reverse lexicographic order, unless P = NP.

    Keywords: Independent set, enumeration, NP-complete, lexicographic order, polynomial time

    Generating all configurations that satisfy a givenspecification (e.g., all permutations of n objectsthat do not fix any object) is a well-studied prob-lem in combinatorics [6]. Graph theory suggestsmany interesting problems of this type (see, e.g.,[7]). Among them, generating all maximal inde-pendent sets of a given graph is one that hasattracted considerable attention in the past [4,5,8].(A maximal independent set of a graph G = (V, E)is a subset V G V of the vertices such that no twovertices in V are joined by an edge in E, andsuch that each vertex in V- V is joined by anedge to some vertex in V.)

    One has to be careful in defining notions ofperformance or complexity of such algorithms.In most interesting problems of this sort, thenumber of configurations to be generated ispotentially exponential in the size of the input(say, a graph), and our notions of performancemust take this into account. Even so, there aremany different notions of what it means to solve aproblem of generating configurations in poly-nomial time. We examine several possibilities be-low:

    (a) Polynomial total time. The least that wecould ask is that the time required to output allconfigurations be bounded by a polynomial in n(the size of the input) and C (the number ofconfigurations). Several algorithms satisfying thiscriterion exist for the problem at hand. The al-gorithm of Paul1 and Unger in 151, for example,runs for O(nC) time with no output, and thengenerates all C maximal independent sets in rapidsuccession. Note that even this weakest notion ofpolynomial time is not always possible: If theconfigurations to be generated have some inherentcomplexity (e.g., the maximum independent setsof a graph, or the satisfying truth assignments of aBoolean formula), then, of course, no polynomialtotal time algorithm exists for generating all ofthem unless P = NP [4].

    (b) I ncremental polynomial time. An algorithmmeeting this criterion can, given an input andseveral configurations (say, a graph and a collec-tion of maximal independent sets), find anotherconfiguration, or determine that none exists, intime polynomial in the combined sizes of theinput and the given configurations. It is not hard

    0020-0190/88/%3.50 0 1988, Elsevier Science Publishers B.V. (North-Holland) 119

  • 8/12/2019 On Generating All Maximal Independent Set

    2/5

    Volume 27, Number 3 INF ORMATION PROCESSING LETTE RS 25 March 1988

    to see that if such an algorithm exists, then the setof all configurations can be generated in poly-nomial rota1 time (assuming that each configura-tion is of polynomial size). Thus (b) implies (a). Anotion much stronger than either (a) or (b) is thefollowing.

    (c) Polynomial delay. An algorithm meeting thiscriterion generates the configurations, one afterthe other in some order, in such a way that thedelay until the first is output, and thereafter thedelay between any two consecutive configurations,is bounded by a polynomial in the input size. Formaximal independent sets there is a clever al-gorithm doing just this, due to Tsukiyama et al.[8]. This algorithm, a variant of the one in [5],works by doing a depth-first search in a dynamicbinary tree with the maximal independent sets asleaves, whose forward and backward edges areconstructed as we go. The tree has depth n, thenumber of vertices. Each vertex at level j is amaximal independent subset J of the first jvertices of the graph. As for its children, there aretwo cases. Let F(Y) denote the set of vertices thatare adjacent to Y. If J n r j + 1) = P, (i.e., if Jdoes not contain any vertices adjacent to vertexj + l), then J s only child is J U { j 1). If thereare some vertices in the neighborhood F( j + 1) ofj + 1 in J, then J potentially has two children.The first, or leftchild, is a copy of itself, and isalways present. The potential rightchild is J =J-F(j+l)U{j+l} if J is a maximal in-dependent subset of the first j + 1 vertices. Notethat, in this case, J is potentially the child ofseveral sets on the same level in the tree, namely,of any maximal independent subset of the first jvertices that contains J - r( j + 1). Of all thesesets, J is the child of the lexicographically smal-lest. This completes the description of the tree ofindependent sets used in the algorithm of [S].Notice that the functions leftchild, rightchild, andparent, as defined above for this tree, can all becomputed in polynomial time. (The lexicographi-tally first maximal independent subset of{I, 2,..., j} that contains J - r( j + 1) is easy tocompute.) It follows that the tree can be traversedin a depth-first manner with polynomial delay perstep of the traversal, and thus the leaves can beoutput with only a polynomial delay.120

    (d) Specified order. A more complex case is theone in which we wish the configurations output insome specified order, such as lexicographic. Obvi-ously, this matters only in the case of polynomialdelay; if we are interested only in polynomial totaltime, then we can generate all configurations, sortthem, and then output them in the desired order.An interesting example of generating configura-tions in a specified order with polynomial delay isgiven in [2], which describes such an algorithm forgenerating all tuples in the Cartesian product of kfinite, weighted sets in order of increasing totalweight of the k-tuples. Until now, no polynomial-delay algorithm had been known for generating allmaximal independent sets of a graph in lexico-graphic (or any other natural) order.(e) Polynomial space. Some of the algorithms inthe above categories, like the algorithm of [5] andthat of [2] build exponentially large data struc-tures. Ideally, one would like to avoid this. Forexample, the algorithm in [8] needs only linearspace, since it generates the tree as it goes, andneed save only the current node of the tree.

    In this paper we examine whether it is possibleto generate all maximal independent sets of agiven graph in lexicographic order and polynomialdelay. (We say a subset S of an ordered set comeslexicographically before T if the first element atwhich they disagree is in S.) It is not at allobvious that such an algorithm exists, especially inthe light of the following result.1 Theorem. Given a graph G and a maximalindependent set S, it is coNP-complete to tell whetherS is the lexicographi cally last maximal independentset of G.

    Proof The problem is in coNP since if S is notthe lexicographically last, a short proof of this factcan be obtained by exhibiting a maximal indepen-dent set that follows S. To show completeness, wesketch a polynomial transformation from SATISFI-ABILITY. Given an instance of satisfiability withvariables xi.. . . , x, and clauses C,, . . . , C,,,, weshall construct a graph G (with ordered vertices)and a maximal independent set S such that thereis a maximal independent set T lexicographicallyafter S if and only if there is a truth assignment

  • 8/12/2019 On Generating All Maximal Independent Set

    3/5

    Volume 27. Number 3 INFORMATION PROCESSING LETTERS 25 March 1988

    that satisfies all the clauses. Our graph has avertex for each clause, a vertex for each literal xior 7x;, and a special vertex a. The order of thevertices is as follows: First the clauses, then a,then the literals (in any order). Vertex a is adja-cent to all other vertices in G, and there is an edgeconnecting any two contradicting literals xi and7xi. Finally, we make each clause adjacent to allliterals it contains. These are all edges of G. Let usnow define S = { a } (clearly a maximal indepen-dent set).

    Is there a maximal independent set T lexico-graphically after S? If there is, it must be a subsetof the literals, and, since contradicting literals areadjacent, a truth assignment. But is it maximal?For such an independent set to be maximal, it. must be the case that, for each clause, there is atleast one literal in T which is adjacent to it. Inother words, T is a satisfying truth assignment.Therefore, S is the lexicographically last maximalindependent set of G if and only if the givenBoolean formula is unsatisfiable. 0

    Notice that it is easy to generate the lexico-graphically first maximal independent subset of agraph: Scan the vertices in the specified order, andnever leave out a vertex unless it is adjacent to avertex already in the set. This can be done inO(n + m) time, where n and M are the numbersof vertices and edges, respectively, in G. Similarly,we can find the lexicographically first independentset that is maximal and contains a given indepen-dent set of vertices. (Recall that this fact was usedin the proof sketched above that the algorithm of[8] runs with polynomial delay.)

    Theorem 1 has interesting consequences, as faras generating algorithms are concerned.2. Corollary. It is NP-hard, given a graph G and amaximal independent set S, to generate the lexico-graphically next maximal independent set.3. Corollary. Unless P = NP, there is no algorithmthat generates the maximal independent sets of agraph in inverse lexicographic order with polynomialdelay.

    Perhaps surprisingly, we now present an al-gorithm which generates all maximal independent

    subsets of a graph in lexicographic order, withpolynomial delay. Intuitively, our algorithm getsaround the negative implications of Corollary 2 byinvesting work for future outputs while workingon the current one. It does use potentially ex-ponential space, in the form of a priority queue Q,which stores a potentially exponential number ofmaximal independent sets. These sets are insertedinto Q by the algorithm at a cost of O(n log C)per insertion, where n is the number of verticesand C is the total number of maximal indepen-dent sets. (If the item to be inserted is alreadypresent in the queue, the queue is not altered,although the same time penalty is incurred.) Theother operation we can perform on the queue is tofind and delete the lexicographically first set itcontains; this can be accomplished within thesame 0( n log C) time bound. Such a priority queuecan be implemented using any of the standardbalanced tree schemes (see, e.g., [l]). Note that thecomparisons to determine lexicographic prioritymay take time proportional to n; this is why thetime is not simply the depth of the tree, i.e.,O(log C). The algorithm is the following:

    beginlet S be the first maximal independent set ofG;insert S to Q;while Q not empty do

    beginS := min of Q;output s;for each vertex j of G adjacent to a vertexi cj of S dobegin

    let s =sn {l,..., j};if Sj-r(j)U { j} is a maximal inde-pendent set of the first j vertices then

    beginlet T be the lexicographically first ma-

    ximal independent set of GwhichcontainsS,-T(j)U{j};

    insert T into Qend

    endend

    end121

  • 8/12/2019 On Generating All Maximal Independent Set

    4/5

    Volume 27 Number 3 INFORMATION PROCESSING LETTERS 25 March 1988

    4. Theorem. The algorithm above outputs ail maxi-mal independent sets of a graph with n vertices andm edges in lexicographic order, and with O(n(m +n log C)) = 0( n3) delay.Proof Notice that the set T inserted in Q at thetime S is output is lexicographically after S. Thus,the queue always gets sets that are lexicographi-tally after the one being output, and therefore thesequence output is indeed lexicographically in-creasing. We shall show by induction that, if S isthe lexicographically first maximal independentset not yet output, then it is already in the queue(and thus it will indeed be output next). Thiscertainly holds when S = S *.

    In the generic case, let j be the largest numbersuch that S, is not a maximal independent set ofthe graph restricted to the first j vertices. (If nosuch j exists, then it is easy to see that S = S * .)Note that we must have j < n since S is a maxi-mal independent set for the whole graph; notealso that, by the maximality of j, we must havej + 1 E S. Enlarge S, to a maximal independentset Sj u K of the first j vertices; since Sj is notmaximal, K is nonempty. Moreover, j + 1 mustbe adjacent to all vertices in set K, again becauseof the maximality of j.We conclude that there is a maximal indepen-dent set S which contains S, U K, but not j + 1.However, S comes lexicographically before S(since it first disagrees with S on the vertices ofK). By induction, S has already been output bythe algorithm. When it was output, vertex j + 1was found to be adjacent to a vertex i -c + 1 inS. Since si+, -r(j+l)U{j+l}=Sj+i is amaximal independent subset of the first j + 1vertices, the first maximal independent set T of Gthat contains Sj+, was inserted into the queue. Tagrees with S on the first j + 1 vertices, becauseSj+, is maximal on that set of vertices. SupposeS T and let k be the first vertex in which theydiffer; k > j + 1. We must have k E T and k e Ssince T was the lexicographically first maximalindependent set containing S,+i. But this wouldimply that S, is not maximal, contradicting themaximality of j. It follows that S = T, and there-fore S is indeed in Q, as claimed. This concludesthe proof of correctness.122

    For the time bound, notice that the generic stepof the algorithm consist of an extraction of thelexicographically first maximal independent setfrom Q (taking 0( n log C) time), followed by atmost n calculations of a maximal independent setcontaining a given one (taking O(n + m) time perset), and for each of these an attempt to insert theset found into the queue (taking time O(n log C)per set). The total delay is thus 0( n(log C + n + m+nlogC))=O(n3). Cl

    Notice that our algorithm uses potentially ex-ponential space (although at most O(nC)). If weare willing to tolerate potentially exponential de-lay, we can generate all maximal independent setsof a graph in lexicographic order using only poly-nomial space: simply generate all subsets in lexi-cographic order, outputting only those that areindependent and maximal. A remaining openquestion is whether there is a way to avoid thisapparent tradeoff.

    Another important open question is whetherthere is an algorithm for generating in polynomialtotal time the maximal independent sets of ahypergraph, not necessarily in lexicographic order.A hypergraph is a set of vertices together with aset of subsets of the vertices, called hyperedges. Aset of vertices of a hypergraph is independent if itdoes not contain a hyperedge. (Note that thisreduces to our standard notion of an independentset in a graph if we specialize to the case when allhyperedges contain precisely two elements.)

    This problem has an unexpected application indatabases. Consider a set of n distributed sites. Avoting pattern in a distributed database concur-rency control scheme is a hypergraph with these ncites as vertices, in which the following two prop-erties hold: (a) all pairs of hyperedges intersect,and (b) no vertex can be deleted from any hyper-edge without violating (a). (This is a restrictedversion of the coterie of [3].) Intuitively, a votingpattern is a collection of minimal sets of sites,such that the sites in each of these sets can safelyagree on a decision (say, an update), without therisk that another set has reached a contradictorydecision. The most usual voting pattern containsall sets of [ (n + 1)1 sites. We say a voting patternis maximal if it cannot be extended to a voting

  • 8/12/2019 On Generating All Maximal Independent Set

    5/5

    Volume 27. Number 3 INFORMATION PROCESSING LETTERS 25 March 1988

    pattern with one more hyperedge. (The maximalvoting patterns coincide with the nondominatedcoteries of [3].) Testing whether a voting patternis maximal can be shown to be equivalent todeciding whether a proposed list of maximal inde-pendent sets of a given hypergraph is complete.

    Unfortunately, no algorithm for generating allmaximal independent sets of a hypergraph inpolynomial total time is known. In particular, theapproach of [5,8] will not work. That approachconstructs all maximal independent sets of thesubgraph induced by (1, 2.. . . , j}, and then de-rives from them the maximal independent sets ofthe subgraph induced by { 1, 2,. . . , j l}. Withboth graphs and hypergraphs, we know that everymaximal independent set Z of vertices { 1,. . . , jl} is contained in a set J U { j + l} for somemaximal independent set .Z of (1, 2,. . . , j}. Thequestion of determining which such Z are con-tained in J u { j + l} for a given J is easy forgraphs; the only candidates are J and J - r( j +1) U { j + l}. For hypergraphs, however, we arenot so fortunate. The set of candidates is muchlarger, and, indeed, the question of whether anysuch Z exists is NP-complete (an exercise we leaveto the reader).

    References

    111

    121

    I31141

    161

    [71

    PI

    A.V. Aho. J.E. Hopcroft and J.D. Ullman. The Design andAnalysis of Computer Algorithms (Addison-Wesley, Read-ing, MA, 1974).A.V. Aho, T. Szymanski and M. Yannakakis, Sorting theCartesian product. Proc. Conk on Information Sciences andSwtems (Princeton University, Princeton, NJ, 1980)557-558.H. Garcia-Molina and D. Barbara, How to assign votes ina distributed system, J. ACM 32 (1985) 841-860.E.L. Lawler. J.K. Lenstra and A.H.G. Rinnooy Kan, Gen-erating all maximal independent sets: FP-hardness andpolynomial-time algorithms, SIAM J. Comput. 9 (1980)558-565.M.C. Paul1 and S.H. Unger, Minimizing the number ofstates in incompletely specified sequential switching func-tions, IRE Trans. Electr. Comput. EC-8 (1959) 356-367.R.C. Read, Every one a winner, or how to avoid isomor-phism when cataloguing combinatorial configurations, Ann.Discrete Math. 2 (1978) 107-120.R.C. Read and R.E. Tatjan, Bounds on backtrack al-gorithms for listing cycles, paths, and spanning trees, Net-works 5 (1975) 237-252.S. Tsukiyama. M. Ide, H. Ariyoshi and I. Shirakawa, A newalgorithm for generating all maximal independent sets,SIAM J. Comput. 6 (1977) 505-517.

    123