A New Approach to Efficient Enumeration by Push-out Amortization
aa r X i v : . [ c s . D S ] J u l A New Approach to Efficient Enumeration byPush-out Amortization
Takeaki Uno [email protected] , National Institute of Informatics, 2-1-2, Hitotsubashi, Chiyoda-ku,Tokyo 101-8430, Japan
Abstract.
Enumeration algorithms have been one of recent hot topicsin theoretical computer science. Different from other problems, enumer-ation has many interesting aspects, such as the computation time can beshorter than the total output size, by sophisticated ordering of outputsolutions. One more example is that the recursion of the enumerationalgorithm is often structured well, thus we can have good amortizedanalysis, and interesting algorithms for reducing the amortized complex-ity. However, there is a lack of deep studies from these points of views;there are only few results on the fundamentals of enumeration, suchas a basic design of an algorithm that is applicable to many problems.In this paper, we address new approaches on the complexity analysis,and propose a new way of amortized analysis
Push Out Amortization for enumeration algorithms, where the computation time of an iterationis amortized by using all its descendant iterations. We clarify sufficientconditions on the enumeration algorithm so that the amortized analysisworks. By the amortization, we show that many elimination orderings,matchings in a graph, connected vertex induced subgraphs in a graph,and spanning trees can be enumerated in O (1) time for each solution bysimple algorithms with simple proofs. Suppose that there is a simple algorithm to solve a problem, and we have twoimprovements on the time complexity; (a) is by developing a new algorithmwith a small complexity, and (b) proves that its complexity is actually small bycomplexity analysis. Both types of improvements are important in theoreticalcomputer science, but these days almost all results are on the type of (a). Devel-oping simple algorithms in (a) is non-trivial, thus many recent algorithms andtheir complexity analysis are difficult to understand. Moreover, these types ofalgorithms often require some structures in the input, hence the problem formu-lations tend to be distant from the real world. On contrary, (b) type has a greatadvantage on these points. Even though the analysis is complicated, we can hidethe difficulty by producing general statements applicable to many problems. Atleast, we do not have to implement the complicated proofs in a program. Ac-cording to this motivation, we study on complexity analysis in this paper, thatis amortized analysis for enumeration algorithms.Amortized analysis is a paradigm of complexity analysis. In the paradigm, wecharge the cost of iterations with long computation time to those with shorterime, to make the upper bound of computation time of an iteration shorter.Compared to usual complexity analysis considering the worst case, the amortizedanalysis is often more powerful, for example dynamic tree, union find, and someenumeration algorithms[13,7]. In the case of dynamic tree, the cost of changingthe shape of the tree is charged to the preceding changes with smaller costs, andattains O (log n ) average time complexity for each change where n is the size ofthe tree. The time complexity is not attained by usual worst case analysis, and itseems to be hard to obtain algorithms with the same complexity by the analysis.This is similar to the union find algorithm, and the resulted time complexity is O ( nα ( n )) while straightforward algorithms take O ( n ) time. The concept of“charging the cost” made a paradigm shift on the design of algorithms. Someenumeration algorithms are designed so that the time complexity of an iterationis linear in the number of subproblems, to make the average computation timeper child will be short[8,12].Enumeration is now rapidly increasing its presence in theoretical computerscience. One of the biggest reasons comes from its importance in applicationareas. An example is the pattern mining problems in data mining. The problemis to find all the patterns belonging to a class of structures, such as subsets andtrees, such that the patterns satisfy some constraints in the given database, suchas appearing at least k times. One more motivation is that there have not beenmany studies including simple problems, thus there is a great possibility. Onthe other hand, enumeration has several interesting aspects which we can notobserve in other problems. For example, by dealing only with the difference be-tween output solutions, we can often attain the computation time shorter thanits output size, by outputting the solutions by the differences. Another exampleis its well-structured recursion. We can frequently have several structural resultson enumeration, and it gives interesting algorithms and mathematical proper-ties, while it is hard to characterize when a brunch and bound algorithm cutsoff subproblems. Structured recursion often gives a good amortization. Thus,there is a great interests on investigating amortized analysis on enumerationalgorithms.According to this motivation and interests, this paper addresses amortizedanalysis of enumeration algorithms. One of our goals on this topic is to fillthe gap between theory and practice. In practice, enumeration algorithms areoften quite efficient and than the theoretical upper bound on the computationtime. Filling the gap gives understandings for both the theoretical and practicalproperties on the data and algorithms; the properties of the data acceleratingthe algorithms, and the the mechanism of the algorithms that enable us to attainsmaller bounds.We have observed that the recursive structures of enumeration algorithmssatisfies a property which we call bottom-expanded . Iterations of enumerationalgorithms generate several recursive calls. Thus, the number of iterations ex-ponentially increases in deeper levels of the recursion. On the other hand, it-erations on deeper levels often have relatively small inputs compared to upperlevels. Thus, we can expect that iterations near by the root of the recursion areew and spend a long time, and iterations near by the bottom of the recursionsare many and spend very short time. In practice, we can frequently observe this,especially in many kinds of pattern mining algorithms. This also implies that theamortized computation time per iteration, or even per solution, is short. Thismechanism is what we call bottom-expanded. We can see this mechanism notonly in practice but also classic enumeration algorithms.This mechanism motivated us to develop a good amortized analysis. How-ever, amortization is not easy in general, since it is hard to globally estimatethe number of iterations and computation time. Thus, in many existing studies,the computation time is amortized between a parent and its children, and some-times its grandchildren[2,3,4,5,8,12]. These local structures are easier to analyzethan the global structures. Extensions of this idea to more global structures arenon-trivial. For example, if we want to amortize between iterations in differentsubtrees of the recursion, we have to understand the relation and the correspon-dence between all iterations in the different subtrees. This is often a difficulttask.In this paper, we propose a new way of carrying out amortized analysis ofthe time complexity of enumeration algorithms, and propose new algorithms forenumeration of matchings, elimination orderings, and connected vertex inducedsubgraphs. We also show that the amortized analysis can prove the existingcomplexity results in very simple ways, for the enumerations of spanning trees,perfect elimination orderings, and perfect sequences, while the existing algo-rithms often need sophisticated algorithms or data structures. We can also seethat the condition in the analysis is often satisfied in practice, thus this amor-tized analysis explains why the enumeration algorithms are efficient in practice.These satisfy out basic motivations for this kind of studies.Our amortization of an iteration is basically done with all its descendants.For each iteration, we push out its computation time to its children so thatthe assigned time is proportional to their computation time. By applying thispush-out from the root of the recursion to deeper levels, the long computationtime near the root is diffused to deeper levels, that have shorter time on average.Since it is very hard to capture the structure of the recursion, we give a conditioncalled Push-out condition such that the amortized computation time is boundedwhen the condition is satisfied. As the condition is given to the relation betweeneach iteration and its children, proving the satisfiability of the condition is oftennot difficult.As a result, to give a bound to amortized time complexity, what we haveto do is to prove that the condition holds for some algorithms. In this way,we propose algorithms for enumerating matchings, elimination orderings, andconnected vertex induced subgraphs, and prove that the condition holds foreach. These lead that these graph objects can be enumerated in constant timeper solution. We also show that the condition holds for the algorithm for spanningtree enumeration, and this gives a very simple proof compared to the existingones.he paper is organized as follows. Section 2 is for preliminaries, and Section3 describes our Push out amortization and Push out condition. Sections 4, 5, 6and 7 show algorithms and their proofs. We conclude the paper in Section 8.
Let A be an enumeration algorithm. Suppose that A is a recursive type algo-rithm, i.e., composed of a subroutine that recursively calls itself several times(or none). Thus, the recursion structure of the algorithm forms a tree. We callthe subroutine, or the execution of the subroutine an iteration . Note that aniteration does not include the computation done in the subroutines recursivelycalled by the iteration, thus no iteration is included in another. When the algo-rithm is composed of several kinds of subroutines and operations, and thus therecursion is a nest of several kind of subroutines. In such cases, we consider aseries of iterations of different types as an iteration.When an iteration X recursively calls an iteration Y , X is called the parent of Y , and Y is called a child of X . The root iteration is that with no parent.For non-root iteration X , its parent is unique, and is denoted by P ( X ). Theset of the children of X is denoted by C ( X ). The parent-child relation betweeniterations forms a tree structure called a recursion tree . An iteration is called a leaf iteration if it has no child, and an inner iteration otherwise.For iteration X , an upper bound of the execution time (the number of op-erations) of X is denoted by T ( X ). Here we exclude the computation for theoutput process from the computation time. We remind that T ( X ) is the timefor local execution time, and thus does not included the computation time inthe recursive calls generated by X . For example, when T ( X ) = O ( n ), T ( X )is written as cn for some constant c . T ∗ is the maximum T ( X ) among all leafiterations X . Here, T ∗ can be either constant, or a polynomial of the input size.If X is an inner iteration, let T ( X ) = P Y ∈ C ( X ) T ( Y ).In this paper, we assume that a graph is stored in a style of adjacency list. Fora vertex subset U of a graph G = ( V, E ), the induced subgraph of U is the graphwhose vertex set is U , and whose edge set contains the edges of E connectingtwo vertices of U . An edge is called a bridge if its removal increases the numberof connected components in the graph. An edge f is said to be parallel to e if e and f have the same endpoints, and be series to e if e is a bridge in G \ f andnot so in G .For an edge e of a graph G , we denote the graph obtained by removing e from G by G \ e , and that by removing e and edges adjacent to e by G + ( e ).Similarly, for a vertex v of G , G \ v is the graph obtained from G by removing v and edges incident to v . For an edge ( u, v ) of G , the graph contracted by ( u, v ),denoted by G/ ( u, v ), is the graph obtained by unifying the vertices u and v intoone. For an edge set F = { e , . . . , e k } , G/F denotes the graph
G/e /e / · · · /e k . The size of the input of each iteration for a recursive algorithm often decreasesas the depth of the recursion. Thus, iterations near the root iteration take a ig. 1.
An iteration, its children, andtheir computation time representedby rectangle lengths; seems to be in-efficient if children take long time,but this results in many descendantsindeed.
Fig. 2.
Push out rule; an iteration(center) receives computation timefrom its parent (while rectangle), anddelivers it together with its computa-tion time (gray rectangle) to its chil-dren, proportional to their computa-tion time.relatively long time, and iterations near leaf iterations take a relatively shorttime. Motivated by this observation, we amortize the computation time by mov-ing the computation time of each iteration to its children. We carry out thismove from the top to the bottom, so that the computation time of ancestors isrecursively diffused to their descendants. When we can obtain a short amortizedcomputation time in this way, iterations with long computation times have manydescendants at least proportional to their computation time; the average com-putation time per iteration will be long only when they have few descendants.However, it is not easy to prove that any inner iteration has sufficiently manydescendants. Instead of that, we use some local conditions, related to a parentand children. Suppose that α > β ≥ Push Out Condition (PO condition): for iteration X , T ( X ) ≥ αT ( X ) − β ( | C ( X ) | + 1) T ∗ .Fig. 1 shows a simple example of this condition. After the assignment of thecomputation time of αβ ( | C ( X ) | +1) T ∗ to children and the remaining to itself, theinequation T ( X ) ≥ αT ( X ) holds. This implies that the computation time of onelevel of recursion intuitively increases as the depth, unless there are not so manyleaf iterations. Considering that enumeration algorithms usually spend less timein deeper levels of the recursion, we can see that this implies that each iterationhas many children on average. This is in some sense not a typical condition tobound the time complexity of recursive algorithms; usually we want to decreasethe total computation time in deeper levels. However, in the enumeration, thenumber of leaf iterations is fixed, and thereby the total computation time in thebottom level is also fixed. Thus, this condition implies that the total computationtime is short. Theorem 1.
If any inner iteration of an enumeration algorithm satisfies POcondition, the amortized computation time of an iteration is O ( T ∗ ) .Proof. To prove the lemma, we charge the computation time. We neither movethe operations nor modify the algorithm, but just charge the computation time;he computation time can be considered as tokens, and we move the tokens sothat each iteration has a small number of tokens. We charge the computationtime from an iteration to its children, i.e., from the top of the recursion tree tothe bottom. Thus, an iteration receives computation time from its parent. Wecharge (push out) its computation time and that received from its parent to itschildren. The computation time is charged to the children, in proportion of theirindividual computation time, using the following rule.
Push out rule:
Suppose that iteration X receives a computation time of S ( X )from its parent, thus X has computation time of S ( X )+ T ( X ) in total. Then, wefix βα − ( | C ( X ) | + 1) T ∗ of the computation time to X , and charge (push out) theremaining computation time of quantity S ( X ) + T ( X ) − βα − ( | C ( X ) | + 1) T ∗ toits children. Each child Z of X receives computation time proportional to T ( Z ),i.e., S ( Z ) = ( S ( X ) + T ( X ) − βα − | C ( X ) | + 1) T ∗ ) T ( Z ) T ( X ) . See Fig. 2 as an example. According to this rule, we charge the computationtime from the root iteration to leaf iterations, so that each inner iteration has O (( | C ( X ) | + 1) T ∗ ) computation time. Since the sum of the number of childrenover all nodes in a tree is no greater than the number of nodes in a tree, thisis equivalent to that each iteration has O ( T ∗ ) time. The remaining issue is toprove the statement of the lemma by showing that each leaf iteration receivescomputation time of O ( T ∗ ), and it is sufficient to prove the statement. To showthat, we state the following claim. Claim : if we charge computation time in the manner of the push out rule, eachiteration X receives computation time of at most T ( X ) / ( α −
1) from its parent,i.e., S ( X ) ≤ T ( X ) / ( α − X satisfiesit. Then, for any child Z of X , Z receives computation time of( S ( X ) + T ( X ) − βα − | C ( X ) | + 1) T ∗ ) T ( Z ) T ( X ) ≤ ( T ( X ) / ( α −
1) + T ( X ) − βα − | C ( X ) | + 1) T ∗ ) T ( Z ) T ( X )= αT ( X ) − β ( | C ( X ) | + 1) T ∗ α − × T ( Z ) T ( X )= αT ( X ) − β ( | C ( X ) | + 1) T ∗ T ( X ) × T ( Z ) α − . Since PO condition is satisfied, T ( X ) ≥ αT ( X ) − β ( | C ( X ) | + 1) T ∗ . Thus, αT ( X ) − β ( | C ( X ) | + 1) T ∗ T ( X ) T ( Z ) α − ≤ T ( Z ) α − . y induction, any iteration satisfies the condition in the claim. ⊓⊔ Note that PO condition does not require for the iterations to have at leasttwo children.
Let L be a class of structures such as sets, graphs, and sequences. Suppose thatany structure Z ∈ L consists of a set of elements called an ground set , that isdenoted by V ( Z ). Examples of ground sets are the vertex set of a graph, theedge set of a graph, the cells of a matrix, and the letters of a string. The emptystructure ⊥ is the unique structure that has V ( ⊥ ) = ∅ , and hereafter we consideronly L including the empty structure. For each Z ∈ L , Z = ⊥ , we define the setof removable elements R ( Z ), such that for each removable element e ∈ R ( Z ),the removal of e from Z results in a structure Z ′ ∈ L , V ( Z ′ ) = V ( Z ) \ { e } . Wedenote the removal of e from Z by Z \ e , and we assume that no two differentstructures can be generated by the removal of e . By using removable elements, wedefine elimination orderings . An elimination ordering is an ordering ( z , . . . , z n )of elements in V ( Z ) iteratively removed from Z until Z is ⊥ , i.e., any z i isremovable in the structure Z i that is obtained by repeatedly removing z to z i − from Z . Example of elimination ordering are removing leaves from a tree,and perfect elimination ordering of a chordal graph. A simple algorithm forenumerating elimination orderings can be described as follows. Algorithm
EnumElimOrdering (
Z, S )1. if | V ( Z ) | = 1, output S + z where V ( Z ) = { z } ; return for each element z ∈ V ( Z ) do if z ∈ R ( Z ), call EnumElimOrdering ( Z \ z, S + z )4. end for Suppose that we are given a structure Z in a class L and removable groundset R for ground set V ( Z ). We suppose that for any z ∈ V ( Z ), we can list all z ∈ R ( Z ) in Θ ( p ( | V ( Z ) | ) q ( n )) time, where p ( | V ( Z ) | ) is a polynomial of | V ( Z ) | ,and q ( n ) is a function where n is an invariant of the input structure, such as thenumber of edges in the original graph. We also assume that a removal of elementtakes Θ ( p ( | V ( Z ) | ) q ( n )) time. Theorem 2.
Elimination orderings of a class L can be enumerated in O ( q ( n )) time for each, if | R ( Z ) | ≥ holds for each Z ∈ L such that | V ( Z ) | is larger thana constant number c .Proof. We first bound the computation time except for the output processes,that is, step 1 of EnumElimOrdering. First, we choose two constants δ > c and α > p ( i − p ( i ) > α holds for any i > δ . Since p is a polynomial function, p ( i ) p ( i − converges to 1, thus such α always exists. Let X be an iteration. When X inputs Z with | V ( Z ) | ≤ δ , the computation time is q ( n ), except for the outputprocess. Hence, we have T ∗ = O ( q ( n )). For the case | V ( Z ) | ≤ δ , the computationtime of X is bounded by q ( n ). For the case | V ( Z ) | > δ , we have ( X ) ≥ | V ( Z ) | − p ( | V ( Z ) | − q ( n ) > α | V ( Z ) | p ( | V ( Z ) | ) q ( n ) , since X has at least two children. Thus, X satisfies PO condition with anyconstant β >
0. From Theorem 1, except for the output process, the computationtime is bounded by O ( q ( n )) time for each iteration whose input has at least δ elements. Since any inner iteration Y has exactly one child only if | V ( Y ) | ≤ c ,the number of inner iterations is bounded by the number of leaf iterations,multiplied by c . Therefore, the computation time for each elimination orderingcan be bounded by O ( cq ( n )) = O ( q ( n )) time.Next, let us consider the output process. Instead of explicitly outputtingelimination orderings, we output each elimination ordering S by the differencefrom S ′ that is output just before S . We can output them compactly in this way.Although the difference can be large up to | V ( Z ) | , we can see that it is boundedby the number of operations done from the previous output process. Thus, thesize of all output differences, except for the first one output in the usual way, isat most proportional to the total computation time. Therefore, the computationtime for the output process is also bounded by O ( q ( n )) time for each. ⊓⊔ The next corollary immediately follows from the theorem.
Corollary 1.
For a given set class, elimination ordering can be enumeratedby EnumElimOrdering in O (1) amortized time for each, if each inner iterationgenerates at least two recursive calls, and takes O ( p ( | V ( Z ) | )) time, where p is apolynomial of | V ( Z ) | . ⊓⊔ There are actually several elimination orderings to which this theorem canbe applied, and they are listed below. For conciseness, we have described eachby their structures and removable elements.
Example (a): perfect elimination orderings of a chordal graph[2]
For a graph, a vertex is called simplicial if the vertices adjacent to it form aclique. An elimination orderings of simplicial vertex is called perfect eliminationordering [11], and a graph is chordal if it has a perfect elimination ordering. Wedefine L by the set of chordal graphs, V ( Z ) by the vertex set of Z ∈ L , and R ( Z ) by the set of its simplicial vertices.It is known that any chordal graph Z admits a clique tree whose vertices aremaximal cliques of Z . If Z is a clique, all vertices in Z are simplicial. If not, it isknown that there are at least two cliques that has a vertex that is not includedin the other maximal cliques. Note that these cliques are leaf cliques of a cliquetree, where the vertices of a clique tree are maximal cliques of Z , each edge con-nects overlapping cliques, and the maximal cliques including any vertex formsa subtree of the clique tree. The vertex is simplicial, hence | R ( Z ) | ≥ | V ( X ) | ) time,we can enumerate all perfect elimination orderings in O (1) time for each. Notethat although the algorithm in [2] already attained the same time complexity,ur analysis yields much simpler algorithm and proof, Example (b): perfect sequence[9] L is the class of chordal graphs Z , and V ( Z ) is the set of maximal cliques in Z . A maximal clique is removable if it is a leaf of some clique trees of Z , andthe removal of a maximal clique z from Z is the removal of all vertices of z thatdo not belong to another maximal clique. The removal of the vertices results inthe graph that includes remaining maximal cliques, and no new maximal cliqueappears in the graph. Note that a clique tree has at least two leaves if it hasmore than one vertex, thus | R ( Z ) | ≥
2. An elimination ordering is called a per-fect sequence . Since all removable maximal cliques can be found in polynomialtime in the number of maximal cliques[9], all perfect sequences are enumeratedin O (1) time for each.The elimination orderings induced by following removable elements can bealso enumerated in O (1) time for each. – non-cut vertices of connected graph – points on surface of convex hull of a point set in plane – leaves of a tree – vertices of degrees less than seven of a simple planar graph. A matching of a graph is an edge subset of a graph G = ( V, E ) such that no twoedges are adjacent. The matchings are enumerated by the following algorithm.
Algorithm
EnumMatching ( G = ( V, E ) , M )1: if E = ∅ then output M ; return
2: choose an edge e from E call EnumMatching ( G \ e, M )4: call EnumMatching ( G + ( e ) , M ∪ { e } )The time complexity of an iteration of EnumMatching is O ( | V | ). Since eachinner iteration generates two children, the computation time for each matchingis O ( | V | ), and no better algorithm has been proposed in the literature. A leafiteration takes O (1) time, thus T ∗ = O (1). However, PO condition may not holdfor some iterations. This cannot be better than O ( | V | ) in straightforward ways.PO condition does not hold when many edges are adjacent to e . In such cases, G + ( e ) has few edges, thus the subproblem of G + ( e ) takes short time so that POcondition does not hold. To avoid this situation, we modify the way of recursionas follows so that in such cases the iteration has many children. Let u , . . . , u k be the vertices adjacent to v , and e i = ( v, u i ). We partition the matchings to beenumerated into – matchings including e – matchings including e – · · · matchings including e k – matchings including no edge incident to v .We see that any matching belongs to exactly one of these groups. To recur,we derive G + ( e ) , . . . , G + ( e k ) and G \ v . G \ v and G + ( e ) can be derived in O ( | E | ) time. To shorten the computation time for G + ( e i ) for i ≥
2, we construct G + ( e i ) from G + ( e i − ). We add all edges of G incident to u i − to G + ( e i − ),and remove all edges adjacent to u i , and obtain G + ( e i ). This can be done in O ( d ( u i − ) + d ( u i )) time. To construct G + ( e i ) for all i = 2 , . . . , k , we need O ( ( d ( u ) + d ( u )) + ( d ( u ) + d ( u )) + · · · + ( d ( u k − ) + d ( u k )) ) = O ( | E | )time. Thus, the computation time of an iteration is bounded by c | E | with aconstant c . The algorithm is described as follows. Algorithm
EnumMatching2 ( G = ( V, E ) , M )1: if E = ∅ then output M ; return
2: choose a vertex v having the maximum degree in G call EnumMatching2 ( G \ v, M )4: for each edge e adjacent to v , call EnumMatching2 ( G + ( e ) , M ∪ { e } ) Theorem 3.
All matchings in a graph can be enumerated in O (1) time for each,with O ( | E | + | V | ) space.Proof. The amortized computation time for outputting process is bounded by O (1) for each by using difference as elimination ordering. Let us consider aninner iteration X . In the iteration X , if d ( v ) ≥ | E | /
4, we generate at least | E | / | C ( X ) | = Ω ( | E | ) and PO condition is satisfied bychoosing sufficiently large β . If d ( v ) < | E | /
4, the subproblems of G \ v take atleast Θ (3 c | E | /
4) time, and the subproblems of G + ( e ) take at least c | E | / α = 1 .
25, we have T ( X ) ≥ c | E | / c | E | / c | E | / ≥ αT ( X ) − β | C ( X ) | T ∗ thereby PO condition holds. Remind that each inner iteration generates twoor more recursive calls, the number of iterations does not exceed the twice thenumber of matchings. Since any inner iteration satisfies PO condition and T ∗ = O (1), the statement holds. We remind that we assumed that there is no isolatedvertex in the input graph, and thus the number of matchings in the graph isgreater than the number of vertices, and the number of edges. ⊓⊔ We consider the problem of enumerating all vertex sets of the given graph G = ( V, E ) inducing connected subgraphs (connected induced subgraphs inshort). In literature, an algorithm is proposed that runs in O ( | V | ) time foreach[1]. For the enumeration, it is sufficient to enumerate all connected inducedubgraphs including the given vertex r . For a vertex v adjacent to r , the con-nected induced subgraphs including r are partitioned into those including v andthose not including v . The former subgraphs are connected induced subgraphsin G/ ( r, v ) and the latter subgraphs are those in G \ v . We have the followingalgorithm according to this partition, and we prove that this algorithm satisfiesPO condition. Algorithm
EnumConnect ( G = ( V, E ) , S, r )1: if d ( r ) = 0 then output S ; return
2: choose a vertex v adjacent to r call EnumConnect ( G/ ( r, v ) , S ∪ { v } , r )4: call EnumConnect ( G \ v, S, r ) Theorem 4.
All connected vertex induced subgraphs in a graph can be enumer-ated in O (1) time for each, with O ( | E | + | V | ) space.Proof. The correctness of the algorithm and the bound for memory usage areclear. Since each inner iteration generates exactly two recursive calls, the numberof iterations is linearly bounded by the number of connected induced subgraphs,and T ∗ = O (1).As same to the matching enumeration, the computation time for outputtingprocess is bounded by O (1) for each. An inner iteration X of the algorithm takes O ( d ( r ) + d ( v )) time. We assume that T ( X ) = c (3 d ( r ) + d ( v )) for a constant c ,and leaf iteration takes 3 c time, since T ∗ = O (1). The constant factor of threeis a key to PO condition.The degree of r is at least ( d ( r ) + d ( v )) / − G/ ( r, v ), and d ( r ) − G \ v . Note that d ( r ) and d ( v ) are degrees of r and v in G . From this, we can seethat the child iteration of G/ ( r, v ) takes at least 3 c (( d ( r ) + d ( v )) / −
1) time,and that of G \ v takes at least 3 c ( d ( r ) −
1) time. Their sum is at least3 c (( d ( r ) + d ( v )) / −
1) + 3 c ( d ( r ) −
1) = 32 c (3 d ( r ) + d ( v )) − c = 32 T ( X ) − c. Setting β = 6, we can see that X satisfies PO condition. Thanks to Theorem 1,the computation time for each connected induced subgraph is O (1). ⊓⊔ A subtree T of a graph G = ( V, E ) is called a spanning tree if any vertex of G is incident to at least one edge of T . Any spanning tree has | V | − e be an edge of G . If there are several edges e , . . . , e k parallel to e ,let F = { e , . . . , e k } and F i = F \ { e i } . We see that at most one edge from F can be included in a spanning tree, thus we enumerate spanning trees in( G \ F ) /e , . . . , ( G \ F k ) /e k . We further enumerate spanning trees in G \ F ifit is connected. Any spanning tree is enumerated in exactly one of these. When has no parallel edges, e can have series edges. If there are several edges e , . . . , e k series to e , again let F = { e , . . . , e k } and F i = F \ { e i } . We also seethat any spanning tree includes at least k − F , thus we enumeratespanning trees in ( G/F ) \ e , . . . , ( G/F k ) \ e k . We further enumerate spanningtrees in G/F if F is not the edges of a cycle. Also in this case, any spanning treeis enumerated once among these. By using these subdivisions, we construct thefollowing algorithm. Algorithm
EnumSpanningTree ( G = ( V, E ) , T )1: if E = ∅ then output T ; return
2: choose an edge e from E F p := { e } ∪ { e | e is parallel to e } ; F s := { e } ∪ { e | e is not parallel to e , and e is series to e } for each e i ∈ F p , call EnumSpanningTree (( G \ ( F p \ { e i } ) /e i , T ∪ { e i } )5: for each e i ∈ F s , call EnumSpanningTree (( G/ ( F s \ { e i } ) \ e i , T ∪ ( F s \ { e i } ))We observe that these k subgraphs are actually isomorphic in both cases exceptfor the edge label e i , thus constructing these graphs takes O ( | V | + | E | ) time. Theorem 5.
All spanning trees in a graph can be enumerated in O (1) time foreach, with O ( | E | + | V | ) space.Proof. The space complexity of the algorithm is O ( | E | + | V | ) and an iterationtakes Θ ( | V | + | E | ) time since all edges parallel/series to an edge can be foundby two connected component decomposition in O ( | V | + | E | ) time. If no edge isparallel or series to e , we generate two subproblems of | E | − k edges are parallel or series to e , we have at least k + 1 ≥ | E | − ( k + 1) edges. When k + 1 ≥ | E | / T ( X ) − β ( | C ( X ) | +1) T ∗ = 0 holds for some β >
0, and PO condition holds. When k + 1 < | E | / k + 1)( | E | − ( k + 1)) ≥ . | E | holds, PO condition holds for α = 1 . β >
0. Since each iteration generates at least two recursive calls or outputsa solution, the number of iterations is at most twice the number of solutions,therefore the statement holds. ⊓⊔ We introduced a new way of looking at amortizing the computation time ofenumeration algorithms, by local conditions of recursion trees. We clarified theconditions that are sufficient to give non-trivial upper bounds for the averagecomputation time of iterations that only depended on the relation between thecomputation time of a parent iteration and that of its child iterations. We showedthat many algorithms for elimination orderings have good properties so thatthe conditions are satisfied, and thus enumerated in constant time for each.Several other enumeration algorithms for matchings, connected vertex inducedsubgraphs, and spanning trees were also described, whose time complexities are O (1) for each solution.There are many problems for those enumeration algorithms that do not sat-isfy the conditions. An interesting future work is to develop new algorithms forhese problems, that satisfy the conditions. Another direction is to study otherconditions for bounding amortized computation time. Further studies on amor-tized analysis will possibly fill the gaps between theory and practice, and clarifythe mechanisms of enumeration algorithms. Acknowledgments:
Part of this research is supported by the FundingProgram for World-Leading Innovative R&D on Science and Technology, Japan,and Grant-in-Aid for Scientific Research (KAKENHI), Japan.
References
1. D. Avis and K. Fukuda, Reverse Search for Enumeration,
Discrete Applied Math-ematics , pp. 21-46 (1996).2. L. S. Chandran, L. Ibarra, F. Ruskey, and J. Sawada, Generating and Characteriz-ing the Perfect Elimination Orderings of a Chordal Graph, Theoretical ComputerScience , pp. 303-317 (2003).3. D. Eppstein, Finding the k Smallest Spanning Trees,
SWAT 90, Lecture Notes inComputer Science , pp. 38-47 (1990).4. D. Eppstein, Finding the k Shortest Paths,
FOCS 94 , pp. 154-165 (1994).5. R. Ferreira, R. Grossi and R. Rizzi, Output-sensitive Listing of Bounded-size Treesin Undirected Graphs”,
ESA 2011, Lecture Notes in Computer Science ,pp. 275-286 (2011).6. Frequent Itemset Mining Dataset Repository, http://fimi.cs.helsinki.fi/data/7. H. N. Gabow, R. E. Tarjan, A Linear-time Algorithm for a Special Case of DisjointSet Union
STOC ’83 , pp. 246-251 (1983).8. H. N. Kapoor and H. Ramesh, Algorithms for Enumerating all Spanning Trees ofUndirected and Weighted Graphs,
SIAM Journal on Computing , , pp. 247-265(1995).9. Y. Matsui, R. Uehara and T. Uno, Enumeration of the Perfect Sequences of aChordal Graph, Theoretical Computer Science , pp. 3635-3641 (2010).10. Y. Matsui and T. Matsui, Enumeration Algorithm of the Edge Colorings in Bipar-tite Graphs,
Lecture Notes in Computer Science ,pp. 18–26 (1995).11. D. J. Rose, R. E. Tarjan, and G. S. Lueker, Algorithmic Aspects of Vertex Elimi-nation on Graphs,
SIAM Journal on Computing , pp. 266-283 (1976).12. A. Shioura, A. Tamura and T. Uno, An Optimal Algorithm for Scanning All Span-ning Trees of Undirected Graphs, SIAM Journal on Computing , pp. 678-692(1997).13. D. D. Sleator, R. E. Tarjan, A Data Structure for Dynamic Trees, STOC ’81 ,pp. 114–122 (1981).14. T. Uno, A New Approach for Speeding Up Enumeration Algorithms and Its Appli-cation for Matroid Bases,
COCOON 99, Lecture Notes in Computer Science1627