Faster Algorithms on Branch and Decompositions

Hans L. Bodlaender1, Erik Jan van Leeuwen2, Johan M.M. van Rooij1, and Martin Vatshelle2

1 Department of Information and Computing Sciences, Utrecht University P.O. Box 80.089, NL-3508 TB Utrecht, The Netherlands {hansb,jmmrooij}@cs.uu.nl 2 Department of Informatics, University of Bergen P.O. Box 7803, N-5020 Bergen, Norway {E.J.van.Leeuwen,martin.vatshelle}@ii.uib.no

Abstract. We combine two techniques recently introduced to obtain faster dynamic programming algorithms for optimization problems on graph decompositions. The unification of generalized fast subset convo- lution and fast matrix multiplication yields significant improvements to the running time of previous algorithms for several optimization prob- ∗ ω k lems. As an example, we give an O (3 2 ) time algorithm for Minimum Dominating Set on graphs of branchwidth k, improving on the previous O∗(4k) algorithm. Here ω is the exponent in the running time of the best matrix multiplication algorithm (currently ω<2.376). For graphs of cliquewidth k,weimprovefromO∗(8k)toO∗(4k). We also obtain an algorithm for counting the number of perfect matchings of a graph, ∗ ω k given a branch decomposition of width k, that runs in time O (2 2 ). Generalizing these approaches, we obtain faster algorithms for all so- called [ρ, σ]-domination problems on branch decompositions if ρ and σ are finite or cofinite. The algorithms presented in this paper either attain or are very close to natural lower bounds for these problems.

1 Introduction

Graph decompositions have over the last few years shown their worth in attack- ing NP-hard graph optimization problems. Most of this success is due to tree decompositions, which form the basis of results in many areas, from approxi- mation algorithms to exact algorithms and have become part of any algorith- mic toolbox. This success has motivated researchers to define and study other types of graph decompositions that are ‘better’ than tree decompositions. In this paper, we investigate algorithms for optimization problems on two such de- compositions, namely branch decompositions and clique decompositions. By for the first time combining two recent techniques used in designing algorithms on graph decompositions, generalized fast subset convolution and fast matrix mul- tiplication, in conjunction with the use of asymmetric vertex states, we obtain significant improvements on previous results.

P. Hlinˇen´yandA.Kuˇcera (Eds.): MFCS 2010, LNCS 6281, pp. 174–185, 2010. c Springer-Verlag Berlin Heidelberg 2010 Faster Algorithms on Branch and Clique Decompositions 175

Algorithmic Techniques. Fast subset convolutions were introduced by Bj¨orklund et al. [1] to improve the running time of algorithms for optimization problems admitting a convolution-like recursive definition. These ideas were re- cently applied and generalized to show that a whole range of problems has faster algorithms on tree decompositions [16]. In particular, Van Rooij et al. [16] showed that Minimum Dominating Set has an O(n tw2(G)3tw(G)) time algorithm. Us- ing a generalized form of fast subset convolutions, they were able to obtain the fastest algorithms for a large class of so-called [ρ, σ]-domination problems. Matrix multiplication has been used for a much longer time as a basic tool for solving combinatorial problems. The best possible exponent in the running time of an algorithm performing multiplication of two n × n matrices is denoted by ω, i.e. the running time is O(nω). Currently we know that ω<2.376, due to an algorithm by Coppersmith and Winograd [4], but it is frequently hypothesized that ω = 2. Dorn [8] recently showed that matrix multiplication can also be used as a tool in solving many optimization problems on branch decompositions. One of the main results of this paper is that fast subset convolutions and fast matrix multiplication can be combined to obtain faster algorithms on branch decompositions for many optimization problems. Graph Decompositions. The notion of a branch decomposition was proposed by Robertson and Seymour as part of their graph minors project [12]. All of the recent results aimed at obtaining faster exact or fixed-parameter algorithms for Minimum Dominating Set on planar graphs and graphs excluding a fixed minor rely on branch decompositions [9,10,8]. The branchwidth and the treewidth of a graph are very closely related; the branchwidth of a graph is always less than its treewidth, but never by more than a factor 2/3. The notion of cliquewidth was first studied by Courcelle et al. [5]. Whereas the treewidth of the n-vertex clique is equal to n − 1, its cliquewidth is equal to 2. Moreover, the cliquewidth of a graph is always bounded by a function of its treewidth [6]. This makes cliquewidth an interesting graph parameter to consider on graphs where the tree- or branchwidth is too high for efficient algorithms. Our Results. In this paper, we improve on the currently best algorithms for Minimum Dominating Set on branch and clique decompositions. Dorn [8] showed that Minimum Dominating Set has an O(m 4k) time algorithm on branch de- compositions of width k. By combining fast subset convolution and fast matrix ω multiplication, we improve on this algorithm and obtain an O(mk2 3 2 k)time algorithm. A further innovation is the use of asymmetric vertex states.When combining two tables in this kind of dynamic programming algorithms, the set of vertex states used by these tables is always the same. We however use different states to obtain further speed-ups. This result extends to counting the number of dominating sets of each size. Another counting problem where we can apply this technique is counting the number of perfect matchings of a graph. This problem generalizes the problem of computing the permanent of a matrix and is a well-known #P-hard problem [15]. 176 H.L. Bodlaender et al.

We give an algorithm for this problem on branch decompositions, running in time 2 ω k O(mk 2 2 i×(n)), where i×(n) is the time to multiply two n-bit numbers. Using the ideas of these algorithms, we solve existence, minimization, maxi- mization and counting variations of all [ρ, σ]-domination problems with finite or ∗ ω cofinite σ and ρ in O (s 2 k) time, where s is the number of vertex states used. Examples of such problems are Strong Stable Set, Independent Dominating Set, Perfect Code, Induced Bounded Degree Subgraph, and p-Dominating Set. On clique decompositions, we report an even bigger improvement for Mini- mum Dominating Set. We present an O∗(4cw(G)) time algorithm improving the current best O∗(8cw(G)) time algorithm obtained in [3].

2 Preliminaries

A branch decomposition (T,l) of a graph G is a ternary tree T and a bijection l between the edges of G and the leaves of T . Associated with every edge e ∈ E(T ) is the middle set Xe of e, defined as the set of vertices in V(G) which have incident edges e1,e2 such that the leaves l(e1)andl(e2) are in different components of T − e.Thewidth of a branch decomposition is the size of the largest set Xe.The branchwidth bw(G) is the minimum width of a branch decomposition of G. Create a root of T as follows. Choose an edge e =(t, t) ∈ E(T ), subdivide it, and add a new vertex r to T adjacent to the vertex created in the subdivision. The middle set of each edge of the subdivision is set to Xe and the middle set of the edge incident to r is set to ∅.RootT at r.Givenanyedge(t, t)=e ∈ E(T ),  we can now speak of Te, which is the subtree of T induced by t, t ,andtheir  descendants. The root of Te is t or t , whichever is closer to r in T . Consider an arbitrary internal vertex v ∈ V (T )andlete, f, g be its incident edges, such that e connects to the parent of v (and f,g to the two children of v). We call f the left child of e and g the right child. Consider the middle sets Xe, Xf , Xg. Note that any vertex in at least one of these sets is in at least two of them. We can then partition Xe ∪ Xf ∪ Xg into four sets:

I = Xe ∩ Xf ∩ Xg L =(Xe ∩ Xf ) − I R =(Xe ∩ Xg) − IF=(Xf ∩ Xg) − I

Observe that I, L,andR partition Xe, I, L,andF partition Xf ,andI, R,and F partition Xg. We can now prove the following lemma. | ∪ ∪ | | | | | | | | |≤ 3 · Lemma 1. Xe Xf Xg = I + L + R + F 2 bw(G). The notion of cliquewidth is defined as follows. A k-expression combines any number of the following four operations:

– create a new labelled graph with one vertex labelled i ∈{1,...,k}, – relabel all vertices with label i to j (i = j), – connect all vertices with label i to all vertices labelled j (i = j), – take the disjoint union of two labelled graphs. Faster Algorithms on Branch and Clique Decompositions 177

The cliquewidth cw(G) of a graph G is the minimum k for which there is a k- expression that evaluates to a graph isomorphic to G. This definition can also be turned into a decomposition based on a rooted tree of degree at most three, labeling leaves of the tree by vertices of G and internal vertices by one of the above operations. We call this a clique decomposition. However, the definition of k-expressions is more useful in this paper. Given sets ρ, σ ⊆ N,a[ρ, σ]-dominating set is a subset D ⊆ V such that |N(v) ∩ D|∈ρ for every v ∈ V \ D and |N(v) ∩ D|∈σ for every v ∈ D.The [ρ, σ]-domination problems were introduced by Telle in [13,14] and form a large class of graph covering problems. Let i×(n) denote the time required to multiply two n-bit integers. Currently, log∗ n i×(n)=O(n(log n)2 ) [11]. Addition and subtraction take O(n)timeeach.

3 Dominating Set

This section gives a faster algorithm to compute a minimum dominating set of a graph using a branch decomposition. We start by describing an algorithm that is actually slower than the O∗(4k) time algorithm of Dorn [8], but which serves to simplify the presentation of our algorithm. Then we show how to improve it. The main ingredient of the algorithm are vertex states. For example, the fol- lowing states can be useful in the dominating set problem: 1 the vertex is in the dominating set 01 the vertex is not in the dominating set and it is dominated 00 the vertex is not in the dominating set and it is not dominated 0? the vertex is not in the dominating set and it might be dominated

An assignment of states to the vertices of some middle set Xe is called a coloring of this set. Depending on which vertex states we are allowed to use, a dominating set can induce several colorings on a set of vertices Xe. Initially we will only use vertex states 1, 00,and01. We will later see other combinations in use. Let (T,l) be a branch decomposition rooted at a vertex r as described before.  Xe For each edge (t, t )=e ∈ E(T ), we will compute a function Ae : {1, 01, 00} × [0 ...n] → N. Given a coloring c of the vertices in Xe and a number i ∈ [0 ...n], | | Ae(c, i) equals the number of dominating sets D of G[X(Te)] such that D = i andsuchthatD induces the coloring c on X .HereX(T )= X .Notice e e f∈Te f that although we speak of a dominating set, it may be so that some vertices in G[X(Te)] remain undominated. These vertices then have state 00 in c (or 0? if we would have used a different set of states). We can compute the functions Ae bottom-up over the tree T .Westartat edges e incident with leaves of T that are not the root. These leaves correspond to an edge of G. Hence G[X(Te)] is a two-vertex graph. In this case, we simply construct the function Ae by initializing all values to zero and then enumerating all subsets D of these two vertices. For each of these sets D we add 1 to each entry of Ae in which coloring c and size i corresponds to the set D. For any edge e not incident with a leaf, let f and g be its left and right child. Recall the definition of the sets I, L, R, F induced by Xe, Xf ,andXg.Given 178 H.L. Bodlaender et al. a coloring c,letc(I) denote the coloring of the vertices of I induced by c.We define c(L), c(R), and c(F ) similarly. Given a coloring ce of Xe,acoloringcf of Xf , and a coloring cg of Xg, we say that these colorings match if

– For any v ∈ I:eitherce(v)=cf (v)=cg(v) ∈{1, 00},orce(v)=01 while cf (v),cg(v) ∈{00, 01} and not cf (v)=cg(v)=00. (5 possibilities) – For any v ∈ F :eithercf (v)=cg(v) = 1, or cf (v),cg(v) ∈{00, 01} while not cf (v)=cg(v)=00. (4 possibilities) – For any v ∈ L: ce(v)=cf (v) ∈{1, 01, 00}. (3 possibilities) – For any v ∈ R: ce(v)=cg(v) ∈{1, 01, 00}. (3 possibilities)

Let im =#1(ce(I)) + #1(cf (F )) for any ce,cf ,cg,where#1(c)is the number of vertices that are assigned state 1 by c. Then we can count all dominating sets of G[X(Te)] per corresponding coloring ce on Xe using:   Ae(ce,ie)= Af (cf ,if + im) · Ag(cg,ig + im),

ce,cf ,cg match ie=if +ig +im

Proposition 1. Given a branch decomposition of width k of a graph G,onecan 2 k count the number of dominating sets of each size in O(mn 6 i×(n)) time.

Proof. We compute the functions Ae as described above. Let er denote the edge incident with the root of the branch decomposition. From the definition of Aer , ∅ Aer ( ,i) contains the number of dominating sets of size i in G. For all leaf edges e of T , we can compute Ae in O(n) time. For all other k edges, we have to compute O(n 3 ) values for Ae,eachofwhichrequiresO(n) terms of the above sum per set of matchings states. Since each vertex in I has 5 possible matching states, each vertex in F has 4 possible matching states, and each vertex in L or R has 3 possible matching states, this leads to a running 2 |I| |F | |L|+|R| time of O(n 5 4 3 i×(n)) for computing Ae. Under the constraint that |I| + |L| + |R|, |I| + |L| + |F |, |I| + |R| + |F |≤k, | | | | | | | | 1 the running time is maximal if I =0, L = R = F = 2 k.AsT has O(m) 2 1 k k 2 k edges, this leads to O(mn 4 2 3 i×(n)) = O(mn 6 i×(n)).

3.1 Using State Changes to Improve the Algorithm We start improving the above algorithm by using the state changes introduced in [16], based on the covering product from [1]. The algorithm of Proposition 1 uses vertex states 1, 01,and00. On tree decompositions, it has been shown that it is more efficient to transform the problem to one using states 1, 00,and0? [16]. We show that we can use similar transformations on branch decompositions. There is a big difference however between dynamic programming on both types of decompositions. On tree decompositions one can transform a tree de- composition such that forget vertices (the vertices in set F ) can be dealt with separately. This is not possible on branch decompositions, which makes the situ- ation more complicated. On branch decompositions vertices in F must be dealt with simultaneously while computing Ae, by merging the results from the two Faster Algorithms on Branch and Clique Decompositions 179 functions Af and Ag from e’s children. We will overcome this problem by using different sets of states simultaneously: the set of states used depends on whether avertexisinL, R, I or F . Moreover, we do this asymmetrically as different states can be used on the vertices in Xe, Xf and Xg. Xe In Proposition 1, we used functions Ae : {1, 01, 00} × [0 ...n] → N counting the number of solutions of a given type. We again consider constructing Ae k from Af and Ag as before. Given Af and Ag, we can compute in O(n 3 )time  { }L ×{ }I ×{ }F × → N a function Af : 1, 01, 00 1, 0?, 00 1, 01, 00 [0 ...n] and a  { }R ×{ }I ×{ }F × → N function Ag : 1, 01, 00 1, 0?, 00 1, 01, 0? [0 ...n] . The new functions again count the number of solutions that satisfy the coloring c, but in this case a single dominating set D can be counted in multiply colorings. Notice   the difference in the states used for Af and Ag on F .   Transforming Af into Af canbedonebyfirstcopyingAf into Af without changing the states in the domain and then coordinate-wise, for each vertex v ∈ I, iteratively transforming the states using the following formula:    Af (cv=0? ,i)=Af (cv=01 ,i)+Af (cv=00 ,i).

Here cv=x is the coloring c with the state of v set to x. This transformation is invertible as we can also coordinate-wise apply the following similar formula:   −  Af (cv=01 ,i)=Af (cv=0? ,i) Af (cv=00 ,i). We are now ready to give the first improvement of Proposition 1. Proposition 2. Given a branch decomposition of width k of G, one can count 2 3 k the number of dominating sets of each size in O(mn 3 2 i×(n)) time. Proof. The algorithm works similar to the one in Proposition 1, only with a different way of computing Ae from Af and Ag.   Given Af and Ag, we transform these to Af and Ag as shown above. Here  { } { }  Af uses the states 1, 0?, 00 on I and the states 1, 01, 00 on L and F and Ag   uses the same states on I and the same states on R as Af on L. However, Ag uses different states on F ,namely{1, 01, 0?}. Now two colorings match if:

– For any v ∈ I: ce(v)=cf (v)=cg(v) ∈{1, 0?, 00}. (3 possibilities) – For any v ∈ F :eithercf (v)=cg(v) = 1, or cf (v)=00 and cg(v)=01,or cf (v)=01 and cg(v)=0?. (3 possibilities) – For any v ∈ L: ce(v)=cf (v) ∈{1, 01, 00}. (3 possibilities) – For any v ∈ R: ce(v)=cg(v) ∈{1, 01, 00}. (3 possibilities) Notice the difference on I compared to Proposition 1. A vertex is not dominated (00) if and only if it is not so in both partial solutions we are combining, and the same for the states 0? and 1, as these do not care about domination. On F we only use combinations which allow the vertices to be ignored in the rest of the process: vertices that are either in the dominating set, or are dominated. Moreover, by   using different states for Af and Ag, every combination of partial solutions is counted exactly once. To see this, consider each of the three combinations on F used in Proposition 1. The combination with cf (v)=00 and cg(v)=01 is counted using the same combination, while the other two combinations (cf (v)= 01 and cg(v)=00 or cg(v)=01) are counted when combining 01 with 0?. 180 H.L. Bodlaender et al.

 { }L ×{ }I × In this way, we can compute the function Ae : 1, 01, 00 1, 0?, 00 R {1, 01, 00} × [0 ...n] → N using the following formula.     ·  Ae(ce,ie)= Af (cf ,if + im) Ag(cg,ig + im). (1)

ce,cf ,cg match ie=if +ig +im

2 |I|+|L|+|R|+|F | Using the new states, O(n 3 i×(n)) time is required to evaluate  the formula. After its evaluation, we reconstruct Ae from Ae by transforming it back to using states 1, 01 and 00 as described before. As each transforma- tion requires O(n 3k) additions, the improved algorithm has a running time of 2 |I|+|L|+|R|+|F | 2 3 k O(mn 3 i×(n)) = O(mn 3 2 i×(n)) by Lemma 1.

3.2 Using Fast Matrix Multiplication

We now apply fast matrix multiplication, as first proposed by Dorn [8]. This yields the fastest algorithm for dominating set on branch decompositions. For multiplying a (n × p)matrixA and (p × n)matrixB, we differentiate between p ≤ n and p>n. Under the condition that ω =2.376 (the best known bound [4]), an O(n1.85p0.54) time algorithm is known if p ≤ n [4]. Otherwise, the p ω ω−1 matrices can be multiplied in O( n n )=O(pn ) time by matrix splitting: p × p p the matrices A and B into n many n n matrices A1,...A and B1,...B , p × n n multiply each of the n pairs Ai Bi, and sum up the results. Theorem 1. Given a branch decomposition of width k of a graph G,onecan 2 ω k count the number of dominating sets of each size in O(mn 3 2 i×(n)) time.

Proof. Given a coloring of I and numbers ie and if , we show how to evaluate Equation 1 for all possible colorings on L, R,andF simultaneously using fast |L| |F | matrix multiplication. Construct a 3 × 3 matrix Mf where each row corre- sponds to a coloring of L and each column corresponds to a coloring of F .Let  the entries of Mf be the values of Af (cf ,if + im) for all cf corresponding to the colorings of L and F of the row and column, and corresponding to the fixed col- |F | × |R|  oring on I and the number if . Construct a similar 3 3 matrix Mg for Ag such that its rows correspond to different colorings of F and its columns of Mg  − correspond to different colorings of R.TheentriesofMg are Ag(cg,ie if ). We permute the rows of Mg such that column i of Mf and row i of Mg correspond to matching colorings on F and thus the value of im matchesaswell. Now we can compute Equation 1 by computing Me = Mf · Mg.Therowsof Me correspond to colorings of L and the columns correspond to colorings of R.  An entry of Me in row i and column j contains the value of Ae(ce,ie) as specified by Equation 1, where ce is the coloring induced by the coloring corresponding to row i and to column j and the coloring for I we fixed. Thus we can compute the  value of Ae(ce,ie)byaseriesofn matrix multiplications. Hence we can compute  2 |I| the function Ae by n 3 matrix multiplications.  | | | | | | | | The time required to compute Ae in this way depends on I , L , R , F . Under the constraint that |I| + |L| + |F |, |I| + |R| + |F |, |I| + |L| + |R|≤k Faster Algorithms on Branch and Clique Decompositions 181 and using the matrix multiplication algorithms described above this theorem, | | | | | | | | k the worst case arises when I =0and L = R = F = 2 .Inthiscase,we  k 2 2 ω compute each Ae in O(n (3 ) i×(n)) time. This proves the theorem. Using that dominating set has finite integer index [2] and by only storing the size of a minimum dominating set instead of counting, we prove the following. Corollary 1. Given a width k branch decomposition of a graph G, the size of a ω minimum dominating set of G can be found in O(mk2 3 2 k).

4 Counting Perfect Matchings

We give a fast algorithm counting the number of perfect matchings of a graph. Theorem 2. Given a branch decomposition of width k of a graph G,onecan 2 ω k compute the number of perfect matchings of G in O(mk 2 2 i×(n)) time. Proof. Given a branch decomposition (T,l) of a graph G, we again compute a table Ae for each e ∈ E(T ). Each vertex in Xe uses states {0, 1},whereavertex is in state 1 if and only if it is matched to some vertex in X(Te)byanedge in a leaf below e in T . Then for any coloring c of Xe, Ae(c)isthenumberof perfect matchings of the graph H =(V,E), where V = X(Te) − 0(c)andE equals the set of edges in leaves below e in T .Here0(c) is the set of vertices that ∅ are assigned state 0 by c. The number of perfect matchings then is Aer ( ). To join the tables Af and Ag of two middle sets Xf and Xg to compute table Ae for Xe, we compute a table Af (c, i) such that Af (c, i)=Af (c)if#1(c(I)) = i and 0 otherwise. A table Ag(c, i) is computed similarly. Applying state changes as in [16] and matrix multiplication in a similar way as before, we can compute 2 ω k Ae in O(mk 2 2 i×(n)) time. The parameter i is used to track matched vertices in spite of the state changes and ensures that no vertex is matched twice. This is similar to applying fast subset convolutions [1]. Details in the full paper.

5[ρ, σ]-Domination Problems

∗ ω We have shown how to solve two fundamental graph problems in O (s 2 k)time on branch decompositions of width k,wheres is the number of states used. Below, we generalize our results and show that one can solve all [ρ, σ]-domination ∗ ω problems with finite or cofinite ρ and σ in O (s 2 k) time. This includes the existence, minimization, maximization, and counting variants of the problems. For [ρ, σ]-domination problems, we use states ρj and σj ,whereρj and σj represent that a vertex is respectively in or not in the [σ, ρ]-dominating set D and has j neighbors in D. For finite ρ, σ, we use states {ρ0,...,ρp,σ0,...,σq}. If ρ or σ is cofinite, we replace the last state by ρ≥p or σ≥q, respectively. To simplify the exposition of the algorithm, we restrict our description to finite ρ and σ. Note that the number of states used equals s = p + q +2. We can essentially use the approach of [16] for the vertices in I.Wethusdo not repeat the details here and treat it more or less as a black box below. 182 H.L. Bodlaender et al.

There are two things we need to know however about this black box. First, the approach ensures that colorings ce, cf , cg match on I if they are the same on I. Therefore, if for any fixed coloring on I we can perform a join operation on L, R, ∗ |L| |R| |F | ∗ |L| |R| |F | |I| and F in O (α β γ ) time, then we can construct Ae in O (α β γ s ) time. Secondly, we need to know how this black box keeps track of the number of neighbors in D of each vertex in the partial solutions that we are combining. This works in the following way: if we combine two partial solutions with states ρi and ρj on a vertex v ∈ I, then the resulting combination will have state ρi+j on v. This is important because this can lead to errors in the following sense. If v has a neighbor u ∈ D in both partial solutions, then this neighbor is counted in both i and j, and combining these partial solutions to one with state ρi+j is incorrect as u can now be counted twice.

Theorem 3. Let ρ, σ ⊆ N be finite or cofinite, and let s be the number of states used in the given representation of the associated [ρ, σ]-domination prob- lem. Then, given a branch decomposition of width k of a graph G,onecan ∗ ω compute the number of [ρ, σ]-dominating sets of G of each size in O (s 2 k) time.

Proof. In this proof, we use the approach of [16] as a black box to combine solutions on I. We use states ρj and σj for Ae, Af ,andAg such that the subscripts j represent the number of neighbors in each [σ, ρ]-dominating set D outside Xe, Xf and Xg, respectively. Because the black box uses the principle that ρi and ρj are combined to ρi+j on I, we first perform some preprocessing.    We construct functions Af and Ag identical to Af and Ag with states ρi and    σi such that the subscripts of the states used in Af and Ag count the number of neighbors in D with the following properties:  − ∪ – States used in Af on vertices in L or I count neighbors in (X(Tf ) Xf ) F .  − ∪ ∪ – States used in Af on vertices in F count neighbors in (X(Tf ) Xf ) L I.  − ∪ – States used in Ag on vertices in R count neighbors in (X(Tg) Xg) F .  − ∪ – States used in Ag on vertices in F count neighbors in (X(Tg) Xg) R.   If we then combine partial solutions with, for a vertex in I,astateρi in Af and     a state ρj in Ag, then the new state ρi+j in Ae correctly counts the number of neighbors on (X(Te)−Xe). Also, states for vertices in L and R in Ae count their neighbors in F ∩ D. And, if we combine solutions with for a vertex in F a state     ρi in Af and a state ρj in Ag, then this vertex will have exactly i + j neighbors  in D. Hence the resulting Ae equals the function Ae we want to compute.     We construct Af from Af by setting Af (cf ,i)toAf (cf ,i), where cf is ob-   tained from cf asspecifiedabove,orto0ifnosuchcf exists. Finding cf from cf is straightforward. For example, if in a coloring cf avertexv ∈ F has state ρj,  then in cf this vertex must have state ρj−d,whered is the number of neighbors ∪  of v in L I that have state σi for some i.WeconstructAg from Ag in the same way, keeping in mind the difference in states used. Using the combination on I as a black box, what remains is the combination   of Af and Ag on L, R,andF . For a fixed coloring of I, we combine all possible colorings on L, R,andF simultaneously using fast matrix multiplication. To Faster Algorithms on Branch and Clique Decompositions 183 do so, we permute the rows and columns of the matrices such that the part of   a coloring cf for Af on F is combined with a unique coloring cg for Ag on F .  To this end, we transform the states on Ag to different states. We thus obtain asymmetric states, similar to the algorithm for dominating set.  {     } For colorings cg for Ag on F , we transform state set ρ0,...,ρp,σ0,...,σq {     }  to the set ρ0¯,...,ρp¯,σ0¯,...,σq¯ .Hereρ¯j is used for a vertex that is not in D ∈  and has i neighbors in D such that j + i ρ,andσ¯j is used for a vertex that is in D and has i neighbors in D such that j + i ∈ σ. These transformations take O∗(s|F |+1) time by applying the following formu- ∗  las coordinate-wise to a copy Ag of the function Ag.   ∗ ∗ ∗ ∗ A (cv=ρ )= A (cv=ρ ) A (cv=σ )= A (cv=σ ). g ¯j g i g ¯j g i i+j∈ρ i+j∈σ    ∗ Notice that if we combine a state ρj from Af with a state ρ¯j from Ag, then valid combinations in which this vertex is not in the set D are counted. The same    ∗ goes with σj from Af with a state σ¯j from Ag for vertices in D. We can now, for a fixed coloring on I, construct two matrices as before. ∗ |I| |L| |F | Computing Ae this way requires O (s ) matrix multiplications of a s × s | | | | ∗ ω matrix and a s F × s R matrix. This gives a running time of O (s 2 k).

6 Cliquewidth

On graphs of bounded cliquewidth, we show how to improve from O∗(8k)time obtained previously [3] to O∗(4k) time for computing Minimum Dominating Set. Theorem 4. Given a k-expression for a graph G, one can compute the number 3 2 k of dominating sets of G of each size in O(n (k + i×(n)) 4 ) time. Proof. An operation in a k-expression applies a procedure on labelled graph H, transforming it to a graph H. In the case of the union-operation, the operation takes two labelled graphs H1 and H2 as an input and combines them to a graph H. For a labelled graph H,weuseVi to denote the set of vertices in H with label i. In contrast to the algorithm on branch decompositions, we do not assign states to individual vertices, but assign them to the sets V1,...,Vk instead. To each Vi, we assign two attributes, inclusion and domination. The first determines whether at least one vertex of Vi is included in a partial solution. We use states T , F , ? to indicate whether this is true, false, or optional respectively. The second attribute determines whether all vertices of Vi are dominated in a partial solution. We use states T , F , ? to indicate whether this is true, false, or optional respectively. The states we use are a combination of both attributes. For any graph constructed in the k-expression, we will compute a table A(c, κ) which stores the number of partial solutions to the dominating set problem of size κ that induce the coloring c. Consider the first operation, creating a labelled graph H with one vertex with label i. Assume w.l.o.g. that i = k and let c be the coloring of V1,...,Vi−1 such that the first attribute is F and the second attribute is T for all labels. Then A(c × (T,T), 1) = A(c × (F, F), 0) = 1. All other entries of A are 0. 184 H.L. Bodlaender et al.

The second operation relabels vertices with label j to label i.IfVi = ∅ or Vj = ∅, this is trivial. Otherwise (w.l.o.g. i = k and j = k − 1),   A(c × (r, r) × (s, s),κ)= A(c × (t, t) × (u, u),κ) t∨u=s t∧u=s  if ¬r ∧ r , and 0 otherwise, where c is any coloring of V1,...,Vj−1. Note that for Vj, the first attribute is F and the second is T in any valid partial solution. If Vi must have a vertex in the dominating set, then it is in Vi or Vj originally. If all vertices in Vi must be dominated, all vertices in Vi and Vj must be dominated. The third operation connects all vertices with label i to all with label j.IfVi or Vj is ∅, this is trivial. Otherwise (w.l.o.g. i = k and j = k − 1),   A(c × (r, r) × (s, s),κ)= A(c × (r, t) × (s, u),κ) t∨s=r u∨r=s where c is any coloring of V1,...,Vj−1.IfVi and Vj are connected and Vi (resp. Vj) contains a vertex in the dominating set, then Vj (resp. Vi) is dominated. The fourth operation joins two labelled graphs H1 and H2 with tables A1 and A2 to a labelled graph H with table A. To do this efficiently, we apply state changes. We use states F and ? for the first attribute and states T and ? for the ∗ ∗ second attribute. Changing A1 and A2 to tables A1 and A2 that use these states ∗ can be done in a similar manner as before. Then A can be computed using: ∗ κ ∗ · ∗ − A (c, κ)= i=0 A1(c, i) A2(c, κ i). Using the inverse state change formulae, 2 k we obtain A.EachoftheO(n) union operations takes O(n 4 i×(n)) time, each of the O(nk2) other operations takes O(n2 4k)time. Although Minimum Dominating Set has finite integer index, it is not clear what this implies for k-expressions. Using other arguments, we can still prove that for computing the number of minimum dominating sets, the table only needs to store sets of size at most 2k larger than the minimum set. Theorem 5. Given a k-expression for a graph G, one can compute (the size of) a minimum dominating set of G in O(nk2 4k) time.

7 Conclusions

We presented a novel combination of existing techniques to improve on algo- rithms for graph optimization problems using graph decompositions. In partic- ∗ ω · ∗ ular, we gave an O (3 2 bw(G))andanO (4cw(G)) algorithm for Minimum Dom- inating Set. These algorithms extend immediately to their counting variant. We ∗ ω · also showed an O (2 2 bw(G)) algorithm for counting perfect matchings. ∗ ω · On planar graphs, an O (3 2 bw(G)) algorithm was presented before [8], using so-called sphere cut branch decompositions [7]. This paper shows that this special branch decomposition is no longer necessary to obtain the fastest algorithm√ for ∗ 3.99· n Minimum Dominating Set on planar graphs. In particular, we get√ an O (2 ) time algorithm for Planar Dominating Set and an O∗(211.98· k) algorithm for its parameterized version, using results of Fomin and Thilikos [9,10]. Faster Algorithms on Branch and Clique Decompositions 185

The results of this paper attain, or are close to, what seem natural limits to techniques commonly used for these problems, namely the amount of space used by any dynamic programming algorithm for these problems on graph de- compositions. This currently is O(3k) for Minimum Dominating Set on branch decompositions and O(4k) on clique decompositions. Also, the number of states used seems the best possible base of the exponent in the running time. Our re- sult for Minimum Dominating Set on clique decompositions attains this bound. On branch decompositions, we are very close (the base of the exponent is 3.688) and under the hypothesis that ω = 2, we attain this bound. Can we get an O∗(3bw(G)) time algorithm for Minimum Dominating Set in another way?

References

1. Bj¨orklund, A., Husfeldt, T., Kaski, P., Koivisto, M.: Fourier meets M¨obius: Fast Subset Convolution. In: STOC 2007, pp. 67–74. ACM, New York (2007) 2. Bodlaender, H.L., van Antwerpen-de Fluiter, B.: Reduction algorithms for graphs of small treewidth. Inform. Comput. 167, 86–119 (2001) 3. Bui-Xuan, B.-M., Telle, J.A., Vatshelle, M.: Boolean-width of graphs. In: Chen, J., Fomin, F.V. (eds.) IWPEC 2009. LNCS, vol. 5917, pp. 61–74. Springer, Heidelberg (2009) 4. Coppersmith, D., Winograd, S.: Matrix Multiplication via Arithmetic Progressions. J. Symbolic Comput. 9, 251–280 (1990) 5. Courcelle, B., Engelfriet, J., Rozenberg, G.: Handle-rewriting hypergraph gram- mars. J. Comput. System. Sci. 46(2), 218–270 (1993) 6. Courcelle, B., Olariu, S.: Upper bounds on the clique-width of graphs. Discrete Appl. Math. 101, 77–114 (2000) 7. 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.)ESA2005.LNCS,vol.3669,pp.95–106.Springer,Heidelberg(2005) 8. 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) 9. Fomin, F.V., Thilikos, D.M.: Dominating Sets in Planar Graphs: Branch-width and Exponential Speed-up. In: SODA 2003, pp. 386–397. ACM, New York (2003) 10. Fomin, F.V., Thilikos, D.M.: A simple and fast approach for solving problems on planar graphs. In: Diekert, V., Habib, M. (eds.) STACS 2004. LNCS, vol. 2996, pp. 56–67. Springer, Heidelberg (2004) 11. F¨urer, M.: Faster Integer Multiplication. In: STOC 2007, pp. 57–66. ACM, New York (2007) 12. Robertson, N., Seymour, P.D.: Graph minors. X. Obstructions to tree- decomposition. J. Combin. Theory B 52(2), 153–190 (1991) 13. Telle, J.A.: Complexity of Domination-Type Problems in Graphs. Nordic J. Com- put. 1, 157–171 (1994) 14. Telle, J.A., Proskurowski, A.: Algorithms for Vertex Partitioning Problems on Par- tial k-Trees. SIAM J. Discrete Math. 10, 529–550 (1997) 15. Valiant, L.G.: The Complexity of Computing the Permanent. Theor. Comput. Sci. 8, 189–201 (1979) 16. van Rooij, J.M.M., Bodlaender, H.L., Rossmanith, P.: Dynamic Programming on Tree Decompositions Using Generalised Fast Subset Convolution. In: Fiat, A., Sanders, P. (eds.) ESA 2009. LNCS, vol. 5757, pp. 566–577. Springer, Heidelberg (2009)