This section is devoted to the proof of the following result, which we used in Sect. 3.
Lemma 4
For every fixed \(d\in \mathbb {N},\) there is an algorithm for Max Induced d-Degenerate Subgraph with running time \(2^{{\mathcal {O}}(w\log w)}\cdot n,\) where w is the treewidth of the input graph and n is the number of its vertices.
Preliminaries on tree decompositions. First, we introduce some notations and terminology, as they will be required in this section. A tree decomposition of a graph G is a tree T together with a mapping \(\beta (\cdot )\) that assigns a bag \(\beta (x)\) to each node x of T in such a way that the following conditions hold:
-
(T1)
for each \(u\in V(G)\), the set of nodes x with \(u\in \beta (x)\) induces a connected non-empty subtree of T; and
-
(T2)
for each \(uv\in E(G)\), there exists a node x such that \(\{u,v\}\subseteq \beta (x)\).
The width of a tree decomposition \((T,\beta )\) is \(\max _{x\in V(T)} |\beta (x)|-1\), and the treewidth of a graph G is the minimum width of a tree decomposition of G.
Henceforth, all tree decompositions will be rooted: the underlying tree T has a prescribed root vertex r. This gives rise a natural ancestor-descendant relation: we write \(x\preceq y\) if x is an ancestor of y (where possibly \(x=y\)). Then, for a node x of T, we define the component at x as
$$\begin{aligned} \alpha (x)=\biggl (\bigcup _{y\succeq x} \beta (y)\biggr )\setminus \beta (x). \end{aligned}$$
It easily follows from (T1) and (T2) that then \(N(\alpha (x))\subseteq \beta (x)\) for every node x.
A nice tree decomposition is a normalized form of a rooted tree decomposition in which every node is of one of the following four kinds.
-
Leaf node a node x with no children and with \(\beta (x)=\emptyset\).
-
Introduce node a node x with one child y such that \(\beta (x)=\beta (y)\cup \{u\}\) for some vertex \(u\notin \beta (y)\).
-
Forget node a node x with one child y such that \(\beta (x)=\beta (y)\setminus \{u\}\) for some vertex \(u\in \beta (y)\).
-
Join node a node x with two children y and z such that \(\beta (x)=\beta (y)=\beta (z)\).
Moreover, we require that the root r of the nice tree decomposition satisfies \(\beta (r)=\emptyset\).
It is known that any given tree decomposition \((T,\beta )\) of width k of an n-vertex graph G can be transformed in \(k^{{\mathcal {O}}(1)}\cdot \max (n,|V(T)|)\) time into a nice tree decomposition of G of width at most as large, see
[12, Lemma 7.4]. Moreover, given an n-vertex graph G of treewidth w, a tree decomposition of G of width at most \(5w+4\) can be computed in \(2^{{\mathcal {O}}(w)}\cdot n\) time
[6], and this tree decomposition has at most n nodes. By combining these two results, for the proof of Lemma 4, we can assume that the input graph G is supplied with a nice tree decomposition \((T,\beta )\) of width \(k\leqslant 5w+4\), where \(w={\mathrm {tw}}(G)\). From now on, our goal is to design a suitable dynamic programming algorithm working on this decomposition with running time \(2^{{\mathcal {O}}(k\log k)}\cdot n=2^{{\mathcal {O}}(w\log w)}\cdot n\).
Dynamic programming states. The main idea behind our dynamic programming algorithm is to view the notion of degeneracy via vertex orderings, as expressed in the following fact.
Lemma 5
(folklore) A graph H is d-degenerate if and only if there is a linear ordering \(\sigma\) of vertices of H such that every vertex of H has at most d neighbors that are smaller in \(\sigma .\)
Let us point out that sometimes degeneracy is expressed in terms of vertex ordering, where we count neighbors that are larger. This characterization is clearly equivalent, as it is sufficient to reverse the ordering given in Lemma 5.
Due to Lemma 5, the problem considered in Lemma 4 can be restated as follows: find a largest set \(A\subseteq V(G)\) that admits a linear ordering \(\sigma\) in which every vertex of A has at most d neighbors in G[A] that are smaller in \(\sigma\). Intuitively, our dynamic programming will therefore keep track of the intersection of the bag with A, the restriction of \(\sigma\) to this intersection; and how many smaller neighbors of each vertex from this intersection have been already forgotten.
We now proceed with formal details. For a node x of T, a set \(X\subseteq \beta (x)\), a linear ordering \(\sigma\) of X, and a function \(f:X\rightarrow \{0,\ldots ,d\}\), we define \(\varPhi _x[X,\sigma ,f]\in \mathbb {N}\) as follows. The value \(\varPhi _x[X,\sigma ,f]\) is the maximum size of a set \(Y\subseteq \alpha (x)\) such that \(X\cup Y\) admits a linear ordering \(\tau\) with the following properties: \(\tau\) restricted to X is equal to \(\sigma\) and for every \(a\in X\), there are at most f(a) vertices \(b\in Y\) that are adjacent to a and smaller than a in \(\tau\). Note that other neighbors of a that belong to X are not taken into consideration when verifying the quota imposed by f(a). Note also that such a set Y always exists, as \(Y=\emptyset\) satisfies the criteria.
For a fixed node x, the total number of triples \((X,\sigma ,f)\) as above is at most
$$\begin{aligned} 2^{k+1}\cdot (k+1)!\cdot (d+1)^{k+1}\leqslant 2^{{\mathcal {O}}(k\log k)}. \end{aligned}$$
Hence, we now show how to compute the values \(\varPhi _x[X,\sigma ,f]\) in a bottom-up manner, so that the values for a node x are computed based on the values for the children of x in \(2^{{\mathcal {O}}(k\log k)}\) time. The answer to the problem corresponds to the value \(\varPhi _r[\emptyset ,\emptyset ,\emptyset ]\), where r is the root of T. While \(\varPhi _r[\emptyset ,\emptyset ,\emptyset ]\) is just the size of a largest feasible solution, an actual solution can be recovered from the dynamic programming tables using standard methods within the same complexity: for every computed value \(\varPhi _x[X,\sigma ,f]\), we store the way this value was obtained, and then we trace back the solution from \(\varPhi _r[\emptyset ,\emptyset ,\emptyset ]\) in a top-down manner.
Transitions It remains to provide recursive formulas for the values of \(\varPhi _x[\cdot ,\cdot ,\cdot ]\). We only present the formulas, while the verification of their correctness, which follows easily from the definition of \(\varPhi _x[\cdot ,\cdot ,\cdot ]\), is left to the reader. As usual, we distinguish cases depending on the type of x.
-
Leaf node x. Then we have only one value:
$$\begin{aligned} \varPhi _x[\emptyset ,\emptyset ,\emptyset ]=0. \end{aligned}$$
-
Introduce node x with child y such that \(\beta (x)=\beta (y)\cup \{u\}\). Then
$$\begin{aligned} \varPhi _x[X,\sigma ,f]={\left\{ \begin{array}{ll}\varPhi _y[X,\sigma ,f] &{} \text {if }u\notin X;\\ \varPhi _y[X\setminus \{u\},\sigma |_{X\setminus \{u\}},f|_{X\setminus \{u\}}] &{} \text {if }u\in X.\end{array}\right. } \end{aligned}$$
-
Forget node x with child y such that \(\beta (x)=\beta (y)\setminus \{u\}\). Then we have
$$\begin{aligned} \varPhi _x[X,\sigma ,f] = \max \,\left( \, \varPhi _y[X,\sigma ,f],\ 1 + \max _{(\sigma ',f')\in S(X,\sigma ,f)} \varPhi _y[X\cup \{u\},\sigma ',f']\,\right) , \end{aligned}$$
where \(S(X,\sigma ,f)\) is the set comprising the pairs \((\sigma ',f')\) satisfying the following:
-
\(\sigma '\) is a vertex ordering of \(X\cup \{u\}\) whose restriction to X is equal to \(\sigma\); and
-
\(f':X\cup \{u\}\rightarrow \{0,\ldots ,d\}\) is such that for all \(a\in X\) that are adjacent to u and larger than u in \(\sigma '\), we have \(f'(a)\leqslant f(a)-1\), and for all other \(a\in X\), we have \(f'(a)\leqslant f(a)\). Moreover, we require that \(f'(u)\leqslant d-\ell\), where \(\ell\) is the number of vertices \(a\in X\) that are adjacent to u and smaller than u in \(\sigma '\).
-
Join node x with children y and z. Then
$$\begin{aligned} \varPhi _x[X,\sigma ,f] = \max _{f_y+f_z\leqslant f} \varPhi _y[X,\sigma ,f_y]+\varPhi _z[X,\sigma ,f_z], \end{aligned}$$
where \(f_y+f_z\leqslant f\) means that \(f_y(a)+f_z(a)\leqslant f(a)\) for each \(a\in X\).
It is straightforward to see that using the formulas above, each value \(\varPhi _x[X,\sigma ,f]\) can be computed in \(2^{{\mathcal {O}}(k\log k)}\) time based on the values computed for the children of x. This completes the proof of Lemma 4.