Composing dynamic programming tree-decomposition-based algorithms

# Composing dynamic programming tree-decomposition-based algorithms

Julien Baste Institute of Optimization and Operations Research, Ulm University, Ulm, Germany.
###### Abstract

Given two integers and as well as graph classes , the problems , , and ask, given graph as input, whether , , respectively can be partitioned into sets such that, for each between and , , , respectively. Moreover in , we request that the number of edges with endpoints in different sets of the partition is bounded by . We show that if there exist dynamic programming tree-decomposition-based algorithms for recognizing the graph classes , for each , then we can constructively create a dynamic programming tree-decomposition-based algorithms for , , and . We show that, in some known cases, the obtained running times are comparable to those of the best know algorithms.

Keywords: graph partition; treewidth; parameterized complexity; dynamic programming; dynamic programming core model.

## 1 Introduction

In one well-known graph partition problem, one is asked, given a graph and an integer , whether can be partitioned into sets such that the number of edges between two different sets is small. These problems have many applications starting from clustering genes, through optimizing financial problems, parallel scientific computing to image segmentation, and analysis of social networks. The above specified graph partitioning problem favors cutting small sets of isolated vertices in the input graph [ShMa2000, WuLe1993]. In order to avoid this kind of solutions which is often undesirable for many practical applications, restrictions are often imposed on the sets , . The most natural restriction is to require the partition to be balanced [AnRa2006]. Another one, used in image segmentation, is to consider normalized cuts [ShMa2000], that is, cuts that maximize the similarity within the sets while minimizing the dissimilarity between the sets. In social networks, the graph clustering problem is a graph partition problem where the graphs , , are required to be dense [Sc2007]. In this paper, we consider the graph partition problem in a general form defined in the following way. Given graph classes and an integer , the problem consists in, given a graph , determining whether can be partitioned into sets such that , i.e., the set of transversal edges, is of size at most and for each .

Coloring problems are special kinds of graph partition problems where the number of transversal edges is not relevant anymore. So, in the problem, the task is to determine whether the vertex set of the input graph can be partitioned into sets such that for each . The most famous coloring problem is the Graph -Colorability problem corresponding to where is the class of edgeless graphs. This problem is one of the first problems proved by Karp to be NP-hard [Ka1972] and has attracted a lot of attention. If Graph -Colorability is the best known, several other graph classes are also under study. For instance, in [YaYu2004, RaSh2013, YuWa2003], the authors consider the induced matching partition where each vertex set of the partition should induce a graph of maximum degree . In [ChChCh2004], the authors focus on where is a fixed integer, , and is either the class of every tree or the class of every forest. These problems are called Tree Arboricity when is the class of every tree and Vertex Arboricity when is the class of every forest. They provide polynomial time algorithms for block-cactus graph, series-parallel graphs, and cographs. In [YaYu2007], the authors focus on planar graph of diameter two. These problems have in particular applications in bioinformatics for constructing phylogenetic trees [JaJoKeStWu2018].

The treewidth of a graph is a structural parameter that measures the similarity of the graph to a forest. Courcelle [Co1990] shows that every problem that can be expressed in monadic second-order logic can be solved in FPT-time parameterized by treewidth, i.e., in time for some function where (resp. ) denotes the size (resp. treewidth) of the input graph. In [Ra2007], the author shows that if there is a monadic second-order logic formula that recognizes a graph class , then for any fixed integer , , with for all , can be solved in polynomial time on graphs of bounded treewidth. If [Co1990] and [Ra2007] provide powerful meta-algorithms, the claimed running times may be far from being optimal. For instance, the Courcelle theorem [Co1990] provides an algorithm for Graph -Coloring when it is well known that an algorithm exists [CyFoKoLoMaPiPiSa2015].

Recently, treewidth has found several applications in bioinformatics when dealing with the so-called display graphs [BrLa2006, ScIeKeBr2014, fvBaPaSaSc2017]. In a recent paper [JaJoKeStWu2018], the authors are interested in determining whether a given graph of bounded treewidth is a positive instance of where is the class of all trees, and they provide an algorithm using Courcelle’s theorem.

The dynamic programming core model, introduced in [arBaFeJaOlRo2019], is a new formalism that describes what is a dynamic programming algorithm that process a tree decomposition, once, in a bottom-up approach. The authors use this model in order to construct meta-algorithms for what they called diverse problems.

In the present paper, we use the expressive power of this formalism and show that, with some small refinements, it can be used to provide algorithms, with good running times, that solve the graph partition problems parameterized by treewidth. Roughly speaking, given graph classes , we show that solving or is not much harder than recognizing each , using a dynamic programming tree-decomposition-based algorithm. Moreover, we provide the explicit running time needed for solving and using the running time needed for recognizing each . We provide similar result for the case where we want to partition the edge set of the graph, that is, for the graph problem that, given a graph , consists in determining whether can be partitioned into sets such that for each .

The main feature of our contribution is to describe a meta-approach that leads to algorithms whose running times are comparable to the best-known algorithms specifically designed for the individual problems.

In Section 2, we introduce the notations and useful definitions. Section 3 is devoted to the definition of the dynamic programming core model together with some examples of dynamic cores. The main results are given in Section 4. In Section 5, we show how theses results can be applied to reproduce known results and to provide unknown algorithms. We provide a short conclusion in Section 6.

## 2 Preliminaries

We denote by the set of integers. Given two integers and we define the set of every integer such that . Let be a graph. Let be an integer and be a -uplet. For each , we use the notation to refer to the -th coordinate of , i.e., in this case to . Note that the coordinates are numbered from to . Given an alphabet , we denote by the set of every finite set of finite words over . We denote by the set of three special letters denoted “(”, “)”, and “,”.

We use and to denote the vertex and edge sets, respectively, of the graph . Through this paper, we assume that vertices are represented as elements of . Given a set , we denote by the subgraph of induced by . Given a set , we denote by the graph . Given two sets , we denote by the set of every edge of with one endpoint in and the other endpoint in . We also denote by the set of every graph. Given an integer , we denote by the class of every graph of size at most . We also denote by the set of every tree and by the set of every forest. Given a tree rooted at , for each , we denote by the set of every child of in and by the set of every descendent of in .

A rooted tree decomposition of a graph is a tuple , where is a tree rooted at and is a collection of subsets of such that:

• ,

• for every edge , there is a such that , and

• for each such that lies on the unique path between and in , .

The width of a tree decomposition , denoted by , is defined as The treewidth of a graph , denoted by , is the smallest integer such that there exists a tree decomposition of of width at most . We also define and .

It is well known, see for instance [Kl1994], that given a rooted tree decomposition , we can, without loss of generality, assume that , that, for each , has at most children and that . In the following we always assume that the rooted tree decompositions have these properties.

Given a graph , a rooted tree decomposition of , and a set , we define to be . Note that is a rooted tree decomposition of .

## 3 Dynamic programming core model

In this section we use a small variation of the dynamic programming core model introduced in [arBaFeJaOlRo2019]. The main idea of this model is to formalize what is a dynamic programming algorithm based on a tree decomposition. This will allows us to manipulate these algorithms in there generic form in order to construct meta-algorithms.

###### Definition 1 (Dynamic Core).

A dynamic core over an alphabet is a set of four functions:

• ,

• ,

• , and

• .

In the following, we always assume that the associated alphabet is implicitly given when a dynamic core is mentioned and we denote by the alphabet associated to a dynamic core . Given a dynamic core , a graph and a rooted tree decomposition of , the data of associated to are, for each :

 AcceptC,G,D =Accept(G[Xr]) ProcessC,G,D(t) =⎧⎪⎨⎪⎩ProcessC,0(G[Xt])% if child(t)=∅,ProcessC,1(G[Xt],G[Xt′])if child(t)={t′}, andProcessC,2(G[Xt],G[Xt′],G[Xt′′])if child(t)={t′,t′′}.

Given a function and an input , we denote by the time needed to compute . Given a dynamic core , a graph and a rooted tree decomposition we let:

 τ(C,G,D,t) =⎧⎪⎨⎪⎩maxA⊆Ytτ(ProcessC,0(G[A∩Xt]))if child(t)=∅,maxA⊆Ytτ(ProcessC,1(G[A∩Xt],G[A∩Xt′]))if child(t)={t′}, andmaxA⊆Ytτ(ProcessC,2(G[A∩Xt],G[A∩Xt′],G[A∩Xt′′]))if child(t)={t′,t′′}.

We also define and . Note that, for each , . We say that a dynamic core is polynomial, if for each graph , each rooted tree decomposition of , and each , and are polynomial.

###### Definition 2.

Let be a dynamic core, be a graph in , and be a rooted tree decomposition of . A -witness is a function such that and for each ,

 ∈ProcessC,G,D(t)

The witness provided in Definition 2 can be seen as a proof of correction of the algorithms we can produce using a given dynamic core.

###### Definition 3.

Let be a class of graphs. We say that a dynamic core solves if for each graph , and each rooted tree decomposition of , if and only if a -witness exists.

As explained in [arBaFeJaOlRo2019] and summarized in Theorem 4, a dynamic core can be seen as an algorithm producer. Moreover the running time of the produced algorithms is directly connected to the definition of the associated dynamic core.

###### Theorem 4 ([arBaFeJaOlRo2019]).

Let be a class of graphs and be a dynamic core that solves . Given a graph and a rooted tree decomposition of , one can decide whether in time .

### 3.1 Some examples of dynamic core

In this section we provide few examples of dynamic cores. We start by a dynamic core that solves , the class of graphs with no edges.

###### Observation 5.

can be solved by a polynomial dynamic core .

###### Proof.

We define such that for each ,

 AcceptC(G) ={⊤} ProcessC,0(G) ={⊤∣E(G)=∅} ProcessC,1(G,G′) ={(⊤,⊤)∣E(G)=∅} ProcessC,2(G,G′,G′′) ={(⊤,⊤,⊤)∣E(G)=∅}

In this case, where represents the fact that the already explored part does not contain any edge. For the running time, note that given a graph and a rooted tree decomposition of , then for each , and . ∎

We also provide a bit more involved dynamic core that solves for some integer , i.e, the class of graph with at most vertices.

###### Observation 6.

Let be an integer. can be solved by a polynomial dynamic core .

###### Proof.

We define such that for each ,

 AcceptC(G) ={q∣q∈[0,p]} ProcessC,0(G) ={0} ProcessC,1(G,G′) ={(q,q′)∣q′≥0, q≤p, and q=q′+|V(G′)∖V(G)|} ProcessC,2(G,G′,G′′) ={(q,q′,q′′)∣q′,q′′≥0, q≤p, and q=q′+q′′+|(V(G′)∪V(G′′))∖V(G)|}

It is now an easy task to show that solves . Simply note that we only count the number of vertices in the part that has already been completely explored and forgotten and that .

For the running time, note that given a graph and a rooted tree decomposition of , then, for each , and . The lemma follows. ∎

The rank-based approach [BoCyKrNe2015] provides, in particular, a deterministic algorithm that solves Feedback Vertex Set in time , where (resp. ) stands for the size (resp. treewidth) of the input graph. From this algorithm, one can easily decline a dynamic core for recognizing if a graph is a tree. We omit the proof of it as it implies to reintroduce several tools presented in [BoCyKrNe2015] that are out of the scope of this paper.

###### Observation 7.

The class of trees can be solved by a dynamic core such that, for each graph , each rooted tree decomposition of , and each :

Note in particular that the dynamic core provided in Observation 7 is not polynomial.

### 3.2 Union and intersection of dynamic core

In this section we provide some simple combinations of dynamic cores. More precisely, we show how to do the union and the intersection of two dynamic cores. Let and be two graph classes and let (resp. ) be a dynamic core that solves (resp. ). We would like to stress that, in order to solve or , the naive procedure, consisting in using and then using , would be more efficient with regard to the running time but will not produce a dynamic core. As the main theorems of the paper, namely Theorems 10, 11, and 12, rely on the knowledge of a dynamic core, this naive procedure will not suit.

###### Lemma 8.

Let be an integer, let be graph classes and let, for each , be a dynamic core that solves . There exists a dynamic core that solves such that, for each graph , each rooted tree decomposition of , and each :

###### Proof.

We define such that for each ,

 AcceptC(G) ={(m1,…,mℓ)∣∀i∈[1,ℓ],mi∈AcceptCi(G) }, ProcessC,0(G) ={(m1,…,mℓ)∣∀i∈[1,ℓ],mi∈ProcessCi,0(G) }, ProcessC,1(G,G′) ={((m1,…,mℓ),(m′1,…,m′ℓ))∣ ∀i∈[1,ℓ],(mi,m′i)∈ProcessCi,1(G,G′) }, ProcessC,2(G,G′,G′′) ={((m1,…,mℓ),(m′1,…,m′ℓ),(m′′1,…,m′′ℓ))∣ ∀i∈[1,ℓ],(mi,m′i,m′′i)∈ProcessCi,2(G,G′,G′′) }.

We now prove that solves . First note that . Let be a graph and be a rooted tree decomposition of .

Assume first that , then by definition of , for each , . Let, for each , be a -witness. Note that it exists as solves and . We define such that for each , . By construction of , is a -witness.

Assume now that there exists a -witness . Then by definition of , for each , is a -uplet. Let define functions , , such that for each and each , . Then, by definition of , for each , is a -witness and so . Thus .

Let now analyze the needed running time for this algorithm. Let be a graph and be a rooted tree decomposition of . For each , we have, by definition, . In order to construct the data of associated to , we need first to construct the data of associated to for each and then to combine them. Thus, we have

 τ(C,G,D)=∑i∈[1,ℓ]τ(Ci,G,D)+O⎛⎝∑t∈V(T)|ProcessC,G,D(t)|⎞⎠.

###### Lemma 9.

Let be an integer, let be graph classes and let, for each , be a dynamic core that solves . There exists a dynamic core that solves such that, for each graph , each rooted tree decomposition of , and each :

###### Proof.

Let be an unused letter. We define such that for each ,

 AcceptC(G) ={(m1,…,mℓ)∣∃i∈[1,ℓ],mi∈AcceptCi(G) }, ProcessC,0(G) ={(m1,…,mℓ)∣∀i∈[1,ℓ],mi∈ProcessCi,0(G)∪{⊥} }, ProcessC,1(G,G′) ={((m1,…,mℓ),(m′1,…,m′ℓ))∣ ∀i∈[1,ℓ],(mi,m′i)∈ProcessCi,1(G,G′)∪{(⊥,⊥)} }, ProcessC,2(G,G′,G′′) ={((m1,…,mℓ),(m′1,…,m′ℓ),(m′′1,…,m′′ℓ))∣ ∀i∈[1,ℓ],(mi,m′i,m′′i)∈ProcessCi,2(G,G′,G′′)∪{(⊥,⊥,⊥)} }.

We prove, using the same kind of argumentation as for Theorem 8, that solves . Note that in this case, the letter is used for each coordinate such that . ∎

## 4 Main theorem

In this section we show, given two integers and , graph classes and dynamic cores such that, for each , solves , how to construct dynamic cores that solve , , and .

We start by the graph partition problem, that is the most involved case.

###### Theorem 10.

Let and be two integers, let be graph classes and let, for each , be a dynamic core that solves . There exists a dynamic core that solves such that, for each graph , each rooted tree decomposition of , and each :

###### Proof.

We define such that for each ,

 AcceptC(G) ={((m1,V1),…,(mℓ,Vℓ),q)∣ q≤p, V1,…,Vℓ % is a partition of V(G), and ∀i∈[1,ℓ],mi∈AcceptCi(G[Vi]) }, ProcessC,0(G) ={((m1,V1),…,(mℓ,Vℓ),0)∣ V1,…,Vℓ % is a partition of V(G) and ∀i∈[1,ℓ],mi∈ProcessCi,0(G[Vi]) }, ProcessC,1(G,G′) ={(((m1,V1),…,(mℓ,Vℓ),q),((m′1,V′1),…,(m′ℓ,V′ℓ),q′))∣ U1,…,Uℓ % is a partition of V(G)∪V(G′), ∀i∈[1,ℓ],Vi=Ui∩V(G), ∀i∈[1,ℓ],V′i=Ui∩V(G′), ∀i∈[1,ℓ],(mi,m′i)∈ProcessCi,1(G[Vi],G′[V′i]), q≤p, and q=q′+∑i∈[1,ℓ]|edgeG(Ui∖V(G),(V(G)∪V(G′))∖Ui)| }, ProcessC,2(G,G′,G′′) ={(((m1,V1),…,(mℓ,Vℓ),q),((m′1,V′1),…,(m′ℓ,V′ℓ),q′), ((m′′1,V′′1),…,(m′′ℓ,V′′ℓ),q′′))∣ U1,…,Uℓ % is a partition of V(G)∪V(G′)∪V(G′′), ∀i∈[1,ℓ],Vi=Ui∩V(G),