Dynamic Programming on Tree Decompositions Using Generalised Fast Subset Convolution Johan M.M. van Rooij1 , Hans L. Bodlaender1 , and Peter Rossmanith2 1
Department of Information and Computing Sciences, Utrecht University, P.O.Box 80.089, 3508 TB Utrecht, The Netherlands {jmmrooij,hansb}@cs.uu.nl 2 Computer Science Department, RWTH Aachen University, 52056 Aachen, Germany
[email protected]
Abstract. In this paper, we show that algorithms on tree decompositions can be made faster with the use of generalisations of fast subset convolution. Amongst others, this gives algorithms that, for a graph, given with a tree decomposition of width k, solve the dominated set problem in O(nk2 3k ) time and the problem to count the number of perfect matchings in O∗ (2k ) time. Using a generalisation of fast subset convolution, we obtain faster algorithms for all [ρ, σ]-domination problems with finite or cofinite ρ and σ on tree decompositions. These include many well known graph problems. We give additional results on many more graph covering and partitioning problems.
1
Introduction
Many recent investigations show that problems that are intractable on general graphs (e.g., NP-hard) become tractable (e.g., linear time solvable) when restricted to graphs of bounded treewidth. However, the constant factors involved in such algorithms are often large, and thus, for practical considerations, it is useful to find algorithms on graphs of small treewidth where the factor in the time, as function of treewidth, grows as slow as possible. Most algorithms on graphs of bounded treewidth consist of two steps: 1. Find a tree decomposition of small width of the input graph. 2. Solve the problem on this tree decomposition using dynamic programming. Concerning the first of these steps, one can find in linear time a tree decomposition of width at most k, for fixed k, if existing [4], but the constant factor of this algorithm is very high. However, in several cases, tree decompositions of small width can be obtained for special graph classes (see [5]), and there are also several good heuristics that often work well in practice (see [7]). In this paper, we improve on the running time of the second of these steps, as a function of the treewidth. In particular, we show that covering products and fast subset convolutions [3] can be used to speed up these algorithms. In some cases, A. Fiat and P. Sanders (Eds.): ESA 2009, LNCS 5757, pp. 566–577, 2009. c Springer-Verlag Berlin Heidelberg 2009
Dynamic Programming on Tree Decompositions
567
our algorithms use a generalisation of these algorithms. While covering products and subset convolutions are defined on sets with subsets, we generalise these to multiple states. Our algorithms are optimal in a certain sense: the running times are a polynomial in the size of the graph times the size of tables in any known tree decomposition based dynamic programming algorithm for the problems. There are several recent papers that analyse the running time of algorithms on tree decompositions. For several vertex partitioning problems, Telle and Proskurowski [16] show that there are algorithms that solve these problems in O(ck n) time, with c a constant only depending on the problem at hand. For the Dominating Set problem, Alber and Niedermeier [2] give an improved algorithm that runs in O(4k n) time; similar results are given in [2] for related problems: Independent Dominating Set, Total Dominating Set, Perfect Dominating Set, Perfect Code, Total Perfect Dominating Set, weighted versions, and Red-Blue Dominating Set. See also [1]. The improvement in [2] is used by exploiting a notion of monotonicity. In this paper, we introduce two new techniques, the first using a variant of convolutions, and the second a simple way of partitioned table handling, that speed up these results and can be used for several other problems as well. Another technique to speed up algorithms on tree decompositions or on the related branch decompositions was introduced by Dorn [9], who employed fast matrix multiplication. If the input graph is planar, then other improvements are possible, see [10,12]. In [10], Dorn showed amongst others, that Dominating Set for planar graphs with a given tree decomposition of width k can be solved in O∗ (3k ) time. Some of these results can be generalised to graphs that avoid a minor, see [11]. We obtain the same result without requiring planarity. Many dynamic programming algorithms on tree decompositions compute a table for each node in the tree decomposition. These tables have an entry for each assignment of a state from some fixed set to each vertex in the bag. It is possible to use different sets of states for the same problem that lead to different running times. In Section 3, we discuss how we can transfer a table for one set of states to the equivalent table for a different set of states. In Sections 4 and 5, we obtain faster tree decomposition algorithms for Dominating Set and #Perfect Matching; the switch technique of Section 3 is used as a subroutine. These results serve as examples of a general method, as the techniques can be applied to many problems. In Section 6, we obtain faster tree decomposition algorithms for a large set of problems, namely all [ρ, σ]-domination problems with finite or cofinite ρ and σ, as introduced by Telle and Proskurowski [16].
2
Preliminaries
Let G = (V, E) be an n-vertex graph. A tree decomposition of G is a tree T in whicheach node i ∈ T has an assigned set of vertices Xi ⊆ V (called a bag) such that i∈T Xi = V with the following properties: 1. for all {u, v} ∈ E, there exists an i ∈ T such that {u, v} ⊆ Xi . 2. if v ∈ Xi and v ∈ Xj , then v ∈ Xk for all Xk on the path from Xi to Xj in T .
568
J.M.M. van Rooij, H.L. Bodlaender, and P. Rossmanith Table 1. [ρ, σ]-domination problems (taken from [15,16])
ρ {0, 1, . . .} {1, 2, . . .} {0, 1} {1} {1, 2, . . .} {1} {1, 2, . . .} {1} {0, 1} {0, 1} {1} {0, 1, . . .} {p, p + 1, . . .} {0, 1, . . .}
σ {0} {0, 1, . . .} {0} {0} {0} {0, 1, . . .} {1, 2, . . .} {1} {0, 1, . . .} {0, 1} {0, 1} {0, 1, . . . , p} {0, 1, . . .} {p}
Standard problem description Independent Set Dominating Set Strong Stable Set/2-Packing/Distance-2 Independent Set Perfect Code/Efficient Dominating Set Independent Dominating Set Perfect Dominating Set Total Dominating Set Total Perfect Dominating Set Nearly Perfect Set Total Nearly Perfect Set Weakly Perfect Dominating Set Induced Bounded Degree Subgraph p-Dominating Set Induced p-Regular Subgraph
The treewidth of a tree decomposition is the size of the largest bag of T minus one: maxi∈T |Xi | − 1. The treewidth of a graph G is the minimum treewidth over all possible tree decompositions of G. In this paper, we will always assume that tree decompositions of the appropriate width are given. Dynamic programming algorithms solving N P-hard problems on graphs of bounded treewidth are often presented on nice tree decompositions. These are rooted tree decompositions in which each node is of one of the following types: 1. Leaf node: a leaf of T . 2. Introduce node: an internal node i with one child node c for which Xi = Xc ∪ {v}. This node is said to introduce the vertex v. 3. Forget node: an internal node i with one child node c for which Xi = Xc \{v}. This node is said to forget the vertex v. 4. Join node: an internal node i with two child nodes l, r with Xi = Xl = Xr . Given a tree decomposition, a nice tree decomposition of equal width can be found in polynomial time [14]. For more information on tree decompositions and dynamic programming over tree decompositions, see [6]. We associate to each node i in the tree decomposition a subgraph Gi = (Vi , Ei ) of G. A vertex v ∈ V belongs to Gi , if and only if there is a bag j with j = i or j a descendant of i with v ∈ Xj , and {v, w} ∈ E belongs to Gi iff v, w ∈ Vi . A dominating set in a graph G is a set of vertices D ⊆ V such that for every v ∈ V \ D there exists a (v, d) ∈ E with d ∈ D. Finding a dominating set of minimum size in G is a classical N P-complete problem (Dominating Set). A perfect matching in G is a set of edges M ⊆ E such that every v ∈ V is contained in exactly one edge e ∈ M . Counting the number of perfect matchings in a graph is a classical #P-complete problem (#Perfect Matching). Let ρ, σ ⊆ N, a [ρ, σ]-dominating set is a subset D ⊆ V such that: for every v ∈ V \ D: |N (v) ∩ D| ∈ ρ, and for every v ∈ D: |N (v) ∩ D| ∈ σ, where N (v) denotes the open neighbourhood of a vertex v ∈ V in G.
Dynamic Programming on Tree Decompositions
569
The [ρ, σ]-domination problems were introduced by Telle in [15,16] and form a large class of graph covering problems: see Table 1. Throughout this paper, we assume that ρ and σ are either finite or cofinite. Throughout the paper, tables are denoted with their parameters, e.g., A(c) is a table that maps each c (from a domain that is clear from the context) to a value (with the range also clear from the context).
3
Switching between State Representations
A dynamic programming algorithm on a tree decomposition T traverses T in a bottom up fashion. In each visited node i ∈ T , partial solutions to the problem on Gi are stored. These partial solutions must satisfy all problem specific constraints everywhere except on the vertices in Xi . To store these partial solutions and identify them by their behaviour on the current bag, for each node of T , a table A(c) is computed containing the solutions corresponding to an assignment of states c (also called a colouring) to the vertices in Xi . During the traversal, the table for each node is computed from the tables from its child nodes. This results in an algorithm that is polynomial in the size of T , but exponential in the treewidth of T (the size of the largest bag). For example, when solving #Perfect Matching, the obvious tree decomposition based dynamic programming algorithm uses states {0, 1}, where 1 means this vertex is matched and 0 means that it is not. The table entry A(c) now contains the number of matchings in Gi such that the only vertices that are not matched are exactly the vertices in the current bag Xi with state 0 in c. We make the following observation: the described table A(c) contains exactly the same information as a table A (c) using states {0, ?}, where ? represents a vertex where we do not specify if it is matched. I.e., for a specific assignment of states c, we count the number of matchings in Gi , where all vertices in Vi \Xi are matched, all vertices with state 0 in c are unmatched, and all vertices with state ? can either be matched or not. In this second representation, there no longer is a direct relation between the partial solutions and the states: a matching where a vertex v ∈ Xi is not matched is counted both in the cases where v has state ? and where v has state 0. We will use such alternative representations throughout this paper to obtain exponentially faster algorithms. Lemma 1. A table containing the number of perfect matchings corresponding to states {0, 1} contains the same information as a table using states {0, ?}. Transformations using O(k2k ) operations between both tables exists. If one defines a vertex with state 1 or ? to be in S, and a vertex with state 0 not to be in S, then the state changes are M¨obius transforms and inversions, see [3]. The proof then directly follows from their fast evaluation algorithms. Proof. The fast transformations work in k steps. In step 1 ≤ i ≤ k, we assume that the first i−1 coordinates of the colouring c in our table use one set of states, and the other k − i + 1 coordinates use the other set of states. Using this as an invariant, we change the set of states used for the i-th coordinate at step i.
570
J.M.M. van Rooij, H.L. Bodlaender, and P. Rossmanith Table 2. Vertex states for the Dominating Set Problem
state 1 01 00 0?
meaning this vertex this vertex this vertex this vertex
is is is is
in the dominating set. not in the dominating set and has already been dominated. not in the dominating set and has not yet been dominated. not in the dominating set and may or may not be dominated.
Transforming from {0, 1} to {0, ?} can be done using the following formula in which A(c) represents our table for colouring c, c1 is a subcolouring of size i using states {0, 1}, and c2 is a subcolouring of size k − i − 1 using states {0, ?}. A(c1 × {?} × c2 ) = A(c1 × {0} × c2 ) + A(c1 × {1} × c2 ) In words, the number of matchings that may contain some vertex equals the sum of those that do and those that do not contain it. For the reverse transformation from {0, ?} to {0, 1} there is a similar formula: A(c1 × {1} × c2 ) = A(c1 × {?} × c2 ) − A(c1 × {0} × c2 ) In words, the number of matchings that contain some vertex equals all matchings minus those that do not contain the vertex. Each step computes 2k values resulting in O(k2k ) time transformations. For Dominating Set the obvious set of states to use would be {1, 01, 00 }: see Table 2. The tables of the dynamic programming algorithm would then, for each colouring c, store the minimum size of a vertex set dominating all vertices seen this far except those with state 00 in the current bag and that contain exactly those vertices in the current bag that have state 1. We take a slightly different approach and use a table A(c, κ) containing the number of dominating sets of each size 0 ≤ κ ≤ n corresponding to the colouring c on the current bag. With this modification, we can also use different sets of states capturing exactly the same information for Dominating Set. Lemma 2. A table A(c, κ) containing the number of dominating sets of size 0 ≤ κ ≤ n corresponding to a colouring c contains the same information independent of the following three choices of states (see Table 2): {1, 01 , 00 }, {1, 01 , 0? }, {1, 0? , 00 }. Transformations using O(nk3k ) operations between the tables exist. Proof. Repeat the following for each 0 ≤ κ ≤ n. Fix the 1 states and then apply the same transformations as described in Lemma 1 on the 0 states. We can use either one of the three sets of states since the 0? state can be created while preserving either the 00 state or the 01 state.
4
Minimum Dominating Set
The previously fastest algorithm for Dominating Set on graphs of treewidth k runs in O(n4k ) and due is to Alber et al. [1,2]. Their dynamic programming
Dynamic Programming on Tree Decompositions
571
Table 3. Join tables for the Dominating Set and #Perfect Matching problems × 1 01 00 1 1 01 01 01 00 01 00
× 1 01 0? 1 1 01 01 0? 01 0?
× 1 0? 00 1 1 0? 0? 00 00
× 01 0 01 1 1
× 0? 0 0 ? ?
algorithm uses states {1, 01 , 0? } (see Table 2), and stores the sizes of the minimum dominating sets corresponding to each state colouring on the bag. This algorithm uses O∗ (3k ) time on leaf, introduce and forget bags, but O∗ (4k ) time on a join bag. Using the results from Section 3, we will improve this to O∗ (3k ). First of all, we observe that the Alber et al. algorithm [1,2] can be extended quite easily to count the number of dominating sets of each size 0 ≤ κ ≤ n; we will use these procedures to compute tables for leaf, introduce, and forget bags. We begin with our main theorem on Dominating Set. Theorem 1. There is an algorithm counting the number of dominating set of each size 0 ≤ κ ≤ n on a graph of treewidth k in O(n3 3k i× (n)) time. Here, i× (n) is the time required to work with (multiply) n-bit integers: currently ∗ i× (n) = n log(n)2log (n) [13]. Proof. We prove the result by showing that we can perform a join operation in O(n2 3k i× (n)) time. For this operation, two child bags with given tables AL (c, κ) and AR (c, κ) are provided. Using Lemma 2, we make sure that they are given using states {1, 0? , 00 }. Now, the table for the join bag A(c, κ) can be computed using the following formula, where #1 (c) stand for the number of 1 states in c: A(c, κ) = AL (c, κL ) · AR (c, κR ) κL +κR −#1 (c)=κ
We sum over all ways to obtain a set of size κ by combining both child tables. The sum is evaluated in O(ni× (n)) time, giving an O(n2 3k i× (n)) time join. This is correct because each vertex with one of three states in {1, 0? , 00 } in the join bag requires that the corresponding vertices in both child bags have the same state: a vertex is in the dominating set if it is so in both child bags (1), a vertex may or may not be dominated if it is so in both child bags (0? ), and a vertex is not dominated if it is so in both child bags (00 ), see Table 3. A similar join with states {1, 01 , 00 } in which a 01 state can be created from a 01 from both children, or a 01 from one child and a 00 from the other, gives an O∗ (5k ) algorithm. The decision procedure of Alber et al. with states {1, 01, 0? } leads to an O∗ (4k ) algorithm. See Table 3. The proof of Theorem 1 uses the principle of the covering product [3]. We presented it using mostly terminology from tree decomposition algorithms. We choose this manner of presentation because it easily generalises to more than two states. In this way, one, for example, easily proves the following proposition.
572
J.M.M. van Rooij, H.L. Bodlaender, and P. Rossmanith
Proposition 1. There is an algorithm counting the number of partitions of a graph of treewidth k into two total dominating sets in O∗ (6k ). We proceed by improving the polynomial factors for Dominating Set. Corollary 1. There is an algorithm counting the number of minimum dominating sets on a graph of treewidth k in O(nk 2 3k i× (n)) time. Proof. Dominating set has the finite integer index property [8]: the size difference between any two minimum dominating sets stored in a table is at most k. For the leaf, introduce and forget bags, we store for each colouring c the size of the corresponding minimum dominating set B(c) and the number of such sets A(c) using states {1, 01, 00 }. At a join node, we expand the tables to: A(c) if B(c) = κ A(c, κ) = 0 otherwise Then, change states as in Theorem 1 and perform the join. To extract A(c) and B(c) for the join table, let A(c) = A(c, κ ) and let B(c) = κ , where κ is the smallest value of κ for which A(c, κ) is non-zero. The sum now has at most k terms on child tables of size only k3k giving the running time. Corollary 2. There is an algorithm solving the minimum dominating set problem on graphs of treewidth k in O(nk 2 3k ) time. Proof. We improve on Corollary 1 by only keeping track of the size of the dominating set B(c) using states {1, 01, 00 }. At a join node, expand the tables to: 1 if B(c) = κ A(c, κ) = 0 otherwise Then, proceed as in Corollary 1 and perform the join. Now, we do not count dominating sets, but simply the number of 1-entries in the table A(c, κ).
5
Counting the Number of Perfect Matchings
We need a more involved algorithm to count the number of perfect matchings on a graph of treewidth k. This algorithm uses fast subset convolutions [3]. Given a set U and functions f, g : 2U → Z their subset convolution is defined: (f ∗ g)(S) = f (X)g(S \ X) (1) X⊆S
The fast subset convolution algorithm computes this in O(k 2 2k ) operations [3]. Our algorithm uses states {0, 1} with the invariant that vertices with state 1 are matched only with vertices outside of the bag, i.e. vertices that have already been forgotten by the algorithm. This prevents vertices to be matched within the bag and greatly simplifies the join. To obtain the final solution from the root of the tree decomposition, we add a series of forget nodes to the root. Our proof uses the fast subset convolution algorithm without mentioning it. Instead, we use state changes: this approach will be generalised in Section 6.
Dynamic Programming on Tree Decompositions
573
Theorem 2. There is an algorithm counting the number of perfect matchings in a graph of treewidth k in O(nk 2 2k i× (n)) time. Proof. Due to space restrictions, we will only explain the join operation. We cannot simply change states to {0, ?} and perform the join similar to dominating set as suggested by Table 3. This is because two ? states do not combine to a new ? state since this would allow a vertex to be matched twice. To compensate for this, one can expand the tables and index them by the number of matched vertices. Let AC (c) be one of the child tables AL (c) or AR (c). AC (c) if #1 (c) = i AC (c, i) = 0 otherwise Now we do the following. First change the state representation in the tables AC (c, i) to {0, ?} obtaining new tables AC (c, i); these tables does not use state 1, but are still indexed by the number of 1 states used in the previous representation. Then, join the tables by combining all possibilities that arise from i 1 states in the old representation (stored in the index i) using the following formula: AL (c, iL ) · AR (c, iR ) A (c, i) = i=iL +iR
Next, change states back to {0, 1} obtaining a table A(c, i); notice that a 1 state can now represent a vertex that is matched twice. Finally, we can find those entries that do not match a vertex twice by the following observation: the total number of 1 states in c should equal the sum of those in its child tables, now stored in the index i. The join table follows A(c) from extracting these entries: A(c) = A(c, #1 (c)) The running time is dominated by the time required to compute A (c, i): k2k entries, each requiring a k-term sum, giving the O(nk 2 2k i× (n)) time bound.
6
[ρ, σ]-Domination Problems
We have shown how to solve two elementary problems in O∗ (sk ) on graphs of treewidth k, where s is the number of states per vertex used in representations of solutions. In this section, we generalise our results and show that we can solve all [ρ, σ]-domination problems with finite or cofinite ρ and σ in O∗ (sk ); this includes existence, minimisation, maximisation, and counting variants of the problems. For the [ρ, σ]-dominating problems one could use states ρj and σj , where ρj and σj represent vertices in or not in the [σ, ρ]-dominating set D, respectively, that have j neighbours in D. For finite ρ, σ we can suffice with states {ρ0 , . . . , ρp , σ0 , . . . , σq }. If ρ or σ is cofinite, we replace the last states by ρ≥p or ρ≥q , respectively. For readability reasons, we restrict ourselves to finite ρ and σ. In our algorithm, the meaning of these states is slightly different: the subscript j of states ρj and σj will count only the number of neighbours in the
574
J.M.M. van Rooij, H.L. Bodlaender, and P. Rossmanith
[ρ, σ]-dominating set D that have already been forgotten by the algorithm. This prevents us from having to keep track of any adjacencies within a bag during a join operation; we can update these subscripts j easily in each forget bag. Dynamic programming tables for the [ρ, σ]-domination problems can also be represented using different sets of states that contain the same information. Lemma 3. A table A(c, κ) containing the number of [ρ, σ]-dominating sets of size κ corresponding to the colouring c on a bag of size k contains the same information independent of the following choices of states: – Set I: {ρ0 , ρ1 , ρ2 , . . . , ρp , σ0 , σ1 , σ2 , . . . , σq }. – Set II: {ρ0 , ρ≤1 , ρ≤2 , . . . , ρ≤p , σ0 , σ≤1 , σ≤2 , . . . , σ≤q }. The identifiers of the states are self explaining: ρcondition , σcondition considers the number of [ρ, σ]-dominating sets D that do not contain (ρ state) or do contain (σ state) this vertex with a number of neighbours in D satisfying the condition. Proof (Sketch). Repeatedly apply transformations as in Lemma 2.
In the proof of Theorem 2, we expanded the child tables to A(c, i), where i was an index indicating the number of 1 states used to create the ? states in c. We need to generalise this to more states to prove our result. To this end, we introduce an index vector i = (iρ1 , iρ2 , . . . , iρp , iσ1 , iσ2 , . . . , iσq ), where iρj and iσj index the sum of the number of neighbours in D of the vertices with state ρ≤j and σ≤j , respectively. We say that a solution corresponding to a colouring c using state set I (Lemma 3) satisfies a combination of a colouring c using state set II and an index vector i if: c is counted in c , and for each iρj , iσj , the sum of the number of neighbours in D in the colouring c for vertices which have colour ρ≤j and σ≤j in c equal iρj and iσj , respectively. We explain this by example. Suppose that we have a bag of size 3 and use states {ρ0 , ρ1 , ρ2 , σ0 } which we want to transform to states {ρ0 , ρ≤1 , ρ≤2 , σ0 }; thus i = (iρ1 , iρ2 ). A partial solution with states c = (ρ0 , ρ1 , ρ2 ) will be counted in both c1 = (ρ0 , ρ≤2 , ρ≤2 ) and c2 = (ρ≤1 , ρ≤1 , ρ≤2 ). In this case, c satisfies the combination (c1 , i = (0, 3)) but no combination of c1 with an other index vector. Also, c satisfies the combination (c2 , i = (1, 2)) and no other combination involving c2 . What we need is a table containing, for each possible combination of a colouring using state set II with an index vector, the number of partial solutions that satisfy these. We can do this by using the following lemma. Lemma 4. Given a table A(c, κ) containing the number of [ρ, σ]-dominating sets of size κ corresponding to the colouring c on a bag of size k using states set I from Lemma 3, we can compute a table A(c, κ, i) containing the number of solutions of size κ satisfying the combination of a colouring using state set II from Lemma 3 and the index vector i in O(nk 2 (sk)s−2 sk ) time. Proof. We start with the following table A(c, κ, i) using state set I: A(c, κ) if i is the all-0 vector A(c, κ, i) = 0 otherwise
Dynamic Programming on Tree Decompositions
575
Then, we change the states of the j-th coordinate at step j, similar to previous state changes, but now changing all states at this coordinate in one pass using the following formulas that also updates the index vector i: A(c1 × {ρ≤j } × c2 , κ, i) =
j
A(c1 × {ρk } × c2 , κ, iiρj →(iρj −k) )
k=0
A(c1 × {σ≤j } × c2 , κ, i) =
j
A(c1 × {σk } × c2 , κ, iiσj →(iσj −k) )
k=0
Here, iiρj →(iρj −k) is the vector i with the value of iρj set to iρj − k. The algorithm runs in k steps, computing a value for each of the sk colourings, n sizes, and s − 2 indices that range over sk values in a k-term sum. This gives a running time bounded by O(nk 2 (sk)s−2 sk ). Since we fix the specific [ρ, σ]-domination problem, this is O∗ (sk ) time. We are now ready to prove our main result of this section. Theorem 3. Let ρ, σ ⊆ N finite or cofinite. There exist an algorithm counting the number of [ρ, σ]-dominating sets of each size 0 ≤ κ ≤ n of a fixed [ρ, σ]domination problem involving s states in O∗ (sk ) time on graphs of treewidth k. Proof. We will only describe the join operation of the algorithm for finite σ, ρ. First, we transform the child tables to state set II (Lemma 3) using Lemma 4 obtaining tables AL (c, κ, l), AR (c, κ, r), where we have the extra index vectors indicating, for each state, the sum of the number of neighbours in D of the set of vertices with this state. Then, compute the table A(c, κ, i) by joining both tables combining identical states from both tables using the formula below. In this formula, we sum over all ways of getting a set of size κ by combining the sizes in the child tables and all ways of getting index vector i from i = r + l. ⎛ ⎞ ⎝ ··· AR (c, κR , r) · AL (c, κL , l)⎠ A (c, κ, i) = κL +κR −#1 (c)=κ
iρ1 =rρ1 +lρ1
iσq =rσq +lσq
A joined partial solution is counted in an entry in A (c, κ, i) if and only if it satisfies the following three conditions. – The sum of the number of neighbours in D of this joined solution on the ρ≤j and σ≤j states equals iρj and iσj , respectively. – The number of neighbours in D in both partial solutions used to create this joined solution on each of the ρ≤j and σ≤j states is at most j. – The total number of vertices in D in this joined solution is κ. Let Σρi (c), Σσi (c) be the weighted sums of the number of ρj and σj states with 0 ≤ j ≤ i in c, respectively, defined by: Σρi (c) =
i j=1
j · #ρi (c)
Σσi (c) =
i j=1
j · #σi (c)
576
J.M.M. van Rooij, H.L. Bodlaender, and P. Rossmanith
Now, using Lemma 3 we change states back to state set I to obtain a table A(c, κ, i) and extract the join table in the following way: A(c, κ) = A c, κ, (Σρ1 (c), Σρ2 (c), . . . , Σρp (c), Σσ1 (c), Σσ2 (c), . . . , Σσq (c)) We will now prove correctness of the entries in A(c, κ). An entry in A(c, κ) with c ∈ {ρ0 , σ0 }k is correct: these states are unaffected by the state changes and the index vector is not used. Now consider an entry in A(c, κ) with c ∈ {ρ0 , ρ1 , σ0 }k . Each ρ1 state comes from a ρ≤1 state in A (c, κ, i) and is a join of partial solutions with the following combinations of states on this vertex: (ρ0 , ρ0 ), (ρ0 , ρ1 ), (ρ1 , ρ0 ), (ρ1 , ρ1 ). Because we have changed states back to set I, each (ρ0 , ρ0 ) combination is counted in the ρ0 state on this vertex, and subtracted from the combinations used to from state ρ1 : the other tree combinations remain counted in the ρ1 state. Since we consider only those solutions with index vector iρ1 = Σρ1 (c), the total number of ρ1 states used to form this joined solutions equals Σρ1 (c) = #ρ1 (c). Therefore no (ρ1 , ρ1 ) combination could have been used, and each partial solution counted in A(c, κ) has exactly one neighbour in D on each of the ρ1 states. We repeat this argument for the other states, but omit the details. This proof generalises ideas from the fast subset convolution algorithm; while convolutions use ranked M¨ obius transforms, we use transformations with multiple ranks and multiple states. The polynomial factors in the proof of Theorem 3 can be improved in several ways, some of which resemble Corollaries 1 and 2.
7
Conclusion
In this paper, we have introduced the use of fast subset convolutions and generalisations of these to speed up the running time of algorithms on tree decompositions. Our techniques can be applied to a large number of problems, and in our paper, we have given a few of such examples, but it is not hard to find more applications. We give one set of such results without proof. Because each of the problems is finite integer index, the running time is linear in n. Proposition 2. The Maximum Triangle Packing, Partition into Triangles, Partition into -cliques for fixed and Minimum Clique Partition can be solved in O(poly(k)2k n) time on graphs of treewidth k. Our algorithms are in a certain sense optimal concerning the exponential dependency on the width of the tree decomposition, as the running times equal a polynomial in n and k times the ‘usual’ size of the dynamic programming tables. However, we have to pay: this exponential improvement goes with extra polynomial factors. In some cases, the pay is little, e.g., for Dominating Set, we improve the O(4k n) time [2] to O(k 2 3k n), but this is not always the case. We end with a few directions for further research. An experimental study on these algorithms would be very interesting. Other questions are: is it possible to use similar techniques to speed up algorithms on branch decompositions? Is it
Dynamic Programming on Tree Decompositions
577
possible to use generalisations of fast subset convolution to speed up algorithms on (tree or branch decompositions of) planar graphs, as in [12]? Acknowledgements. The first author thanks Jan Arne Telle and Jesper Nederlof for several very useful discussions.
References 1. Alber, J., Bodlaender, H.L., Fernau, H., Kloks, T., Niedermeier, R.: Fixed parameter algorithms for dominating set and related problems on planar graphs. Algorithmica 33, 461–493 (2002) 2. Alber, J., Niedermeier, R.: Improved tree decomposition based algorithms for domination-like problems. In: Rajsbaum, S. (ed.) LATIN 2002. LNCS, vol. 2286, pp. 613–627. Springer, Heidelberg (2002) 3. Bj¨ orklund, A., Husfeldt, T., Kaski, P., Koivisto, M.: Fourier meets M¨ obius: Fast subset convolution. In: Proceedings of the 39th Annual Symposium on Theory of Computing, STOC 2007, pp. 67–74 (2007) 4. Bodlaender, H.L.: A linear time algorithm for finding tree-decompositions of small treewidth. SIAM J. Comput. 25, 1305–1317 (1996) 5. Bodlaender, H.L.: A partial k-arboretum of graphs with bounded treewidth. Theor. Comp. Sc. 209, 1–45 (1998) 6. Bodlaender, H.L., Koster, A.M.C.A.: Combinatorial optimization on graphs of bounded treewidth. The Computer Journal 51(3), 255–269 (2008) 7. Bodlaender, H.L., Koster, A.M.C.A.: Treewidth computations I. upper bounds. Technical Report UU-CS-2008-032, Department of Information and Computing Sciences, Utrecht University, Utrecht, the Netherlands, Submitted (2008) 8. Bodlaender, H.L., van Antwerpen-de Fluiter, B.: Reduction algorithms for graphs of small treewidth. Information and Computation 167, 86–119 (2001) 9. Dorn, F.: Dynamic programming and fast matrix multiplication. In: Azar, Y., Erlebach, T. (eds.) ESA 2006. LNCS, vol. 4168, pp. 280–291. Springer, Heidelberg (2006) 10. Dorn, F.: How to use planarity efficiently: New tree-decomposition based algorithms. In: Brandst¨ adt, A., Kratsch, D., M¨ uller, H. (eds.) WG 2007. LNCS, vol. 4769, pp. 280–291. Springer, Heidelberg (2007) 11. Dorn, F., Fomin, F.V., Thilikos, D.M.: Catalan structures and dynamic programming in h-minor-free graphs. In: Proceedings of the 18th Annual ACM-SIAM Symposium on Discrete Algorithms, SODA 2008, pp. 631–640 (2008) 12. Dorn, F., Penninkx, E., Bodlaender, H.L., Fomin, F.V.: Efficient exact algorithms on planar graphs: Exploiting sphere cut branch decompositions. In: Brodal, G.S., Leonardi, S. (eds.) ESA 2005. LNCS, vol. 3669, pp. 95–106. Springer, Heidelberg (2005) 13. F¨ urer, M.: Faster integer multiplication. In: Proceedings of the 39th Annual Symposium on Theory of Computing, STOC 2007 (2007) 14. Kloks, T.: Treewidth. Computations and Approximations. LNCS, vol. 842. Springer, Heidelberg (1994) 15. Telle, J.A.: Complexity of domination-type problems in graphs. Nordic J. Comput. 1, 157–171 (1994) 16. Telle, J.A., Proskurowski, A.: Algorithms for vertex partitioning problems on partial k-trees. SIAM J. Disc. Math. 10, 529–550 (1997)