1 Introduction

Given a vertex-weighted graph G and a set S of its vertices, the Subset Feedback Vertex Set (SFVS) problem asks for a vertex set of minimum weight that intersects all cycles containing a vertex of S. SFVS was introduced by Even et al. [17] who proposed an 8-approximation algorithm. Cygan et al. [15] and Kawarabayashi and Kobayashi [30] independently showed that SFVS is fixed-parameter tractable (FPT) parameterized by the solution size, while Hols and Kratsch [25] provide a randomized polynomial kernel for the problem. As a generalization of the classical NP-complete Feedback Vertex Set (FVS) problem, for which \(S=V(G)\), there has been a considerable amount of work to obtain faster algorithms for SFVS, both for general graphs [10, 18] where the current best is an \(O^*(1.864^{n})\) algorithm due to Fomin et al. [20], and restricted to special graph classes [2, 23, 37, 38]. Naturally, FVS and SFVS differ in complexity, as exemplified by split graphs where FVS is polynomial-time solvable [11] whereas SFVS remains NP-hard [20]. Moreover, note that the vertex-weighted variation of SFVS behaves differently than the unweighted one, as exposed on graphs with bounded independent set sizes: weighted SFVS is NP-complete on graphs with independent set size at most four, whereas unweighted SFVS is in XP parameterized by the independent set size [38].

Closely related to SFVS is the NP-hard Node Multiway Cut (NMC) problem in which we are given a vertex-weighted graph G and a set T of (terminal) vertices, and asked to find a vertex set of minimum weight that disconnects all the terminals [8, 21]. NMC is a well-studied problem in terms of approximation [21], as well as parameterized algorithms [8,9,10, 14, 16, 20]. It is not difficult to see that SFVS for \(S = \{v\}\) coincides with NMC in which \(T=N(v)\). In fact, NMC reduces to SFVS by adding a single vertex v with a large weight that is adjacent to all terminals and setting \(S=\{v\}\) [20]. Thus, in order to solve NMC on a given graph one may apply a known algorithm for SFVS on a vertex-extended graph. Observe, however, that through such an approach one needs to clarify that the vertex-extended graph still obeys the necessary properties of the known algorithm for SFVS. This explains why most of the positive results on SFVS on graph families [23, 37, 38] can not be translated to NMC.

In this paper, we investigate the complexity of SFVS and NMC when parameterized by structural graph width parameters. Well-known graph width parameters include tree-width [4], clique-width [13], rank-width [33], and maximum induced matching width (a.k.a. mim-width) [41]. These are of varying strength, with tree-width of modeling power strictly weaker than clique-width, as it is bounded on a proper subset of the graph classes having bounded clique-width, with rank-width and clique-width of the same modeling power, and with mim-width much stronger than clique-width. Belmonte and Vatshelle [1] showed that several graph classes, like interval graphs and permutation graphs, have bounded mim-width and a decomposition witnessing this can be found in polynomial time, whereas it is known that the clique-width of such graphs can be proportional to the square root of the number of vertices [24]. In this way, an XP algorithm parameterized by mim-width has the feature of unifying several algorithms on well-known graph classes.

We obtain most of these parameters through the well-known notion of branch-decomposition introduced in [39]. This is a natural hierarchical clustering of G, represented as a subcubic tree T with the vertices of G at its leaves. Any edge of the tree defines a cut of G given by the leaves of the two subtrees that result from removing the edge from T. Judiciously choosing a cut-function to measure the complexity of such cuts, or rather of the bipartite subgraphs of G given by the edges crossing the cuts, this framework then defines a graph width parameter by a minmax relation, minimum over all trees and maximum over all its cuts. Several graph width parameters have been defined this way, like carving-width, maximum matching-width, boolean-width etc. We will in this paper focus on: (i) rank-width [33] whose cut function is the GF[2]-rank of the adjacency matrix, (ii) \({\mathbb {Q}}\)-rank-width [35] a variant of rank-width with interesting algorithmic properties which instead uses the rank over the rational field, and (iii) mim-width [41] whose cut function is the size of a maximum induced matching of the graph crossing the cut. Concerning their computations, for rank-width and \({\mathbb {Q}}\)-rank-width, there are \(2^{3k}\cdot n^{4}\) time algorithms that, given a graph G as input and \(k\in {\mathbb {N}}\), either output a decomposition for G of width at most \(3k+1\) or confirms that the width of G is more than k [35, 36]. However, it is not known whether the mim-width of a graph can be approximated within a constant factor in time \(n^{f(k)}\) for some function f.

Let us mention what is known regarding the complexity of NMC and SFVS parameterized by these width measures. Since these problems can be expressed in MSO\(_1\)-logic it follows that they are FPT parameterized by tree-width, clique-width, rank-width or \({\mathbb {Q}}\)-rank-width [12, 34], however the runtime will contain a tower of 2’s with more than 4 levels. Recently, Bergougnoux et al. [2] proposed \(k^{O(k)}\cdot n^{3}\) time algorithms for these two problems parameterized by treewidth and proved that they cannot be solved in time \(k^{o(k)}\cdot n^{O(1)}\) unless ETH fails. For mim-width, we know that FVS and thus SFVS are both W[1]-hard when parameterized by the mim-width of a given decomposition [29].

Attacking SFVS seems to be a hard task that requires more tools than for FVS. Even for very small values of mim-width that capture several graph classes, the tractability of SFVS, prior to our result, was left open besides interval and permutation graphs [37]. Although FVS was known to be tractable on such graphs for more than a decade [32], the complexity status of SFVS still remained unknown.

Our Results We design a meta-algorithm that, given a graph and a branch-decomposition, solves SFVS (or NMC via its reduction to SFVS). The runtime of this algorithm is upper bounded by \(2^{O(rw^3)}\cdot n^4\), \(2^{O(q^2\log (q))}\cdot n^4\) and \(n^{O(k^2)}\) where rw, q and k are the rank-width, the \({\mathbb {Q}}\)-rank-width and the mim-width of the given branch-decomposition. For clique-width, our meta-algorithm implies that we can solve SFVS and NMC in time \(2^{O(k^2)}\cdot n^{O(1)}\) where k is the clique-width of a given clique-width expression. However, we do not prove this as it is not asymptotically optimal, indeed Jacob et al. [26] show recently that SFVS and NMC is solvable in time \(2^{O(k\log k )}\cdot n\) given a clique-width expression.

We resolve in the affirmative the question raised by Jaffke et al. [29], also mentioned in [37, 38], asking whether there is an XP-time algorithm for SFVS parameterized by the mim-width of a given decomposition. For rank-width and \({\mathbb {Q}}\)-rank-width we provide the first explicit FPT-algorithms with low exponential dependency that avoid the MSO\(_1\) formulation. Our main results are summarized in the following theorem:

Theorem 1

Let G be a graph on n vertices. We can solve Subset Feedback Vertex Set and Node Multiway Cut in time \(2^{O(rw^3)}\cdot n^4\) and \(2^{O(q^2\log (q))}\cdot n^4\), where rw and q are the rank-width and the \({\mathbb {Q}}\)-rank-width of G, respectively. Moreover, if a branch-decomposition of mim-width k for G is given as input, we can solve Subset Feedback Vertex Set and Node Multiway Cut in time \(n^{O(k^2)}\).

Note it is not known whether the mim-width of a graph can be approximated within a constant factor in time \(n^{f(k)}\) for some function f. However, by the previously mentioned results of Belmonte and Vatshelle [1] on computing decompositions of bounded mim-width, combined with a result of [27] showing that for any positive integer r a decomposition of mim-width k of a graph G is also a decomposition of mim-width at most 2k of its power \(G^r\), we get the following corollary.

Corollary 2

We can solve Subset Feedback Vertex Set and Node Multiway Cut in polynomial time on Interval, Permutation, and Bi-Interval graphs, Circular Arc and Circular Permutation graphs, Convex graphs, k -Polygon, Dilworth-k and Co-k -Degenerate graphs for fixed k, and on arbitrary powers of graphs in any of these classes.

Previously, such polynomial-time tractability was known only for SFVS and only on Interval and Permutation graphs [37]. It is worth noticing that Theorem 1 implies also that we can solve Subset Feedback Vertex Set and Node Multiway Cut in polynomial time on Leaf Power if an intersection model is given as input (from which we can compute a decomposition of mim-width 1) [1, 27] and on H -Graphs for a fixed H if an H-representation is given as input (from which we can compute a decomposition of mim-width 2|E(H)|) [19].

Our Approach We give some intuition to our meta-algorithm, that will focus on Subset Feedback Vertex Set. Since NMC can be solved by adding a vertex v of large weight adjacent to all terminals and solving SFVS with \(S=\{v\}\), all within the same runtime as extending the given branch-decomposition to this new graph increases the width at most by one for all considered width measures.

Towards achieving our goal, we use the d-neighbor equivalence, with \(d=1\) and \(d=2\), a notion introduced by Bui-Xuan et al. [7]. Two subsets X and Y of \(A \subseteq V(G)\) are d-neighbor equivalent w.r.t. A, if \(\mathsf {min}(d,|X\cap N(u)|) = \mathsf {min}(d,|Y\cap N(u)|)\) for all \(u\in V(G) {\setminus } A\). For a cut \((A, \overline{A})\) this equivalence relation on subsets of vertices was used by Bui-Xuan et al. [7] to design a meta-algorithm, also giving XP algorithms by mim-width, for so-called \((\sigma , \rho )\) generalized domination problems. Recently, Bergougnoux and Kanté [3] extended the uses of this notion to acyclic and connected variants of \((\sigma , \rho )\) generalized domination and similar problems like FVS. An earlier XP algorithm for FVS parameterized by mim-width had been given by Jaffke et al. [29] but instead of the d-neighbor equivalences this algorithm was based on the notions of reduced forests and minimal vertex covers.

Our meta-algorithm does a bottom-up traversal of a given branch-decomposition of the input graph G, computing a vertex subset X of maximum weight that induces an S-forest (i.e., a graph where no cycle contains a vertex of S) and outputs \(V(G) {\setminus } X\) which is necessarily a solution of SFVS. As usual, our dynamic programming algorithm relies on a notion of representativity between sets of partial solutions. For each cut \((A,\overline{A})\) induced by the decomposition, our algorithm computes a set of partial solutions \({\mathcal {A}}\subseteq 2^{A}\) of small size that represents \(2^{A}\). We say that a set of partial solutions \({\mathcal {A}}\subseteq 2^{A}\) represents a set of partial solutions \({\mathcal {B}}\subseteq 2^{A}\), if, for each \(Y\subseteq \overline{A}\), we have \(\mathsf {best}({\mathcal {A}},Y)=\mathsf {best}({\mathcal {B}},Y)\) where \(\mathsf {best}({\mathcal {C}},Y)\) is the maximum weight of a set \(X\in {\mathcal {C}}\) such that \(X\cup Y\) induces an S-forest. Since the root of the decomposition is associated with the cut \((V(G),\varnothing )\), the set of partial solutions computed for this cut represents \(2^{V(G)}\) and thus contains an S-forest of maximum weight. Our main tool is a subroutine that, given a set of partial solutions \({\mathcal {B}}\subseteq 2^{A}\), outputs a subset \({\mathcal {A}}\subseteq {\mathcal {B}}\) of small size that represents \({\mathcal {B}}\).

To design this subroutine, we cannot use directly the approaches solving FVS of any earlier approaches, like [3] or [29]. This is due to the fact that S-forests behave quite differently than forests; for example, given an S-forest F, the graph induced by the edges between \(A\cap V(F)\) and \(\overline{A}\cap V(F)\) could be a biclique. Instead, we introduce a notion of vertex contractions and prove that, for every \(X\subseteq A\) and \(Y\subseteq \overline{A}\), the graph induced by \(X\cup Y\) is an S-forest if and only if there exists a partition of \(X {\setminus } S\) and of \(Y {\setminus } S\), satisfying certain properties, such that contracting the blocks of these partitions into single vertices transforms the S-forest into a forest.

This equivalence between S-forests in the original graph and forests in the contracted graphs allows us to adapt some ideas from [3, 29]. Most of all, we use the property that, if the mim-width of the given decomposition is mim, then the contracted graph obtained from the bipartite graph induced by X and Y admits a vertex cover \(\mathsf {VC}\) of size at most 4mim. Note however, that in our case the elements of \(\mathsf {VC}\) are contracted subsets of vertices. Such a vertex cover allows us to control the cycles which are crossing the cut.

We associate each possible vertex cover \(\mathsf {VC}\) with an index i which contains basically a representative for the 2-neighbor equivalence for each subset of vertices in \(\mathsf {VC}\). Moreover, for each index i, we introduce the notions of partial solutions and complements solutions associated with i which correspond, respectively, to subsets of \(X\subseteq A\) and subsets \(Y\subseteq \overline{A}\) such that, for some contractions of X and Y,  the contracted graph obtained from the bipartite graph induced by X and Y admits a vertex cover \(\mathsf {VC}\) associated with i. We define an equivalence relation \(\sim _i\) between the partial solutions associated with i such that \(X\sim _i W\), if X and W connect in the same way the representatives of the vertex sets which belongs to the vertex covers described by i. Given a set of partial solutions \({\mathcal {B}}\subseteq 2^{A}\), our subroutine outputs a set \({\mathcal {A}}\) that contains, for each index i and each equivalence class \({\mathcal {C}}\) of \(\sim _i\) over \({\mathcal {B}}\), a partial solution in \({\mathcal {C}}\) of maximum weight. In order to prove that \({\mathcal {A}}\) represents \({\mathcal {B}}\), we show that:

  • for every S-forest F, there exists an index i such that \(V(F)\cap A\) is a partial solution associated with i and \(V(F)\cap \overline{A}\) is a complement solutions associated with i.

  • if \(X\sim _i W\), then, for every complement solution Y associated with i, the graph induced by \(X\cup Y\) is an S-forest if and only if \(W\cup Y\) induces an S-forest.

The number of indices i is upper bounded by \(2^{O(q^2\log (q))}\), \(2^{O(rw^3)}\) and \(n^{O(mim^2)}\). This follows from the known upper-bounds on the number of 2-neighbor equivalence classes and the fact that the vertex covers we consider have size at most 4mim. Since there are at most \((4mim)^{4mim}\) ways of connecting 4mim vertices and \(rw,q\ge mim\), we deduce that the size of \({\mathcal {A}}\) is upper bounded by \(2^{O(q^2\log (q))}\), \(2^{O(rw^3)}\) and \(n^{O(mim^2)}\).

To the best of our knowledge, this is the first time a dynamic programming algorithm parameterized by graph width measures uses this notion of vertex contractions. Note that in contrast to the meta-algorithms in [3, 7], the number of representatives (for the d-neighbor equivalence) contained in the indices of our meta-algorithm are not upper bounded by a constant but by 4mim. This explains the differences between the runtimes in Theorem 1 and those obtained in [3, 7], i.e. \(n^{O(mim^2)}\) versus \(n^{O(mim)}\). However, for the case \(S=V(G)\), thus solving FVS, our meta-algorithm will have runtime \(n^{O(mim)}\), as the algorithms for FVS of [3, 29]. We do not expect that SFVS can be solved as fast as FVS when parameterized by graph width measures. In fact, we know that it is not the case for tree-width as FVS can be solved in \(2^{O(k)} \cdot n\) [5] but SFVS cannot be solved in \(k^{o(k)} \cdot n^{O(1)}\) unless ETH fails [2].

2 Preliminaries

The size of a set V is denoted by |V| and its power set is denoted by \(2^V\). We write \(A{\setminus } B\) for the set difference of A from B. We let \(\mathsf {min}(\varnothing )= +\infty \) and \(\mathsf {max}(\varnothing )=-\infty \).

Graphs The vertex set of a graph G is denoted by V(G) and its edge set by E(G). An edge between two vertices x and y is denoted by xy (or yx). Given \({\mathcal {S}}\subseteq 2^{V(G)}\), we denote by \(V({\mathcal {S}})\) the set \(\bigcup _{S\in {\mathcal {S}}}S\). For a vertex set \(U \subseteq V(G)\), we denote by \(\overline{U}\) the set \(V(G) {\setminus } U\). The set of vertices that are adjacent to x is denoted by \(N_G(x)\), and for \(U\subseteq V(G)\), we let \(N_G(U)=\left( \cup _{v\in U}N_G(v)\right) {\setminus } U\).

The subgraph of G induced by a subset X of its vertex set is denoted by G[X]. For two disjoint subsets X and Y of V(G), we denote by G[XY] the bipartite graph with vertex set \(X\cup Y\) and edge set \(\{xy \in E(G)\mid x\in X \text { and } \ y\in Y \}\). We denote by \(M_{X,Y}\) the adjacency matrix between X and Y, i.e., the (XY)-matrix such that \(M_{X,Y}[x,y]=1\) if \(y\in N(x)\) and 0 otherwise. A vertex cover of a graph G is a set of vertices \(\mathsf {VC}\subseteq V(G)\) such that, for every edge \(uv\in E(G)\), we have \(u\in \mathsf {VC}\) or \(v\in \mathsf {VC}\). A matching is a set of edges having no common endpoint and an induced matching is a matching M of edges such that G[V(M)] has no other edges besides M. The size of an induced matching M refers to the number of edges in M.

For a graph G, we denote by \(\mathsf {cc}_G(X)\) the partition \(\{C\subseteq V(G) \mid G[C]\) is a connected component of \(G[X]\}\). We will omit the subscript G of the neighborhood and components notations whenever there is no ambiguity.

For two graphs \(G_1\) and \(G_2\), we denote by \(G_1 - G_2\) the graph \((V(G_1), E(G_1){\setminus } E(G_2))\).

Given a graph G and \(S\subseteq V(G)\), we say that a cycle of G is an S-cycle if it contains a vertex in S. Moreover, we say that a subgraph F of G is an S-forest if F does not contain an S-cycle. Typically, the Subset Feedback Vertex Set problem asks for a vertex set of minimum (weight) size such that its removal results in an S-forest. Here we focus on the following equivalent formulation:

figure a

Rooted Layout For the notion of branch-decomposition, we consider its rooted variant called rooted layout. A rooted binary tree is a binary tree with a distinguished vertex called the root. Since we manipulate at the same time graphs and trees representing them, the vertices of trees will be called nodes.

A rooted layout of G is a pair \((T,\delta )\) of a rooted binary tree T and a bijective function \(\delta \) between V(G) and the leaves of T. For each node x of T, let \(L_x\) be the set of all the leaves l of T such that the path from the root of T to l contains x. We denote by \(V_x\) the set of vertices that are in bijection with \(L_x\), i.e., \(V_x:=\{v \in V(G)\mid \delta (v)\in L_x\}\).

All the width measures dealt with in this paper are special cases of the following one, where the difference in each case is the used set function. Given a set function \({\mathsf {f}}: 2^{V(G)} \rightarrow {\mathbb {N}}\) and a rooted layout \({\mathcal {L}}=(T,\delta )\), the \({\mathsf {f}}\)-width of a node x of T is \({\mathsf {f}}(V_x)\) and the \({\mathsf {f}}\)-width of \((T,\delta )\), denoted by \({\mathsf {f}}(T,\delta )\) (or \({\mathsf {f}}({\mathcal {L}})\)), is \(\mathsf {max}\{{\mathsf {f}}(V_x) \mid x \in V(T)\}\). Finally, the \({\mathsf {f}}\)-width of G is the minimum \({\mathsf {f}}\)-width over all rooted layouts of G.

\(({\mathbb {Q}})\)-Rank-Width     The rank-width and \({\mathbb {Q}}\)-rank-width are, respectively, the \(\mathsf {rw}\)-width and \(\mathsf {rw}_{\mathbb {Q}}\)-width where \(\mathsf {rw}(A)\) (resp. \(\mathsf {rw}_{\mathbb {Q}}(A)\)) is the rank over GF(2) (resp. \({\mathbb {Q}}\)) of the matrix \(M_{A,\overline{A}}\) for all \(A\subseteq V(G)\).

Mim-Width The mim-width of a graph G is the \(\mathsf {mim}\)-width of G where \(\mathsf {mim}(A)\) is the size of a maximum induced matching of the graph \(G[A,\overline{A}]\) for all \(A\subseteq V(G)\).

Observe that all three parameters \(\mathsf {rw}\)-, \(\mathsf {rw}_{\mathbb {Q}}\)-, and \(\mathsf {mim}\)-width are symmetric, i.e., for the associated set function f and for any \(A \subseteq V(G)\), we have \(f(A) = f(\overline{A})\). The following lemma provides upper bounds between mim-width and the other two parameters.

Lemma 3

([41]) Let G be a graph. For every \(A\subseteq V(G)\), we have \(\mathsf {mim} (A) \leqslant \mathsf {rw} (A)\) and \(\mathsf {mim} (A) \leqslant \mathsf {rw} _{{\mathbb {Q}}}(A)\).

Proof

Let \(A\subseteq V(G)\). Let S be the vertex set of a maximum induced matching of the graph \(G[A,\overline{A}]\). By definition, we have \(\mathsf {mim}(A)= |S\cap A| = |S \cap \overline{A}|\). Observe that the restriction of the matrix \(M_{A,\overline{A}}\) to rows in \(S \cap A\) and columns in \(S \cap \overline{A}\) is a permutation matrix: a binary square matrix with exactly one entry of 1 in each row and each column. The rank of this permutation matrix over GF[2] or \({\mathbb {Q}}\) is \(|S\cap A|=\mathsf {mim}(A)\). Hence, \(\mathsf {mim}(A)\) is upper bounded both by \(\mathsf {rw}(A)\) and \(\mathsf {rw}_{\mathbb {Q}}(A)\). \(\square \)

d-Neighbor-Equivalence     The following concepts were introduced in [7]. Let G be a graph. Let \(A\subseteq V(G)\) and \(d\in {\mathbb {N}}^+\). Two subsets X and Y of A are d-neighbor equivalent w.r.t. A, denoted by \(X\equiv _{d}^{A} Y\), if \(\mathsf {min}(d,|X\cap N(u)|) = \mathsf {min}(d,|Y\cap N(u)|)\) for all \(u\in \overline{A}\). It is not hard to check that \(\equiv _{d}^{A}\) is an equivalence relation. See Fig. 1 for an example of 2-neighbor equivalent sets.

Fig. 1
figure 1

We have \(X\equiv _{2}^{A} Y\), but it is not the case that \(X\equiv _{3}^{A} Y\)

For all \(d\in {\mathbb {N}}^+\), we let \(\mathsf {nec}_d : 2^{V(G)}\rightarrow {\mathbb {N}}\) where for all \(A\subseteq V(G)\), \(\mathsf {nec}_d(A)\) is the number of equivalence classes of \(\equiv _{d}^{A}\). Notice that \(\mathsf {nec}_1\) is a symmetric function [31, Theorem 1.2.3] but \(\mathsf {nec}_d\) is not necessarily symmetric for \(d\ge 2\). To simplify the running times, we will use the shorthand \(\mathsf {s\text {-}nec}_2(A)\) to denote \(\mathsf {max}(\mathsf {nec}_2(A),\mathsf {nec}_2(\overline{A}))\) (where \({\mathsf {s}}\) stands for symmetric). The following lemma shows how \(\mathsf {nec}_d(A)\) is upper bounded by the other parameters.

Lemma 4

([1, 35, 41]) Let G be a graph. For every \(A\subseteq V(G)\) and \(d\in {\mathbb {N}}^+\), we have the following upper bounds on \(\mathsf {nec} _d(A)\):

  1. (a)

    \(2^{d \mathsf {rw} (A)^2}\),

  2. (b)

    \(2^{\mathsf {rw} _{{\mathbb {Q}}}(A)\log (d \mathsf {rw} _{{\mathbb {Q}}}(A) + 1 )}\),

  3. (c)

    \(|A|^{d \mathsf {mim} (A)}\).

In order to manipulate the equivalence classes of \(\equiv _{d}^{A}\), one needs to compute a representative for each equivalence class in polynomial time. This is achieved with the following notion of a representative. Let G be a graph with an arbitrary ordering of V(G) and let \(A\subseteq V(G)\). For each \(X\subseteq A\), let us denote by \(\mathsf {rep}_{d}^{A}(X)\) the lexicographically smallest set \(R\subseteq A\) such that |R| is minimized and \(R\equiv _{d}^{A} X\). Moreover, we denote by \({\mathcal {R}}_{d}^{A}\) the set \(\{\mathsf {rep}_{d}^{A}(X)\mid X\subseteq A\}\). It is worth noticing that the empty set always belongs to \({\mathcal {R}}_{d}^{A}\), for all \(A\subseteq V(G)\) and \(d\in {\mathbb {N}}^+\). Moreover, we have \({\mathcal {R}}_{d}^{V(G)}={\mathcal {R}}_{d}^{\varnothing }=\{\varnothing \}\) for all \(d\in {\mathbb {N}}^+\). In order to compute these representatives, we use the following lemma.

Lemma 5

([7]) Let G be an n-vertex graph. For every \(A\subseteq V(G)\) and \(d\in {\mathbb {N}}^+\), one can compute in time \(O(\mathsf {nec} _d(A) \cdot n^2 \cdot \log (\mathsf {nec} _d(A)))\), the sets \({\mathcal {R}}_{d}^{A}\) and a data structure that, given a set \(X\subseteq A\), computes \(\mathsf {rep} ^{A}_{d}(X)\) in time \(O(|A|\cdot n\cdot \log (\mathsf {nec} _d(A)))\).

Vertex Contractions In order to deal with SFVS, we will use the ideas of the algorithms for Feedback Vertex Set from [3, 28]. To this end, we will contract subsets of \(\overline{S}\) in order to transform S-forests into forests.

In order to compare two partial solutions associated with \(A\subseteq V(G)\), we define an auxiliary graph in which we replace contracted vertices by their representative sets in \({\mathcal {R}}_{2}^{A}\). Since the sets in \({\mathcal {R}}_{2}^{A}\) are not necessarily pairwise disjoint, we will use the following notions of graphs “induced” by collections of subsets of vertices. We will also use these notions to define the contractions we make on partial solutions.

Let G be a graph. Given \({\mathcal {A}}\subseteq 2^{V(G)}\), we define \(G[{\mathcal {A}}]\) as the graph with vertex set \({\mathcal {A}}\) where \(A,B\in {\mathcal {A}}\) are adjacent if and only if \(N(A)\cap B\ne \varnothing \). Observe that if the sets in \({\mathcal {A}}\) are pairwise disjoint, then \(G[{\mathcal {A}}]\) is obtained from an induced subgraph of G by vertex contractions (i.e., by replacing two vertices u and v with a new vertex with neighborhood \(N(\{u,v\})\)) and, for this reason, we refer to \(G[{\mathcal {A}}]\) as a contracted graph. Notice that we will never use the neighborhood notation and connected component notations on contracted graphs. Given \({\mathcal {A}},{\mathcal {B}}\subseteq 2^{V(G)}\), we denote by \(G[{\mathcal {A}},{\mathcal {B}}]\) the bipartite graph with vertex set \({\mathcal {A}}\cup {\mathcal {B}}\) and where \(A,B\in {\mathcal {A}}\cup {\mathcal {B}}\) are adjacent if and only if \(A\in {\mathcal {A}}\), \(B\in {\mathcal {B}}\), and \(N(A)\cap B\ne \varnothing \). Moreover, we denote by \(G[{\mathcal {A}}\mid {\mathcal {B}}]\) the graph with vertex set \({\mathcal {A}}\cup {\mathcal {B}}\) and with edge set \(E(G[{\mathcal {A}}])\cup E(G[{\mathcal {A}},{\mathcal {B}}])\). Observe that both graphs \(G[{\mathcal {A}},{\mathcal {B}}]\) and \(G[{\mathcal {A}}\mid {\mathcal {B}}]\) are subgraphs of the contracted graph \(G[{\mathcal {A}}\cup {\mathcal {B}}]\). To avoid confusion with the original graph, we refer to the vertices of the contracted graphs as blocks. It is worth noticing that in the contracted graphs used in this paper, whenever two blocks are adjacent, they are disjoint.

The following observation states that we can contract from a partition without increasing the size of a maximum induced matching of a graph. It follows directly from the definition of contractions.

Observation 6

Let H be a graph. For any partition \({\mathcal {P}}\) of a subset of V(H), the size of a maximum induced matching of \(H[{\mathcal {P}}]\) is at most the size of a maximum induced matching of H.

Let (GS) be an instance of SFVS. The vertex contractions that we use on a partial solution X are defined from a given partition of \(X{\setminus } S\). A partition of the vertices of \(X {\setminus } S\) is called an \(\overline{S}\)-contraction of X. We will use the following notations to handle these contractions.

Given \(Y\subseteq V(G)\), we denote by \(\left( {\begin{array}{c}Y\\ 1\end{array}}\right) \) the partition of Y which contains only singletons, i.e., \(\left( {\begin{array}{c}Y\\ 1\end{array}}\right) =\{\{ v\} \mid v \in Y\}\). Moreover, for an \(\overline{S}\)-contraction \({\mathcal {P}}\) of X, we denote by \(X_{\downarrow {\mathcal {P}}}\) the partition of X where \(X_{\downarrow {\mathcal {P}}}= {\mathcal {P}}\cup \left( {\begin{array}{c}X\cap S\\ 1\end{array}}\right) \). Given a subgraph H of G and an \(\overline{S}\)-contraction \({\mathcal {P}}\) of V(H), we denote by \(H_{\downarrow {\mathcal {P}}}\) the graph \(H[V(H)_{\downarrow {\mathcal {P}}}]\). For example, given two \(\overline{S}\)-contractions \({\mathcal {P}}_X,{\mathcal {P}}_Y\) of two disjoint subsets XY of V(G), we denote the graph \(G[X_{\downarrow {\mathcal {P}}_X}, Y_{\downarrow {\mathcal {P}}_Y}]\) by \(G[X, Y]_{\downarrow {\mathcal {P}}_X\cup {\mathcal {P}}_Y}\) and the graph \(G[X_{\downarrow {\mathcal {P}}_X} | Y_{\downarrow {\mathcal {P}}_Y}]\) by \(G[X| Y]_{\downarrow {\mathcal {P}}_X\cup {\mathcal {P}}_Y}\). It is worth noticing that in our contracted graphs, all the blocks of S-vertices are singletons and we denote them by \(\{v\}\).

Given a set \(X\subseteq V(G)\), we will intensively use the graph \(G[X]_{\downarrow \mathsf {cc}(X{\setminus } S)}\) which corresponds to the graph obtained from G[X] by contracting the connected components of \(G[X{\setminus } S]\), see Fig. 2.

Fig. 2
figure 2

An S-forest induced by a set \(X\subseteq V(G)\), the vertices of S are white. The gray circles represent the blocks of \(X_{\downarrow \mathsf {cc}(X{\setminus } S)}\). The graph \(G[X]_{\downarrow \mathsf {cc}(X{\setminus } S)}\) is obtained by contracting each gray circle

Observe that, for every subset \(X\subseteq V(G)\), if G[X] is an S-forest, then \(G[X]_{\downarrow \mathsf {cc}(X{\setminus } S)}\) is a forest. The converse is not true as we may delete S-cycles with contractions: take a triangle with one vertex v in S and contract the neighbors of v. However, we can prove the following equivalence.

Fact 7

Let G be a graph and \(S\subseteq V(G)\). For every \(X\subseteq V(G)\), G[X] is an S-forest if and only if there exists an \(\overline{S}\)-contraction \({\mathcal {P}}\) of X satisfying the following two properties:

  • \(G[X]_{\downarrow {\mathcal {P}}}\) is a forest, and

  • for every \(B\in {\mathcal {P}}\) and \(v\in X\cap S\), we have \(|N(v)\cap B|\leqslant 1\).

Moreover, if G[X] is an S-forest, then the \(\overline{S}\)-contraction \(\mathsf {cc} (X{\setminus } S)\) satisfies these two properties.

Proof

(\(\Rightarrow \)) Suppose first that G[X] is an S-forest. We claim that the \(\overline{S}\)-contraction \(\mathsf {cc}(X{\setminus } S)\) satisfies the two properties. Assume towards a contradiction that there is a cycle C in \(G[X]_{\downarrow \mathsf {cc}(X{\setminus } S)}\). By definition of \(G[X]_{\downarrow \mathsf {cc}(X{\setminus } S)}\), the blocks of this graph are the connected components \(\mathsf {cc}(X{\setminus } S)\) and the singletons in \(\left( {\begin{array}{c}X\cap S\\ 1\end{array}}\right) \). The blocks in \(\mathsf {cc}(X{\setminus } S)\) are pairwise non-adjacent, thus C contains a block \(\{s\}\) with \(s\in X\cap S\). Observe that for every pair of consecutive blocks \(B_1,B_2\) of C, there exists a vertex \(v_1\in B_1\) and \(v_2\in B_2\) such that \(v_1v_2\in E(G[X])\). As every block of \(G[X]_{\downarrow \mathsf {cc}(X{\setminus } S)}\) induces a connected component in G, we can construct an S-cycle in G[X] by replacing every block of C by a path in G[X], yielding a contradiction. Hence, \(G[X]_{\downarrow \mathsf {cc}(X{\setminus } S)}\) is a forest, i.e. the first property is satisfied. Observe that if there exists \(C\in \mathsf {cc}(X{\setminus } S)\) and \(v\in X\cap S\) such that v has two neighbors in C, then there exists an S-cycle in G[X] since C is a connected component. Hence, \(\mathsf {cc}(X{\setminus } S) \) satisfies the second property.

(\(\Leftarrow \)) Let \({\mathcal {P}}\) be a \(\overline{S}\) contraction of a subset \(X\subseteq V(G)\) that satisfies the two properties. Assume for contradiction that there is an S-cycle C in G[X]. Let v be a vertex of C that belongs to S and let u and w be the neighbors of v in C.

Let \(B_u\) and \(B_w\) be the blocks in \((X\cup Y)_{\downarrow {\mathcal {P}}}\) that contain u and w respectively. As v is in S, it belongs to the block \(\{v\}\) of \(G[X\cup Y]_{\downarrow {\mathcal {P}}}\) and thus it is not contained in \(B_u\) nor \(B_w\). The second property implies that \(|N(v)\cap B|\leqslant 1\) for each \(B\in {\mathcal {P}}\). Thus, \(B_u\) and \(B_w\) are two distinct blocks both connected to the block \(\{v\}\). Since there exists a path between u and w in C that does not go through v, we deduce that there is a path between \(B_u\) and \(B_w\) in \(G[X]_{\downarrow {\mathcal {P}}}\) that does not go through \(\{v\}\). Indeed, this follows from the fact that if there is an edge between two vertices a and b in G[X], then either a and b belong to the same block of \(G[X]_{\downarrow {\mathcal {P}}}\) or there exists an edge between the blocks in \(G[X]_{\downarrow {\mathcal {P}}}\) which contain a and b. We conclude that there exists a cycle in \(G[X]_{\downarrow {\mathcal {P}}}\), a contradiction with the first property. \(\square \)

3 A Meta-algorithm for Subset Feedback Vertex Set

In the following, we present a meta-algorithm that, given a rooted layout \((T,\delta )\) of G, solves SFVS. We will show that this meta-algorithm will imply that SFVS can be solved in time \(2^{O(\mathsf {rw}_{\mathbb {Q}}(G)^2\log (\mathsf {rw}_{\mathbb {Q}}(G)))}\cdot n^{4}\), \(2^{O(\mathsf {rw}(G)^3)}\cdot n^{4}\) and \(n^{O(\mathsf {mim}(T,\delta )^2)}\). The main idea of this algorithm is to use \(\overline{S}\)-contractions in order to employ similar properties of the algorithm for Maximum Induced Tree of [3] and the \(n^{O(\mathsf {mim}(T,\delta ))}\) time algorithm for Feedback Vertex Set of [28]. In particular, we use the following lemma which is proved implicitly in [3]. To simplify the following statements, we fix a graph G, a rooted layout \((T,\delta )\) of G and a node \(x\in V(T)\).

Lemma 8

Let X and Y be two disjoint subsets of V(G). If \(G[X\cup Y]\) is a forest, then the number of vertices of X that have at least two neighbors in Y is bounded by 2w where w is the size of a maximum induced matching in the bipartite graph G[XY].

Proof

Let \(X^{2+}\) be the set of vertices in X having at least 2 neighbors in Y. In the following, we prove that \(F=G[X^{2+},Y]\) admits a good bipartition, that is a bipartition \(\{X_0,X_1\}\) of \(X^{2+}\) such that, for each \(i\in \{0,1\}\) and, for each \(v\in X_i\), there exists \(y_v\in Y\) such that \(N_{F}(y_v)\cap X_i = \{v\}\). Observe that this is enough to prove the lemma since if F admits a good bipartition \(\{X_0,X_1\}\), then \(|X_0|\leqslant w\) and \(|X_1|\leqslant w\). Indeed, if F admits a good bipartition \(\{X_0,X_1\}\), then, for each \(i\in \{0,1\}\), the set of edges \(M_i=\{ vy_v \mid v\in X_i \}\) is an induced matching of G[XY]. In order to prove that F admits a good bipartition it is sufficient to prove that each connected component of F admits a good bipartition.

Let C be a connected component of F and \(x_0\in C\cap X^{2+}\). As \(G[X\cup Y]\) is a forest, we deduce that F[C] is a tree. Observe that the distance in F[C] between each vertex \(v\in C\cap X^{2+}\) and \(x_0\) is even because F[C] is bipartite w.r.t. \((C\cap X^{2+}, C\cap Y)\). Let \(X_0\) (resp. \(X_1\)) be the set of all vertices \(v\in C\cap X^{2+}\) at distance \(2\ell \) from \(x_0\) with \(\ell \) even (resp. odd). We claim that \(\{X_0,X_1\}\) is a good bipartition of F[C].

Let \(i \in \{0,1\}\), \(v\in X_i\) and \(\ell \in {\mathbb {N}}\) such that the distance between v and \(x_0\) in F[C] is \(2\ell \). Let P be the set of vertices in \(C{\setminus } \{v\}\) that share a common neighbor with v in F[C]. We want to prove that v has a neighbor y in F that is not adjacent to \(P\cap X_i\). Observe that, for every \(v'\in P\), the distance between \(v'\) and \(x_0\) in F[C] is either \(2\ell -2\), \(2\ell \) or \(2\ell +2\) because F[C] is a tree and the distance between v and \(x_0\) is \(2\ell \). By construction of \(\{X_0,X_1\}\), every vertex at distance \(2\ell -2\) or \(2\ell +2\) from \(x_0\) belongs to \(X_{1-i}\). Thus, every vertex in \(P\cap X_i\) is at distance \(2\ell \) from \(x_0\). If \(\ell =0\), then we are done because \(v=x_0\) and \(P\cap X_i=\varnothing \). Assume that \(\ell \ne 0\). As F[C] is a tree, v has only one neighbor w at distance \(2\ell -1\) from \(x_0\) in F[C]. Because F[C] is a tree, w is the only vertex adjacent to v and the vertices in \(P\cap X_i\). By definition of \(X^{2+}\), v has at least two neighbors in Y, so v admits a neighbor that is not w and this neighbor is not adjacent to the vertices in \(P\cap X_i\). Hence, we deduce that \(\{X_0,X_1\}\) is a good bipartition of F[C].

We deduce that every connected component of F admits a good bipartition and, thus, F admits a good bipartition. This proves that \(|X^{2+}|\leqslant 2w\). \(\square \)

The following lemma generalizes Fact 7 and presents the equivalence between S-forests and forests that we will use in our algorithm.

Lemma 9

Let \(X\subseteq V_x\) and \(Y\subseteq \overline{V_x}\). If the graph \(G[X\cup Y]\) is an S-forest, then there exists an \(\overline{S}\)-contraction \({\mathcal {P}}_Y\) of Y that satisfies the following conditions:

  1. (1)

    \(G[X\cup Y]_{\downarrow \mathsf {cc} (X{\setminus } S)\cup {\mathcal {P}}_Y}\) is a forest,

  2. (2)

    for all block \(P\in \mathsf {cc} (X{\setminus } S)\cup {\mathcal {P}}_Y\) and \(v\in (X\cup Y)\cap S\), we have \(|N(v)\cap P|\leqslant 1\),

  3. (3)

    the graph \(G[X, Y]_{\downarrow \mathsf {cc} (X{\setminus } S)\cup {\mathcal {P}}_Y}\) admits a vertex cover \(\mathsf {VC} \) of size at most \(4 \mathsf {mim} (V_x)\) such that the neighborhoods of the blocks in \(\mathsf {VC} \) are pairwise distinct in \(G[X, Y]_{\downarrow \mathsf {cc} (X{\setminus } S)\cup {\mathcal {P}}_Y}\).

Proof

Assume that \(G[X\cup Y]\) is an S-forest. Let us explain how we construct \({\mathcal {P}}_Y\) that satisfies Conditions (1)–(3). First, we initialize \({\mathcal {P}}_Y=\mathsf {cc}(Y{\setminus } S)\). Observe that there is no cycle in \(G[X\cup Y]_{\downarrow \mathsf {cc}(X{\setminus } S)\cup {\mathcal {P}}_Y}\) that contains a block in \(\left( {\begin{array}{c}S\\ 1\end{array}}\right) \) because \(G[X\cup Y]\) is an S-forest. Moreover, \(\mathsf {cc}(X{\setminus } S)\) and \({\mathcal {P}}_Y\) form two independent sets in \(G[X\cup Y]_{\downarrow \mathsf {cc}(X{\setminus } S)\cup {\mathcal {P}}_Y}\). Consequently, for all the cycles C in \(G[X\cup Y]_{\downarrow \mathsf {cc}(X{\setminus } S)\cup {\mathcal {P}}_Y}\) we have \(C=(X_1,Y_1,X_2,Y_2,\dots ,X_t,Y_t)\) where \(X_1,\dots ,X_t\in \mathsf {cc}(X{\setminus } S)\) and \(Y_1,\dots ,Y_t\in {\mathcal {P}}_Y\). We do the following operation, until the graph \(G[X\cup Y]_{\downarrow \mathsf {cc}(X{\setminus } S)\cup {\mathcal {P}}_Y}\) is a forest: take a cycle \(C=(X_1,Y_1,X_2,Y_2,\dots ,X_t,Y_t)\) in \(G[X\cup Y]_{\downarrow \mathsf {cc}(X{\setminus } S)\cup {\mathcal {P}}_Y}\) and replace the blocks \(Y_1,\dots ,Y_t\) in \({\mathcal {P}}_Y\) by the block \(Y_1\cup \dots \cup Y_t\). See Figs. 5 and 6 in “Appendix A” for an example of \(\overline{S}\)-contraction \({\mathcal {P}}_Y\).

For each \(B\in \mathsf {cc}(X{\setminus } S)\cup \mathsf {cc}(Y{\setminus } S)\), the vertices of B are pairwise connected in \(G[(X\cup Y){\setminus } S]\). We deduce by induction that whenever we apply the operation on a cycle \(C=(X_1,Y_1,X_2,Y_2,\dots ,X_t,Y_t)\), it holds that the vertices of the new block \(Y_1\cup \dots \cup Y_t\) are pairwise connected in \(G[(X\cup Y){\setminus } S]\). Thus, for every block B of \(\mathsf {cc}(X{\setminus } S)\cup {\mathcal {P}}_Y\), the vertices of B are pairwise connected in \(G[(X\cup Y){\setminus } S]\). It follows that for every \(v\in (X\cup Y)\cap S\) and \(B\in \mathsf {cc}(X{\setminus } S)\cup {\mathcal {P}}_Y\), since \(G[X\cup Y]\) is an S-forest, we have \(|N(v)\cap B|\leqslant 1\). Thus, Condition (2) is satisfied.

It remains to prove Condition (3). Let \(\mathsf {VC}\) be the set of blocks of \(G[X, Y]_{\downarrow \mathsf {cc}(X{\setminus } S)\cup {\mathcal {P}}_Y}\) containing:

  • the blocks that have at least 2 neighbors in \(G[X, Y]_{\downarrow \mathsf {cc}(X{\setminus } S)\cup {\mathcal {P}}_Y}\), and

  • one block in every isolated edge of \(G[X, Y]_{\downarrow \mathsf {cc}(X{\setminus } S)\cup {\mathcal {P}}_Y}\).

By construction, it is clear that \(\mathsf {VC}\) is indeed a vertex cover of \(G[X, Y]_{\downarrow \mathsf {cc}(X{\setminus } S)\cup {\mathcal {P}}_Y}\) as every edge is either isolated or incident to a block of degree at least 2. We claim that \(|\mathsf {VC}|\leqslant 4\mathsf {mim}(V_x)\). By Observation 6, we know that the size of a maximum induced matching in \(G[X, Y]_{\downarrow \mathsf {cc}(X{\setminus } S)\cup {\mathcal {P}}_Y}\) is at most \(\mathsf {mim}(V_x)\). Let t be the number of isolated edges in \(G[X, Y]_{\downarrow \mathsf {cc}(X{\setminus } S)\cup {\mathcal {P}}_Y}\). Observe that the size of a maximum induced matching in the graph obtained from \(G[X, Y]_{\downarrow \mathsf {cc}(X{\setminus } S)\cup {\mathcal {P}}_Y}\) by removing isolated edges is at most \(\mathsf {mim}(V_x)-t\). By Lemma 8, we know that there are at most \(4(\mathsf {mim}(V_x)-t)\) blocks that have at least 2 neighbors in \(G[X, Y]_{\downarrow \mathsf {cc}(X{\setminus } S)\cup {\mathcal {P}}_Y}\). We conclude that \(|\mathsf {VC}|\leqslant 4\mathsf {mim}(V_x)\).

Since \(G[X, Y]_{\downarrow \mathsf {cc}(X{\setminus } S)\cup {\mathcal {P}}_Y}\) is a forest, the neighborhoods of the blocks that have at least 2 neighbors must be pairwise distinct. We conclude from the construction of \(\mathsf {VC}\) that the neighborhoods of the blocks of \(\mathsf {VC}\) in \(G[X,Y]_{\downarrow \mathsf {cc}(X{\setminus } S)\cup {\mathcal {P}}_Y}\) are pairwise distinct. Hence, Condition (3) is satisfied. \(\square \)

In the following, we will use Lemma 9 to design some sort of equivalence relation between partial solutions. To this purpose, we use the following set of tuples. We call each such tuple an index because it corresponds to an index into a table in a DP (dynamic programming) approach. We do this even though the presentation of our algorithm is not given by a standard DP description.

Definition 10

(\({\mathbb {I}}_x\)) We define the set \({\mathbb {I}}_x\) of indices as the set of tuples

$$\begin{aligned} ({\mathscr {X}}_{\mathsf {vc}}^{\overline{S}},{\mathscr {X}}_{\mathsf {vc}}^{S}, {\mathscr {X}}_{\overline{\mathsf {vc}}},{\mathscr {Y}}_{\mathsf {vc}}^{\overline{S}},{\mathscr {Y}}_{\mathsf {vc}}^{S}) \in 2^{{\mathcal {R}}_{2}^{{V_x}}}\times 2^{{\mathcal {R}}_{1}^{V_x}}\times {\mathcal {R}}_{1}^{V_x}\times 2^{{\mathcal {R}}_{2}^{\overline{V_x}}} \times 2^{{\mathcal {R}}_{1}^{\overline{V_x}}} \end{aligned}$$

such that \(|{\mathscr {X}}_{\mathsf {vc}}^{\overline{S}}|+|{\mathscr {X}}_{\mathsf {vc}}^{S}|+|{\mathscr {Y}}_{\mathsf {vc}}^{\overline{S}}| + |{\mathscr {Y}}_{\mathsf {vc}}^{S}| \leqslant 4\mathsf {mim}(V_x)\).

These sets of indices play a major role in our meta-algorithm, in particular, the sizes of these sets of indices appear in the runtime of our meta-algorithm. In fact, to prove the algorithmic consequences of our meta-algorithm for rank-width, \({\mathbb {Q}}\)-rank-width and mim-width, we show (Lemma 23) that the size of \({\mathbb {I}}_x\) is upper bounded by \(2^{O(\mathsf {rw}(V_x)^3)}\), \(2^{O(\mathsf {rw}_{\mathbb {Q}}(V_x)^2\log (\mathsf {rw}_{\mathbb {Q}}(V_x)))}\) and \(n^{O(\mathsf {mim}(V_x)^2)}\).

In the following, we will define partial solutions associated with an index \(i\in {\mathbb {I}}_x\) (a partial solution may be associated with many indices). In order to prove the correctness of our algorithm (the algorithm itself will not use this concept), we will also define complement solutions (the sets \(Y\subseteq \overline{V_x}\) and their \(\overline{S}\)-contractions \({\mathcal {P}}_Y\)) associated with an index i. We will prove that, for every partial solution X and complement solution \((Y,{\mathcal {P}}_Y)\) associated with i, if the graph \(G[X\cup Y]_{\downarrow \mathsf {cc}(X{\setminus } S)\cup {\mathcal {P}}_Y}\) is a forest, then \(G[X\cup Y]\) is an S-forest.

Let us give some intuition on these indices by explaining how one index is associated with a solution, figures explaining this association and the purposes of the sets \({\mathscr {X}}_{\mathsf {vc}}^{\overline{S}},{\mathscr {X}}_{\mathsf {vc}}^{S}, {\mathscr {X}}_{\overline{\mathsf {vc}}},{\mathscr {Y}}_{\mathsf {vc}}^{\overline{S}},{\mathscr {Y}}_{\mathsf {vc}}^{S}\) can be found in “Appendix A”. Let \(X\subseteq V_x\) and \(Y\subseteq \overline{V_x}\) such that \(G[X\cup Y]\) is an S-forest. Let \({\mathcal {P}}_Y\) be the \(\overline{S}\)-contraction of Y and \(\mathsf {VC}\) be a vertex cover of \(G[X,Y]_{\downarrow \mathsf {cc}(X{\setminus } S)\cup {\mathcal {P}}_Y}\) given by Lemma 9. Then, X and Y are associated with \(i=({\mathscr {X}}_{\mathsf {vc}}^{\overline{S}},{\mathscr {X}}_{\mathsf {vc}}^{S}, {\mathscr {X}}_{\overline{\mathsf {vc}}},{\mathscr {Y}}_{\mathsf {vc}}^{\overline{S}},{\mathscr {Y}}_{\mathsf {vc}}^{S})\in {\mathbb {I}}_x\) such that:

  • \({\mathscr {X}}_{\mathsf {vc}}^{S}\) (resp. \({\mathscr {Y}}_{\mathsf {vc}}^{S}\)) contains the representatives of the blocks \(\{v\}\) in \(\mathsf {VC}\) such that \(v\in X\cap S\) (resp. \(v\in Y\cap S\)) w.r.t. the 1-neighbor equivalence over \(V_x\) (resp. \(\overline{V_x}\)). We will only use the indices where \({\mathscr {X}}_{\mathsf {vc}}^{S}\) contains representatives of singletons, in other words, \({\mathscr {X}}_{\mathsf {vc}}^{S}\) is included in \(\{ \mathsf {rep}_{1}^{V_x}(\{v\}) \mid v\in V_x\}\) which can be much smaller than \({\mathcal {R}}_{1}^{V_x}\). The same observation holds for \({\mathscr {Y}}_{\mathsf {vc}}^{S}\). In Definition 10, we state that \({\mathscr {X}}_{\mathsf {vc}}^{S}\) and \({\mathscr {Y}}_{\mathsf {vc}}^{S}\) are, respectively, subsets of \(2^{{\mathcal {R}}_{1}^{V_x}}\) and \(2^{{\mathcal {R}}_{1}^{\overline{V_x}}}\), for the sake of simplicity.

  • \({\mathscr {X}}_{\mathsf {vc}}^{\overline{S}}\) (resp. \({\mathscr {Y}}_{\mathsf {vc}}^{\overline{S}}\)) contains the representatives of the blocks in \(\mathsf {cc}(X{\setminus } S)\cap \mathsf {VC}\) (resp. \({\mathcal {P}}_Y\cap \mathsf {VC}\)) w.r.t. the 2-neighbor equivalence relation over \(V_x\) (resp. \(\overline{V_x}\)).

  • \({\mathscr {X}}_{\overline{\mathsf {vc}}}\) is the representative of \(X{\setminus } V(\mathsf {VC})\) (the set of vertices which do not belong to the vertex cover) w.r.t. the 1-neighbor equivalence over \(V_x\).

Because the neighborhoods of the blocks in \(\mathsf {VC}\) are pairwise distinct in \(G[X,Y]_{\downarrow \mathsf {cc}(X{\setminus } S)\cup {\mathcal {P}}_Y}\) (Property (3) of Lemma 9), there is a one to one correspondence between the representatives in \({\mathscr {X}}_{\mathsf {vc}}^{\overline{S}}\cup {\mathscr {X}}_{\mathsf {vc}}^{S}\cup {\mathscr {Y}}_{\mathsf {vc}}^{\overline{S}}\cup {\mathscr {Y}}_{\mathsf {vc}}^{S}\) and the blocks in \(\mathsf {VC}\).

While \({\mathscr {X}}_{\mathsf {vc}}^{\overline{S}}, {\mathscr {X}}_{\mathsf {vc}}^{S},{\mathscr {Y}}_{\mathsf {vc}}^{\overline{S}},{\mathscr {Y}}_{\mathsf {vc}}^{S}\) describe \(\mathsf {VC}\), the representative set \({\mathscr {X}}_{\overline{\mathsf {vc}}}\) describes the neighborhood of the blocks of \(X_{\downarrow \mathsf {cc}(X{\setminus } S)}\) which are not in \(\mathsf {VC}\). The purpose of \({\mathscr {X}}_{\overline{\mathsf {vc}}}\) is to make sure that, for every partial solution X and complement solution \((Y,{\mathcal {P}}_Y)\) associated with i, the set \(\mathsf {VC}\) described by \({\mathscr {X}}_{\mathsf {vc}}^{\overline{S}}, {\mathscr {X}}_{\mathsf {vc}}^{S},{\mathscr {Y}}_{\mathsf {vc}}^{\overline{S}},{\mathscr {Y}}_{\mathsf {vc}}^{S}\) is a vertex cover of \(G[X,Y]_{\downarrow \mathsf {cc}(X{\setminus } S)\cup {\mathcal {P}}_Y}\). For doing so, it is sufficient to require that \(Y{\setminus } V(\mathsf {VC})\) has no neighbor in \({\mathscr {X}}_{\overline{\mathsf {vc}}}\) for every complement solution \((Y,{\mathcal {P}}_Y)\) associated with i.

Observe that the sets \({\mathscr {X}}_{\mathsf {vc}}^{\overline{S}}\) and \({\mathscr {Y}}_{\mathsf {vc}}^{\overline{S}}\) contain representatives for the 2-neighbor equivalence. We need the 2-neighbor equivalence to control the S-cycles which might disappear after vertex contractions. To prevent this situation, we require, for example, that every vertex in \(X\cap S\) has at most one neighbor in \(\overline{R}\) for each \(\overline{R}\in {\mathscr {Y}}_{\mathsf {vc}}^{\overline{S}}\). Thanks to the 2-neighbor equivalence, a vertex v in \(X\cap S\) has at most one neighbor in \(\overline{R}\in {\mathscr {Y}}_{\mathsf {vc}}^{\overline{S}}\) if and only if v has at most one neighbor in the block of \({\mathcal {P}}_Y\) associated with \(\overline{R}\). This property of the 2-neighbor equivalence is captured by the following fact.

Fact 11

For every \(A\subseteq V(G)\) and \(B,P\subseteq A\), if \(B\equiv _{2}^{A} P\), then, for all \(v\in \overline{A}\), we have \(|N(v)\cap B|\leqslant 1\) if and only if \(|N(v)\cap P|\leqslant 1\).

In order to define partial solutions associated with i, we need the following notion of auxiliary graph. Given \(X\subseteq V_x\) and \(i=({\mathscr {X}}_{\mathsf {vc}}^{\overline{S}},{\mathscr {X}}_{\mathsf {vc}}^{S}, {\mathscr {X}}_{\overline{\mathsf {vc}}},{\mathscr {Y}}_{\mathsf {vc}}^{\overline{S}},{\mathscr {Y}}_{\mathsf {vc}}^{S})\in {\mathbb {I}}_x\), we write \(\mathsf {aux}(X,i)\) to denote the graph

$$\begin{aligned} G[X_{\downarrow \mathsf {cc}(X{\setminus } S)}\mid {\mathscr {Y}}_{\mathsf {vc}}^{\overline{S}} \cup {\mathscr {Y}}_{\mathsf {vc}}^{S} ]. \end{aligned}$$

Observe that \(\mathsf {aux}(X,i)\) is obtained from the graph induced by \(X_{\downarrow \mathsf {cc}(X{\setminus } S)} \cup {\mathscr {Y}}_{\mathsf {vc}}^{\overline{S}} \cup {\mathscr {Y}}_{\mathsf {vc}}^{S}\) by removing the edges between the blocks from \( {\mathscr {Y}}_{\mathsf {vc}}^{\overline{S}} \cup {\mathscr {Y}}_{\mathsf {vc}}^{S}\). Figure 3 illustrates an example of the graph \(\mathsf {aux}(X,i)\) and the related notions. The figures in “Appendix A” explain the relations between an S-forest and these auxiliary graphs.

Fig. 3
figure 3

An example of a set \(X\subseteq V_x\) and its auxiliary graph associated with the index \(i=({\mathscr {X}}_{\mathsf {vc}}^{\overline{S}},{\mathscr {X}}_{\mathsf {vc}}^{S}, {\mathscr {X}}_{\overline{\mathsf {vc}}},{\mathscr {Y}}_{\mathsf {vc}}^{\overline{S}},{\mathscr {Y}}_{\mathsf {vc}}^{S})\). Here, \({\mathscr {X}}_{\mathsf {vc}}^{\overline{S}}=\{R_2\}\) with \(R_2=\mathsf {rep}_{2}^{V_x}(X_2)\), \({\mathscr {X}}_{\mathsf {vc}}^{S}=\{R_1\}\) with \(R_1= \mathsf {rep}_{1}^{V_x}(\{v_1\})\), \({\mathscr {X}}_{\overline{\mathsf {vc}}}\) is the representative of the union of the circular blocks, \({\mathscr {Y}}_{\mathsf {vc}}^{\overline{S}}=\{ U_1,U_2\}\), and \({\mathscr {Y}}_{\mathsf {vc}}^{S}=\{ U_3,U_4\}\). The singletons in \(X\cap S\) and \({\mathscr {Y}}_{\mathsf {vc}}^{S}\) are white filled, whereas the square blocks are \(\{v_1\}\), \(X_2\) and the blocks in \({\mathscr {Y}}_{\mathsf {vc}}^{\overline{S}}\cup {\mathscr {Y}}_{\mathsf {vc}}^{S}\)

We will ensure that, given a complement solution \((Y,{\mathcal {P}}_Y)\) associated with i, the graph \(\mathsf {aux}(X,i)\) is isomorphic to \(G[X_{\downarrow \mathsf {cc}(X{\setminus } S)} \mid Y_{\downarrow {\mathcal {P}}_Y}\cap \mathsf {VC}]\). We are now ready to define the notion of partial solution associated with an index i.

Definition 12

(Partial solutions) Let \(i=({\mathscr {X}}_{\mathsf {vc}}^{\overline{S}},{\mathscr {X}}_{\mathsf {vc}}^{S}, {\mathscr {X}}_{\overline{\mathsf {vc}}},{\mathscr {Y}}_{\mathsf {vc}}^{\overline{S}},{\mathscr {Y}}_{\mathsf {vc}}^{S})\in {\mathbb {I}}_x\). We say that \(X\subseteq V_x\) is a partial solution associated with i if the following conditions are satisfied:

  1. (a)

    for every \(R\in {\mathscr {X}}_{\mathsf {vc}}^{S}\), there exists a unique \(v\in X\cap S\) such that \(R\equiv _{1}^{V_x} \{v\}\),

  2. (b)

    for every \(R\in {\mathscr {X}}_{\mathsf {vc}}^{\overline{S}}\), there exists a unique \(C\in \mathsf {cc}(X{\setminus } S)\) such that \(R\equiv _{2}^{V_x} C\),

  3. (c)

    \(\mathsf {aux}(X,i)\) is a forest,

  4. (d)

    for every \(C\in \mathsf {cc}(X{\setminus } S)\) and \(\{v\}\in {\mathscr {Y}}_{\mathsf {vc}}^{S}\), we have \(|N(v)\cap C |\leqslant 1\),

  5. (e)

    for every \(v\in X\cap S\) and \(U\in {\mathscr {Y}}_{\mathsf {vc}}^{\overline{S}}\cup \mathsf {cc}(X{\setminus } S)\), we have \(|N(v)\cap U|\leqslant 1\),

  6. (f)

    \({\mathscr {X}}_{\overline{\mathsf {vc}}} \equiv _{1}^{V_x} X{\setminus } V(\mathsf {VC}_X)\) , where \(\mathsf {VC}_X\) contains the blocks \(\{v\}\in \left( {\begin{array}{c}X\cap S\\ 1\end{array}}\right) \) such that \(\mathsf {rep}_{1}^{V_x}(\{v\})\in {\mathscr {X}}_{\mathsf {vc}}^{S}\) and the components C of \(G[X{\setminus } S]\) such that \(\mathsf {rep}_{2}^{V_x}(C)\in {\mathscr {X}}_{\mathsf {vc}}^{\overline{S}}\).

Similarly to Definition 12, we define the notion of complement solutions associated with an index \(i\in {\mathbb {I}}_x\). We use this concept only to prove the correctness of our algorithm.

Definition 13

(Complement solutions) Let \(i=({\mathscr {X}}_{\mathsf {vc}}^{\overline{S}},{\mathscr {X}}_{\mathsf {vc}}^{S}, {\mathscr {X}}_{\overline{\mathsf {vc}}},{\mathscr {Y}}_{\mathsf {vc}}^{\overline{S}},{\mathscr {Y}}_{\mathsf {vc}}^{S})\in {\mathbb {I}}_x\). We call complement solutions associated with i all the pairs \((Y,{\mathcal {P}}_Y)\) such that \(Y\subseteq \overline{V_x}\), \({\mathcal {P}}_Y\) is an \(\overline{S}\)-contraction of Y and the following conditions are satisfied:

  1. (a)

    for every \(U\in {\mathscr {Y}}_{\mathsf {vc}}^{S}\), there exists a unique \(v \in Y\cap S\) such that \(U\equiv _{1}^{V_x} \{v\}\),

  2. (b)

    for every \(U\in {\mathscr {Y}}_{\mathsf {vc}}^{\overline{S}}\), there exists a unique \(P\in {\mathcal {P}}_Y\) such that \(U\equiv _{2}^{V_x} P\),

  3. (c)

    \(G[Y]_{\downarrow {\mathcal {P}}_Y}\) is a forest,

  4. (d)

    for every \(P\in {\mathcal {P}}_Y\) and \(\{v\}\in {\mathscr {X}}_{\mathsf {vc}}^{S}\), we have \(|N(v)\cap P |\leqslant 1\),

  5. (e)

    for every \(y\in Y\cap S\) and \(R\in {\mathscr {X}}_{\mathsf {vc}}^{\overline{S}}\cup {\mathcal {P}}_Y\), we have \(|N(y)\cap R| \leqslant 1\),

  6. (f)

    \(N({\mathscr {X}}_{\overline{\mathsf {vc}}})\cap V({\mathscr {Y}}_{\overline{\mathsf {vc}}})=\varnothing \), where \({\mathscr {Y}}_{\overline{\mathsf {vc}}}\) contains the blocks \(\{v\}\in \left( {\begin{array}{c}Y\cap S\\ 1\end{array}}\right) \) such that \(\mathsf {rep}_{1}^{\overline{V_x}}(\{v\})\notin {\mathscr {Y}}_{\mathsf {vc}}^{S}\) and the blocks \(P\in {\mathcal {P}}_Y\) such that \(\mathsf {rep}_{2}^{\overline{V_x}}(P)\notin {\mathscr {Y}}_{\mathsf {vc}}^{\overline{S}}\).

Let us give some explanations on the conditions of Definitions 12 and 13. Let X be a partial solution associated with an index \(i\in {\mathbb {I}}_x\) and \((Y,{\mathcal {P}}_Y)\) be a complement solution associated with i. Conditions (a) and (b) of both definitions guarantee that there exists a subset \(\mathsf {VC}\) of \(X_{\downarrow \mathsf {cc}(X{\setminus } S)}\cup Y_{\downarrow {\mathcal {P}}_Y}\) such that there is a one-to-one correspondence between the blocks of \(\mathsf {VC}\) and the representatives in \({\mathscr {X}}_{\mathsf {vc}}^{\overline{S}}\cup {\mathscr {X}}_{\mathsf {vc}}^{S}\cup {\mathscr {Y}}_{\mathsf {vc}}^{\overline{S}}\cup {\mathscr {Y}}_{\mathsf {vc}}^{S}\).

Condition (c) of Definition 12 guarantees that the connections between \(X_{\downarrow \mathsf {cc}(X{\setminus } S)}\) and \(\mathsf {VC}\) are acyclic. As explained earlier, Conditions (d) and (e) of both definitions are here to control the S-cycles which might disappear with the vertex contractions. In particular, by Fact 7, Conditions (c), (d) and (e) together imply that G[X] and G[Y] are S-forests.

Finally, as explained earlier, the last conditions of both definitions ensure that \(\mathsf {VC}\) the set described by \({\mathscr {X}}_{\mathsf {vc}}^{\overline{S}},{\mathscr {X}}_{\mathsf {vc}}^{S},{\mathscr {Y}}_{\mathsf {vc}}^{\overline{S}}\) and \({\mathscr {Y}}_{\mathsf {vc}}^{S}\) is a vertex cover of \(G[X,Y]_{\downarrow \mathsf {cc}(X{\setminus } S)\cup {\mathcal {P}}_Y}\). Notice that \(X{\setminus } V(\mathsf {VC}_X)\) and \(V({\mathscr {Y}}_{\overline{\mathsf {vc}}})\) correspond the set of vertices in X and Y, respectively, that do not belong to a block in the vertex cover \(\mathsf {VC}\). Such observations are used to prove the following two results.

Lemma 14

Let \(X\subseteq V_x\) and \(Y\subseteq \overline{V_x}\) such that \(G[X\cup Y]\) is an S-forest. There exist \(i\in {\mathbb {I}}_x\) and an \(\overline{S}\)-contraction \({\mathcal {P}}_Y\) of Y such that (1) \(G[X\cup Y]_{\downarrow \mathsf {cc} (X{\setminus } S)\cup {\mathcal {P}}_Y}\) is a forest, (2) X is a partial solution associated with i and (3) \((Y,{\mathcal {P}}_Y)\) is a complement solution associated with i.

Proof

By Lemma 9, there exists an \(\overline{S}\)-contraction \({\mathcal {P}}_Y\) of Y such that the following properties are satisfied:

  1. (A)

    \(G[X\cup Y]_{\downarrow \mathsf {cc}(X{\setminus } S)\cup {\mathcal {P}}_Y}\) is a forest,

  2. (B)

    for all \(P\in \mathsf {cc}(X{\setminus } S)\cup {\mathcal {P}}_Y\) and all \(v\in (X\cup Y)\cap S\), we have \(|N(v)\cap P|\leqslant 1\),

  3. (C)

    the graph \(G[X, Y]_{\downarrow \mathsf {cc}(X{\setminus } S)\cup {\mathcal {P}}_Y}\) admits a vertex cover \(\mathsf {VC}\) of size at most \(4\mathsf {mim}(V_x)\) such that the neighborhoods of the blocks in \(\mathsf {VC}\) are pairwise distinct in \(G[X, Y]_{\downarrow \mathsf {cc}(X{\setminus } S)\cup {\mathcal {P}}_Y}\).

We construct \(i=({\mathscr {X}}_{\mathsf {vc}}^{\overline{S}},{\mathscr {X}}_{\mathsf {vc}}^{S}, {\mathscr {X}}_{\overline{\mathsf {vc}}},{\mathscr {Y}}_{\mathsf {vc}}^{\overline{S}},{\mathscr {Y}}_{\mathsf {vc}}^{S})\in {\mathbb {I}}_x\) from \(\mathsf {VC}\) as follows:

  • \({\mathscr {X}}_{\mathsf {vc}}^{S}=\{\mathsf {rep}_{1}^{V_x}(\{v\}) \mid \{v\}\in \left( {\begin{array}{c}X\cap S\\ 1\end{array}}\right) \cap \mathsf {VC}\}\),

  • \({\mathscr {X}}_{\mathsf {vc}}^{\overline{S}}=\{\mathsf {rep}_{2}^{V_x}(P) \mid P\in \mathsf {cc}(X{\setminus }S) \cap \mathsf {VC}\}\),

  • \({\mathscr {X}}_{\overline{\mathsf {vc}}}= \mathsf {rep}_{1}^{V_x}(X{\setminus } V(\mathsf {VC}))\),

  • \({\mathscr {Y}}_{\mathsf {vc}}^{\overline{S}}= \{ \mathsf {rep}_{2}^{\overline{V_x}}(P)\mid P\in {\mathcal {P}}_Y\cap \mathsf {VC}\}\),

  • \({\mathscr {Y}}_{\mathsf {vc}}^{S}=\{\mathsf {rep}_{1}^{\overline{V_x}}(\{v\}) \mid \{v\}\in \left( {\begin{array}{c}Y\cap S\\ 1\end{array}}\right) \cap \mathsf {VC}\}\).

Since \(|\mathsf {VC}|\leqslant 4\mathsf {mim}(V_x)\), we have \(|{\mathscr {X}}_{\mathsf {vc}}^{\overline{S}}|+|{\mathscr {X}}_{\mathsf {vc}}^{S}|+|{\mathscr {Y}}_{\mathsf {vc}}^{\overline{S}}| + |{\mathscr {Y}}_{\mathsf {vc}}^{S}| \leqslant 4\mathsf {mim}(V_x)\) and thus we have \(i\in {\mathbb {I}}_x\).

We claim that X is a partial solution associated with i . By construction of i, Conditions (a), (b) and (f) of Definition 12 are satisfied. In particular, Condition (a) and (b) follow from Property (C), i.e. the neighborhoods of the blocks in \(\mathsf {VC}\) are pairwise distinct in \(G[X, Y]_{\downarrow \mathsf {cc}(X{\setminus } S)\cup {\mathcal {P}}_Y}\). So, the blocks in \(X_{\downarrow \mathsf {cc}(X{\setminus } S)}\cap \mathsf {VC}\) are pairwise non-equivalent for the d-neighbor equivalence over \(V_x\) for any \(d\in {\mathbb {N}}^+\) including 1 and 2. Consequently, there is a one to one correspondence between the blocks of \(X_{\downarrow \mathsf {cc}(X{\setminus } S)}\cap \mathsf {VC}\) and the representatives in \({\mathscr {X}}_{\mathsf {vc}}^{\overline{S}}\cup {\mathscr {X}}_{\mathsf {vc}}^{S}\).

It remains to prove Conditions (c), (d) and (e). We claim that Condition (c) is satisfied: \(\mathsf {aux}(X,i)\) is a forest. Observe that, by construction, \(\mathsf {aux}(X,i)\) is isomorphic to the graph \(G[X_{\downarrow \mathsf {cc}(X{\setminus } S)} \mid Y_{\downarrow {\mathcal {P}}_Y}\cap \mathsf {VC}]\). Indeed, for every \(P\in Y_{\downarrow {\mathcal {P}}_Y}\cap \mathsf {VC}\), by construction, there exists a unique \(U\in {\mathscr {Y}}_{\mathsf {vc}}^{\overline{S}}\cup {\mathscr {Y}}_{\mathsf {vc}}^{S}\) such that \(U\equiv _{1}^{\overline{V_x}} P\) or \(U\equiv _{2}^{\overline{V_x}} P\). In both case, we have \(N(U)\cap V_x=N(P)\cap V_x\) and thus, the neighborhood of P in \(G[X_{\downarrow \mathsf {cc}(X{\setminus } S)} \mid Y_{\downarrow {\mathcal {P}}_Y}\cap \mathsf {VC}]\) is the same as the neighborhood of U in \(\mathsf {aux}(X,i)\). Since \(G[X_{\downarrow \mathsf {cc}(X{\setminus } S)} \mid Y_{\downarrow {\mathcal {P}}_Y}\cap \mathsf {VC}]\) is a subgraph of \(G[X\cup Y]_{\downarrow \mathsf {cc}(X{\setminus } S)\cup {\mathcal {P}}_Y}\) and this latter graph is a forest, we deduce that \(\mathsf {aux}(X,i)\) is also a forest.

We deduce that Conditions (d) and (e) are satisfied from property (B) and Fact 11. Consequently, X is a partial solution associated with i.

Let us now prove that \((Y,{\mathcal {P}}_Y)\) is a complement solution associated with i. From the construction of i and with the same argument used earlier, we deduce that that Conditions (a) and (b) of Definition 13 are satisfied. By Property (A) \(G[X\cup Y]_{\downarrow \mathsf {cc}(X{\setminus } S)\cup {\mathcal {P}}_Y}\) is a forest, as a subgraph, \(G[Y]_{\downarrow {\mathcal {P}}_Y}\) is also a forest and thus Condition (c) is satisfied. Conditions (d) and (e) are satisfied from Property (B) and Fact 11.

It remains to prove Condition (f): \(N({\mathscr {X}}_{\overline{\mathsf {vc}}})\cap {\mathscr {Y}}_{\overline{\mathsf {vc}}}=\varnothing \) where \({\mathscr {Y}}_{\overline{\mathsf {vc}}}\) contains the blocks \(\{v\}\in \left( {\begin{array}{c}Y\cap S\\ 1\end{array}}\right) \) such that \(\mathsf {rep}_{1}^{\overline{V_x}}(\{v\})\notin {\mathscr {Y}}_{\mathsf {vc}}^{S}\) and the blocks \(P\in {\mathcal {P}}_Y\) such that \(\mathsf {rep}_{2}^{\overline{V_x}}(P)\notin {\mathscr {Y}}_{\mathsf {vc}}^{\overline{S}}\). By construction, \({\mathscr {Y}}_{\overline{\mathsf {vc}}} = Y {\setminus } V(\mathsf {VC})\). Since, \(\mathsf {VC}\) is a vertex cover of the graph \(G[X, Y]_{\downarrow \mathsf {cc}(X{\setminus } S)\cup {\mathcal {P}}_Y}\), there are no edges between \(X_{\downarrow \mathsf {cc}(X{\setminus } S)}{\setminus }\mathsf {VC}\) and \(Y_{\downarrow {\mathcal {P}}_Y}{\setminus } \mathsf {VC}\) in \(G[X, Y]_{\downarrow \mathsf {cc}(X{\setminus } S)\cup {\mathcal {P}}_Y}\). We deduce that \(N(X {\setminus } V(\mathsf {VC})) \cap {\mathscr {Y}}_{\overline{\mathsf {vc}}}= \varnothing \). Since \(X {\setminus } V(\mathsf {VC})\equiv _{1}^{V_x} {\mathscr {X}}_{\overline{\mathsf {vc}}}\), we conclude that \(N({\mathscr {X}}_{\overline{\mathsf {vc}}})\cap {\mathscr {Y}}_{\overline{\mathsf {vc}}}=\varnothing \). This proves that \((Y,{\mathcal {P}}_Y)\) is a complement solution associated with i. \(\square \)

Lemma 15

Let \(i=({\mathscr {X}}_{\mathsf {vc} }^{\overline{S}},{\mathscr {X}}_{\mathsf {vc} }^{S}, {\mathscr {X}}_{\overline{\mathsf {vc} }},{\mathscr {Y}}_{\mathsf {vc} }^{\overline{S}},{\mathscr {Y}}_{\mathsf {vc} }^{S})\in {\mathbb {I}}_x\), X be a partial solution associated with i and \((Y,{\mathcal {P}}_Y)\) be a complement solution associated with i. If the graph \(G[X\cup Y]_{\downarrow \mathsf {cc} (X{\setminus } S)\cup {\mathcal {P}}_Y}\) is a forest, then \(G[X\cup Y]\) is an S-forest.

Proof

Assume that \(G[X\cup Y]_{\downarrow \mathsf {cc}(X{\setminus } S)\cup {\mathcal {P}}_Y}\) is a forest. By Fact 7, in order to prove that \(G[X\cup Y]\) is an S-forest, it is enough to prove that for all \(v\in (X\cup Y)\cap S\) and all \(P\in \mathsf {cc}(X{\setminus } S)\cup {\mathcal {P}}_Y\), we have \(|N(v)\cap P|\leqslant 1\). Let us prove this statement for a vertex \(v\in X\cap S\) the proof is symmetric for \(v\in Y\cap S\). Let \(P\in (X\cup Y)_{\downarrow \mathsf {cc}(X{\setminus } S)\cup {\mathcal {P}}_Y}\). If \(P\notin (\mathsf {cc}(X{\setminus } S)\cup {\mathcal {P}}_Y)\), then P is a singleton in \(\left( {\begin{array}{c}X\cup Y\\ 1\end{array}}\right) \) and we are done. If \(P\in \mathsf {cc}(X{\setminus } S)\), then Condition (e) of Definition 12 guarantees that we have \(|N(v)\cap P|\leqslant 1\).

Assume now that \(P\in {\mathcal {P}}_Y\). Suppose first that \(\mathsf {rep}_{2}^{\overline{V_x}}(P)\notin {\mathscr {Y}}_{\mathsf {vc}}^{\overline{S}}\). From Condition (f) of Definition 13, we have \(N(P)\cap {\mathscr {X}}_{\overline{\mathsf {vc}}}=\varnothing \). Let \(r=\mathsf {rep}_{1}^{V_x}(\{v\})\). From the definition of \({\mathscr {X}}_{\overline{\mathsf {vc}}}\) in Definition 12, we deduce that if \(r\notin {\mathscr {X}}_{\mathsf {vc}}^{S}\), then \(N(v)\cap \overline{V_x}\subseteq N({\mathscr {X}}_{\overline{\mathsf {vc}}})\) and thus \(N(v)\cap P=\varnothing \). On the other hand, if \(r\in {\mathscr {X}}_{\mathsf {vc}}^{S}\), then Condition (d) of Definition 13 ensures that \(|N(r)\cap P|\leqslant 1\) and thus \(|N(v)\cap P|\leqslant 1\). Now, suppose that \(\mathsf {rep}_{2}^{\overline{V_x}}(P)\in {\mathscr {Y}}_{\mathsf {vc}}^{\overline{S}}\). By Condition (e) of Definition 12, we know that \(|N(v)\cap \mathsf {rep}_{2}^{\overline{V_x}}(P)|\leqslant 1\). From Fact 11, we conclude that \(|N(v)\cap P|\leqslant 1\). This concludes the proof of Lemma 15. \(\square \)

For each index \(i\in {\mathbb {I}}_x\), we will design an equivalence relation \(\sim _i\) between the partial solutions associated with i. We will prove that, for any partial solutions X and W associated with i, if \(X\sim _i W\), then, for any complement solution \(Y\subseteq \overline{V_x}\) associated with i, the graph \(G[X\cup Y]\) is an S-forest if and only if \(G[W\cup Y]\) is an S-forest. Then, given a set of partial solutions \({\mathcal {A}}\) whose size needs to be reduced, it is sufficient to keep, for each \(i\in {\mathbb {I}}_x\) and each equivalence class \({\mathcal {C}}\) of \(\sim _i\), one partial solution in \({\mathcal {C}}\) of maximal weight. The resulting set of partial solutions has size bounded by \(|{\mathbb {I}}_x|\cdot (4\mathsf {mim}(V_x))^{4\mathsf {mim}(V_x)}\) because \(\sim _i\) generates at most \((4\mathsf {mim}(V_x))^{4\mathsf {mim}(V_x)}\) equivalence classes.

Intuitively, given two partial solutions X and W associated with \(i=({\mathscr {X}}_{\mathsf {vc}}^{\overline{S}},{\mathscr {X}}_{\mathsf {vc}}^{S}, {\mathscr {X}}_{\overline{\mathsf {vc}}},{\mathscr {Y}}_{\mathsf {vc}}^{\overline{S}},{\mathscr {Y}}_{\mathsf {vc}}^{S})\), we have \(X\sim _i W\) if the blocks of \(\mathsf {VC}\) (i.e., the vertex cover described by i) are equivalently connected in \(G[X_{\downarrow \mathsf {cc}(X{\setminus } S)}\mid {\mathscr {Y}}_{\mathsf {vc}}^{\overline{S}} \cup {\mathscr {Y}}_{\mathsf {vc}}^{S} ]\) and \(G[W_{\downarrow \mathsf {cc}(W{\setminus } S)}\mid {\mathscr {Y}}_{\mathsf {vc}}^{\overline{S}} \cup {\mathscr {Y}}_{\mathsf {vc}}^{S} ]\). In order to compare these connections, we use the following notion.

Definition 16

(\(\mathsf {cc}(X,i)\)) Let \(i=({\mathscr {X}}_{\mathsf {vc}}^{\overline{S}},{\mathscr {X}}_{\mathsf {vc}}^{S}, {\mathscr {X}}_{\overline{\mathsf {vc}}},{\mathscr {Y}}_{\mathsf {vc}}^{\overline{S}},{\mathscr {Y}}_{\mathsf {vc}}^{S})\in {\mathbb {I}}_x\) and \(X\subseteq V_x\) be a partial solution associated with i. For each connected component C of \(\mathsf {aux}(X,i)\), we define the set \(C_\mathsf {vc}\) as follows:

  • for every \(U\in C\) such that \(U\in {\mathscr {Y}}_{\mathsf {vc}}^{\overline{S}} \cup {\mathscr {Y}}_{\mathsf {vc}}^{S}\), we have \(U \in C_\mathsf {vc}\),

  • for every \(\{v\}\in \left( {\begin{array}{c}X\cap S\\ 1\end{array}}\right) \cap C\) such that \(\{v\}\equiv _{1}^{V_x} R\) for some \(R\in {\mathscr {X}}_{\mathsf {vc}}^{S}\), we have \(R\in C_\mathsf {vc}\),

  • for every \(U\in \mathsf {cc}(X{\setminus } S)\) such that \(U\equiv _{2}^{V_x} R\) for some \(R \in {\mathscr {X}}_{\mathsf {vc}}^{\overline{S}}\), we have \(R \in C_\mathsf {vc}\).

We define \(\mathsf {cc}(X,i)\) as the collection \(\{C_\mathsf {vc}\mid C \text { is a connected component of } \mathsf {aux}(X,i)\}\).

For a connected component C of \(\mathsf {aux}(X,i)\), the set \(C_\mathsf {vc}\) contains \(C \cap ({\mathscr {Y}}_{\mathsf {vc}}^{\overline{S}}\cup {\mathscr {Y}}_{\mathsf {vc}}^{S})\) and the representatives of the blocks in \(C\cap X_{\downarrow \mathsf {cc}(X{\setminus } S)}\cap \mathsf {VC}\) with \(\mathsf {VC}\) the vertex cover described by i. Consequently, for every \(X\subseteq V_x\) and \(i\in {\mathbb {I}}_x\), the collection \(\mathsf {cc}(X,i)\) is partition of \({\mathscr {X}}_{\mathsf {vc}}^{\overline{S}}\cup {\mathscr {X}}_{\mathsf {vc}}^{S}\cup {\mathscr {Y}}_{\mathsf {vc}}^{\overline{S}}\cup {\mathscr {Y}}_{\mathsf {vc}}^{S}\). For the example given in Fig. 3, observe that \(\mathsf {cc}(X,i)\) is the partition that contains \(\{R_1,U_1,U_2\}\), \(\{R_2,U_3\}\) and \(\{U_4\}\) (see also Fig. 13)

Now we are ready to give the notion of equivalence between partial solutions. We say that two partial solutions XW associated with i are i-equivalent, denoted by \(X\sim _i W\), if \(\mathsf {cc}(X,i)=\mathsf {cc}(W,i)\). Our next result is the most crucial step. As already explained, our task is to show equivalence between partial solutions under any complement solution with respect to S-forests. Figure 14 gives an example of two i-equivalent partial solutions.

Lemma 17

Let \(i=({\mathscr {X}}_{\mathsf {vc} }^{\overline{S}},{\mathscr {X}}_{\mathsf {vc} }^{S}, {\mathscr {X}}_{\overline{\mathsf {vc} }},{\mathscr {Y}}_{\mathsf {vc} }^{\overline{S}},{\mathscr {Y}}_{\mathsf {vc} }^{S})\in {\mathbb {I}}_x\). For every partial solutions XW associated with i such that \(X\sim _i W\) and for every complement solution \((Y,{\mathcal {P}}_Y)\) associated with i, the graph \(G[X\cup Y]_{\downarrow \mathsf {cc} (X{\setminus } S)\cup {\mathcal {P}}_Y}\) is a forest if and only if the graph \(G[W\cup Y]_{\downarrow \mathsf {cc} (W{\setminus } S)\cup {\mathcal {P}}_Y}\) is a forest.

Proof

Let XW be two partial solutions associated with i such that \(X\sim _i W\) and let \((Y,{\mathcal {P}}_Y)\) be a complement solution associated with i. To prove this lemma, we show that if \(G[W\cup Y]_{\downarrow \mathsf {cc}(W{\setminus } S)\cup {\mathcal {P}}_Y}\) contains a cycle, then \(G[X\cup Y]_{\downarrow \mathsf {cc}(X{\setminus } S)\cup {\mathcal {P}}_Y}\) contains a cycle too. See Fig. 16 for some intuitions on this proof. We will use the following notation in this proof.

For \(Z\in \{X,W\}\), we denote by \(\mathsf {VC}_Z\) the set that contains:

  • all \(\{v\}\in \left( {\begin{array}{c}Z\cap S\\ 1\end{array}}\right) \) such that \(\mathsf {rep}_{1}^{V_x}(\{v\})\in {\mathscr {X}}_{\mathsf {vc}}^{S}\),

  • all \(P\in \mathsf {cc}(Z{\setminus } S)\) such that \(\mathsf {rep}_{2}^{V_x}(P)\in {\mathscr {X}}_{\mathsf {vc}}^{\overline{S}}\).

We define also \(\mathsf {VC}_Y\) as the set that contains:

  • all \(\{v\}\in \left( {\begin{array}{c}Y\cap S\\ 1\end{array}}\right) \) such that \(\mathsf {rep}_{1}^{\overline{V_x}}(\{v\})\in {\mathscr {Y}}_{\mathsf {vc}}^{S}\),

  • all \(P\in {\mathcal {P}}_Y\) such that \(\mathsf {rep}_{2}^{\overline{V_x}}(P)\in {\mathscr {Y}}_{\mathsf {vc}}^{\overline{S}}\).

The sets \(\mathsf {VC}_X,\mathsf {VC}_W\) and \(\mathsf {VC}_Y\) contain the blocks in \(X_{\downarrow \mathsf {cc}(X{\setminus } S)}, W_{\downarrow \mathsf {cc}(W{\setminus }S)}\) and \(Y_{\downarrow {\mathcal {P}}_Y}\), respectively, which belong to the vertex cover described by i. Finally, for each \(Z\in \{X,W\}\), we define the following two edge-disjoint subgraphs of \(G[Z\cup Y]_{\downarrow \mathsf {cc}(Z{\setminus }S)\cup {\mathcal {P}}_Y}\):

  • \(G_Z=G[Z_{\downarrow \mathsf {cc}(Z{\setminus }S)} \mid \mathsf {VC}_Y]\),

  • \(\overline{G_Z}= G[Z\cup Y]_{\downarrow \mathsf {cc}(Z{\setminus }S)\cup {\mathcal {P}}_Y} - G_Z\).

As explained in the proof of Lemma 14, for any \(Z\in \{X,W\}\), the graph \(\mathsf {aux}(Z,i)\) is isomorphic to the graph \(G_Z\). Informally, \(G_Z\) contains the edges of \(G[Z\cup Y]_{\downarrow \mathsf {cc}(Z{\setminus }S)\cup {\mathcal {P}}_Y}\) which are induced by \(Z_{\downarrow \mathsf {cc}(Z{\setminus }S)}\) and those between \(Z_{\downarrow \mathsf {cc}(Z{\setminus }S)}\) and \(\mathsf {VC}_Y\). The following fact implies that \(\overline{G_Z}\) contains the edges of \(G[Z\cup Y]_{\downarrow \mathsf {cc}(Z{\setminus }S)\cup {\mathcal {P}}_Y}\) that are induced by \(Y_{\downarrow {\mathcal {P}}_Y}\) and those between \(Y_{\downarrow {\mathcal {P}}_Y} {\setminus }\mathsf {VC}_Y\) and \(\mathsf {VC}_Z\).

Fact 18

For any \(Z\in \{X,W\}\), the set \(\mathsf {VC} _Z\cup \mathsf {VC} _Y\) is a vertex cover of \(G[Z,Y]_{\downarrow \mathsf {cc} (Z{\setminus }S)\cup {\mathcal {P}}_Y}\).

Proof

First observe that \(N(Y{\setminus }V(\mathsf {VC}_Y)) \cap {\mathscr {X}}_{\overline{\mathsf {vc}}}=\varnothing \) thanks to Condition (f) of Definition 13. Moreover, we have \({\mathscr {X}}_{\overline{\mathsf {vc}}}\equiv _{1}^{V_x} Z{\setminus }V(\mathsf {VC}_Z)\) by Condition (f) of Definition 12. We conclude that there are no edges between \(Y_{\downarrow {\mathcal {P}}_Y}{\setminus }\mathsf {VC}_Y\) and \(Z_{\downarrow \mathsf {cc}(Z{\setminus }S)}{\setminus }\mathsf {VC}_Z\) in \(G[Z,Y]_{\downarrow \mathsf {cc}(Z{\setminus }S)\cup {\mathcal {P}}_Y}\). Hence, \(\mathsf {VC}_Z\cup \mathsf {VC}_Y\) is a vertex cover of \(G[Z,Y]_{\downarrow \mathsf {cc}(Z{\setminus } S)\cup {\mathcal {P}}_Y}\). \(\square \)

Assume that \(G[W\cup Y]_{\downarrow \mathsf {cc}(W{\setminus }S)\cup {\mathcal {P}}_Y}\) contains a cycle C. Our task is to show that \(G[X\cup Y]_{\downarrow \mathsf {cc}(X{\setminus }S)\cup {\mathcal {P}}_Y}\) contains a cycle as well. We first explore properties of C with respect to \(G_W\) and \(\overline{G_W}\). Since the graph \(\mathsf {aux}(W,i)\) is a forest and it is isomorphic to \(G_W\), we know that C must contain at least one edge from \(\overline{G_W}\). Moreover, C must go though a block of \(W_{\downarrow \mathsf {cc}(W{\setminus }S)}\) because \(G[Y]_{\downarrow {\mathcal {P}}_Y}\) is a forest. Consequently, (and because from Fact 18\(\mathsf {VC}_W\cup \mathsf {VC}_Y\) is a vertex cover of \(G[W\cup Y]_{\downarrow \mathsf {cc}(W{\setminus }S)\cup {\mathcal {P}}_Y}\)), we deduce that C is the concatenation of edge-disjoint paths \(P_1\dots P_t\) such that for each \(\ell \in [t]\) we have:

  • \(P_\ell \) is a non-empty path with endpoints in \(\mathsf {VC}_W\cup \mathsf {VC}_Y\) and internal blocks not in \(\mathsf {VC}_W\cup \mathsf {VC}_Y\) and \(P_\ell \) is either a path of \(G_W\) or \(\overline{G_W}\).

At least one of these paths is in \(\overline{G_W}\) and, potentially, C may be entirely contained in \(\overline{G_W}\). Figure 4 presents two possible interactions between C and the graphs \(G_W\) and \(\overline{G_W}\).

Fig. 4
figure 4

How cycles in \(G[W\cup Y]_{\downarrow \mathsf {cc}(W{\setminus }S)\cup {\mathcal {P}}_Y}\) may interact with the graphs \(G_W\) and \(\overline{G_W}\). The solid edges belong to \(G_W\) and the dashed edges belong to \(\overline{G_W}\)

Given an endpoint \(U\in \mathsf {VC}_W\cup \mathsf {VC}_Y\) of one of the paths \(P_1,\dots ,P_\ell \), we define \(U_X\) and \(U_i\) as the analogs of U in \(\mathsf {VC}_X\cup \mathsf {VC}_Y\) and \({\mathscr {X}}_{\mathsf {vc}}^{\overline{S}}\cup {\mathscr {X}}_{\mathsf {vc}}^{S} \cup {\mathscr {Y}}_{\mathsf {vc}}^{\overline{S}}\cup {\mathscr {Y}}_{\mathsf {vc}}^{S}\), respectively, as follows:

  • if \(U\in \mathsf {cc}(W{\setminus }S)\), then \(U_X\) and \(U_i\) are the unique elements of \(\mathsf {cc}(X{\setminus }S)\) and \({\mathscr {X}}_{\mathsf {vc}}^{\overline{S}}\), respectively, such that \(U\equiv _{2}^{V_x} U_X \equiv _{2}^{V_x} U_i\),

  • if \(U=\{v\}\in \left( {\begin{array}{c}W\cap S\\ 1\end{array}}\right) \), then \(U_X\) and \(U_i\) are the unique elements in \(\left( {\begin{array}{c}X\cap S\\ 1\end{array}}\right) \) and \({\mathscr {X}}_{\mathsf {vc}}^{S}\), respectively, such that \(U\equiv _{1}^{V_x} U_X \equiv _{1}^{V_x} U_i\),

  • if \(U\in {\mathcal {P}}_Y\), then \(U_X=U\) and \(U_i\) is the unique element of \({\mathscr {Y}}_{\mathsf {vc}}^{\overline{S}}\) such that \(U\equiv _{2}^{\overline{V_x}} U_i\);

  • otherwise, if \(U=\{v\}\in \left( {\begin{array}{c}Y\cap S\\ 1\end{array}}\right) \), then \(U_X=U\) and \(U_i\) is the unique element of \({\mathscr {Y}}_{\mathsf {vc}}^{S}\) such that \(U\equiv _{1}^{\overline{V_x}} U_i\).

Observe that \(U_X\) and \(U_i\) exist by Conditions (a) and (b) of Definitions 12 and 13.

For each \(\ell \in [t]\), we construct a non-empty path \(P'_\ell \) whose endpoints are the analogs in \(\mathsf {VC}_X\cup \mathsf {VC}_Y\) of the endpoints of \(P_\ell \) and such that if \(P_\ell \) is a path in \(G_W\) (resp. \(\overline{G_W}\)), then \(P'_\ell \) is a path in \(G_X\) (resp. \(\overline{G_X}\)). This is sufficient to prove the claim because thanks to this, we can construct a closed walk in \(G[X\cup Y]_{\downarrow \mathsf {cc}(X{\setminus }S)\cup {\mathcal {P}}_Y}\) by concatenating the paths \(P'_1,\dots ,P'_t\). Since \(G_X\) and \(\overline{G_X}\) are edge-disjoint and the paths \(P'_1,\dots ,P'_t\) are non-empty paths, this closed walk must contain a cycle.

Let \(\ell \in [t]\) and UT be the endpoints of \(P_\ell \). We denote by \(U_X,T_X,U_i\) and \(T_i\) the analogs of U and T in \(\mathsf {VC}_X\cup \mathsf {VC}_Y\) and \({\mathscr {X}}_{\mathsf {vc}}^{\overline{S}}\cup {\mathscr {X}}_{\mathsf {vc}}^{S} \cup {\mathscr {Y}}_{\mathsf {vc}}^{\overline{S}}\cup {\mathscr {Y}}_{\mathsf {vc}}^{S}\), respectively.

First, assume that \(P_\ell \) is path of \(G_W\). Observe that \(U_i\) and \(T_i\) belong to the same partition class of \(\mathsf {cc}(W,i)\). This follows from the definitions of \(U_i,T_i\) and the fact that \(G_W\) is isomorphic to \(\mathsf {aux}(W,i)\). As \(W\sim _i X\), we deduce that \(U_i\) and \(T_i\) belong to the same partition class of \(\mathsf {cc}(X,i)\). By construction, \(U_i\) and \(T_i\) are the analogs of \(U_X\) and \(T_X\) in \({\mathscr {X}}_{\mathsf {vc}}^{\overline{S}}\cup {\mathscr {X}}_{\mathsf {vc}}^{S} \cup {\mathscr {Y}}_{\mathsf {vc}}^{\overline{S}}\cup {\mathscr {Y}}_{\mathsf {vc}}^{S}\). We conclude that \(U_X\) and \(T_X\) are connected in \(G_X\) via a path \(P'_\ell \). We claim that \(P'_\ell \) is not empty because we have \(U_X\ne T_X\). As \(P_\ell \) is a non empty path of \(G_W\) and because \(G_W\) is acyclic, we know that U and T are distinct. Hence, by the construction of \(U_X\) and \(T_X\), we deduce that \(U_X\ne T_X\).

Now, assume that \(P_\ell \) is a non-empty path of \(\overline{G_W}\). Since \(\mathsf {VC}_W\cup \mathsf {VC}_Y\) is a vertex cover of \(G[W,Y]_{\downarrow \mathsf {cc}(W{\setminus }S)\cup {\mathcal {P}}_Y}\), the blocks in \(W_{\downarrow \mathsf {cc}(W{\setminus }S)}\) that do not belong to \(VC_W\) are isolated in \(\overline{G_W}\). As \(P_\ell \) is not empty, the blocks of \(P_\ell \) which belong to \(W_{\downarrow \mathsf {cc}(W{\setminus }S)}\) are in \(\mathsf {VC}_W\). Because the internal blocks of the paths \(P_1,\dots ,P_t\) are not in \(\mathsf {VC}_W\cup \mathsf {VC}_Y\), we deduce that the internal blocks of \(P_\ell \) belong to \(Y_{\downarrow {\mathcal {P}}_Y}\). We distinguish the following cases:

  • If both endpoints of \(P_\ell \) belong to \(\mathsf {VC}_Y\), then \(U_X=U\), \(T_X=T\) and all the blocks of \(P_\ell \) belong to \(Y_{\downarrow {\mathcal {P}}_Y}\). It follows that \(P_\ell \) is a non-empty path of \(\overline{G_X}\) because \(G[Y]_{\downarrow {\mathcal {P}}_Y}\) is a subgraph of \(\overline{G_X}\). In this case, we take \(P'_\ell =P_\ell \).

  • Assume now that one or two endpoints of \(P_\ell \) belong to \(\mathsf {VC}_W\). Suppose w.l.o.g. that U belongs to \(\mathsf {VC}_W\). Since \(P_\ell \) is non-empty and the internal blocks of \(P_\ell \) are in \(Y_{\downarrow {\mathcal {P}}_Y}\), U has a neighbor \(Q\in Y_{\downarrow {\mathcal {P}}_Y}\) in \(P_\ell \). We claim that Q is adjacent to \(U_X\) in \(\overline{G_X}\). By definition of \(U_X\), we have \(U\equiv _{d}^{V_x} U_X\) for some \(d\in \{1,2\}\) and in particular \(N(U)\cap \overline{V_x}= N(U_X)\cap \overline{V_x}\). As U and Q are adjacent in \(\overline{G_W}\), we deduce that \(N(U)\cap Q \ne \varnothing \). It follows that \(N(U_X)\cap Q\ne \varnothing \) and thus Q and \(U_X\) are adjacent in \(\overline{G_X}\). Symmetrically, we can prove that if \(T\in \mathsf {VC}_W\), then the neighbor of T in \(P_\ell \) is adjacent to \(T_X\) in \(\overline{G_X}\). Hence, the neighbors of U and T in \(P_\ell \) are adjacent to \(U_X\) and \(T_X\) respectively in \(\overline{G_X}\). We obtain \(P_\ell '\) from \(P_\ell \) by replacing U and T by \(U_X\) and \(T_X\). Since the internal blocks of \(P_\ell \) belong to \(Y_{\downarrow {\mathcal {P}}_Y}\) and \(G[Y]_{\downarrow {\mathcal {P}}_Y}\) is a subgraph of \(\overline{G_X}\), we deduce that \(P'_\ell \) is a path of \(\overline{G_X}\). The path \(P'_\ell \) is not-empty because it contains \(U_X\) and Q which are distinct blocks of \(\overline{G_X}\) as \(U_X\in \mathsf {VC}_X\) (since \(U\in \mathsf {VC}_W\) by assumption) and \(Q\in Y_{\downarrow {\mathcal {P}}_Y}\).

\(\square \)

The following theorem proves that, for every set of partial solutions \({\mathcal {A}}\subseteq 2^{V_x}\), we can compute a small subset \({\mathcal {B}}\subseteq {\mathcal {A}}\) such that \({\mathcal {B}}\) represents \({\mathcal {A}}\), i.e., for every \(Y\subseteq \overline{V_x}\), the best solutions we obtain from the union of Y with a set in \({\mathcal {A}}\) are as good as the ones we obtain from \({\mathcal {B}}\). Firstly, we formalize this notion of representativity.

Definition 19

(Representativity) For every \({\mathcal {A}}\subseteq 2^{V_x}\) and \(Y\subseteq \overline{V_x}\), we define

$$\begin{aligned} \mathsf {best}({\mathcal {A}},Y)= \mathsf {max}\{ {\mathsf {w}}(X) \mid X\in {\mathcal {A}}\text { and } G[X\cup Y] \text { is an } S\text {-forest} \} .\end{aligned}$$

Given \({\mathcal {A}},{\mathcal {B}}\subseteq 2^{V_x}\), we say that \({\mathcal {B}}\) represents \({\mathcal {A}}\) if, for every \(Y\subseteq \overline{V_x}\), we have \(\mathsf {best}({\mathcal {A}},Y)=\mathsf {best}({\mathcal {B}},Y)\).

We recall that \(\mathsf {s\text {-}nec}_2(A)=\mathsf {max}(\mathsf {nec}_2(A),\mathsf {nec}_2(\overline{A}))\).

Lemma 20

There exists an algorithm \(\mathsf {reduce} \) that, given a set \({\mathcal {A}}\subseteq 2^{V_x}\), outputs in time \(O(|{\mathcal {A}}|\cdot |{\mathbb {I}}_x| \cdot (4\mathsf {mim} (V_x))^{4\mathsf {mim} (V_x)}\cdot \log (\mathsf {s-nec} _2(V_x)) \cdot n^3)\) a subset \({\mathcal {B}}\subseteq {\mathcal {A}}\) such that \({\mathcal {B}}\) represents \({\mathcal {A}}\) and \(|{\mathcal {B}}|\leqslant |{\mathbb {I}}_x| \cdot (4\mathsf {mim} (V_x))^{4\mathsf {mim} (V_x)}\).

Proof

Given \({\mathcal {A}}\subseteq 2^{V_x}\) and \(i\in {\mathbb {I}}_x\), we define \(\mathsf {reduce}({\mathcal {A}},i)\) as the operation which returns a set containing one partial solution \(X\in {\mathcal {A}}\) associated with i of each equivalence class of \(\sim _i\) such that \({\mathsf {w}}(X)\) is maximum. Moreover, we define \(\mathsf {reduce}({\mathcal {A}})= \bigcup _{i\in {\mathbb {I}}_x}\mathsf {reduce}({\mathcal {A}},i)\).

We prove first that \(\mathsf {reduce}({\mathcal {A}})\) represents \({\mathcal {A}}\), that is \(\mathsf {best}({\mathcal {A}},Y)=\mathsf {best}(\mathsf {reduce}({\mathcal {A}}),Y)\) for all \(Y\subseteq \overline{V_x}\). Let \(Y\subseteq \overline{V_x}\). Since \(\mathsf {reduce}({\mathcal {A}})\subseteq {\mathcal {A}}\), we already have \(\mathsf {best}(\mathsf {reduce}({\mathcal {A}}),Y)\leqslant \mathsf {best}({\mathcal {A}},Y)\). Consequently, if there is no \(X\in {\mathcal {A}}\) such that \(G[X\cup Y]\) is an S-forest, we have \(\mathsf {best}(\mathsf {reduce}({\mathcal {A}}),Y)= \mathsf {best}({\mathcal {A}},Y)=\mathsf {max}(\varnothing )=-\infty \).

Assume that there exists \(X\in {\mathcal {A}}\) such that \(G[X\cup Y]\) is an S-forest. Let \(X\in {\mathcal {A}}\) such that \(G[X\cup Y]\) is an S-forest and \({\mathsf {w}}(X)=\mathsf {best}({\mathcal {A}},Y)\). By Lemma 14, there exists \(i\in {\mathbb {I}}_x\) and an \(\overline{S}\)-contraction \({\mathcal {P}}_Y\) of Y such that (1) \(G[X\cup Y]_{\downarrow \mathsf {cc}(X{\setminus }S)\cup {\mathcal {P}}_Y}\) is a forest, (2) X is a partial solution associated with i and (3) \((Y,{\mathcal {P}}_Y)\) is a complement solution associated with i.

From the construction of \(\mathsf {reduce}({\mathcal {A}},i)\), there exists \(W\in \mathsf {reduce}({\mathcal {A}})\) such that W is a partial solution associated with i, \(X\sim _i W\), and \({\mathsf {w}}(W)\ge {\mathsf {w}}(X)\). By Lemma 17 and since \(G[X\cup Y]_{\downarrow \mathsf {cc}(X{\setminus }S)\cup {\mathcal {P}}_Y}\) is a forest, we deduce that \(G[W\cup Y]_{\downarrow \mathsf {cc}(W{\setminus }S)\cup {\mathcal {P}}_Y}\) is a forest too. Thanks to Lemma 15, we deduce that \(G[W\cup Y]\) is an S-forest. As \({\mathsf {w}}(W)\ge {\mathsf {w}}(X)=\mathsf {best}({\mathcal {A}},Y)\), we conclude that \(\mathsf {best}({\mathcal {A}},Y)=\mathsf {best}(\mathsf {reduce}({\mathcal {A}}),Y)\). Hence, \(\mathsf {reduce}({\mathcal {A}})\) represents \({\mathcal {A}}\).

We claim that \(|\mathsf {reduce}({\mathcal {A}})| \leqslant |{\mathbb {I}}_x| \cdot (4\mathsf {mim}(V_x))^{4\mathsf {mim}(V_x)}\). For every \(i=({\mathscr {X}}_{\mathsf {vc}}^{\overline{S}},{\mathscr {X}}_{\mathsf {vc}}^{S}, {\mathscr {X}}_{\overline{\mathsf {vc}}},{\mathscr {Y}}_{\mathsf {vc}}^{\overline{S}},{\mathscr {Y}}_{\mathsf {vc}}^{S})\in {\mathbb {I}}_x\) and partial solution X associated with i, \(\mathsf {cc}(X,i)\) is a partition of \({\mathscr {X}}_{\mathsf {vc}}^{\overline{S}}\cup {\mathscr {X}}_{\mathsf {vc}}^{S}\cup {\mathscr {X}}_{\overline{\mathsf {vc}}} \cup {\mathscr {Y}}_{\mathsf {vc}}^{\overline{S}} \cup {\mathscr {Y}}_{\mathsf {vc}}^{S}\). Since \(|{\mathscr {X}}_{\mathsf {vc}}^{\overline{S}}|+|{\mathscr {X}}_{\mathsf {vc}}^{S}|+|{\mathscr {Y}}_{\mathsf {vc}}^{\overline{S}}| + |{\mathscr {Y}}_{\mathsf {vc}}^{S}| \leqslant 4\mathsf {mim}(V_x)\), there are at most \((4\mathsf {mim}(V_x))^{4\mathsf {mim}(V_x)}\) possible values for \(\mathsf {cc}(X,i)\). We deduce that, for every \(i\in {\mathbb {I}}_x\), the relation \(\sim _i\) generates at most \((4\mathsf {mim}(V_x))^{4\mathsf {mim}(V_x)}\) equivalence classes, so \(|\mathsf {reduce}({\mathcal {A}},i)|\leqslant (4\mathsf {mim}(V_x))^{4\mathsf {mim}(V_x)}\) for every \(i\in {\mathbb {I}}_x\). By construction, we conclude that \(|\mathsf {reduce}({\mathcal {A}})|\leqslant |{\mathbb {I}}_x| \cdot (4\mathsf {mim}(V_x))^{4\mathsf {mim}(V_x)}\).

It remains to prove the runtime. As \(\mathsf {nec}_1(V_x)\leqslant \mathsf {nec}_2(V_x)\), by Lemma 5 we can compute in time \(O(\mathsf {s\text {-}nec}_2(V_x) \cdot \log (\mathsf {s\text {-}nec}_2(V_x)) \cdot n^2)\) the sets \({\mathcal {R}}_{1}^{V_x},{\mathcal {R}}_{2}^{V_x}\), \({\mathcal {R}}_{2}^{\overline{V_x}}\) and data structures which compute \(\mathsf {rep}_{1}^{V_x},\mathsf {rep}_{2}^{V_x}\) and \(\mathsf {rep}_{2}^{\overline{V_x}}\) in time \(O(\log (\mathsf {s\text {-}nec}_2(V_x))\cdot n^2)\). Given \({\mathcal {R}}_{1}^{V_x},{\mathcal {R}}_{2}^{V_x}\), \({\mathcal {R}}_{2}^{\overline{V_x}}\), we can compute \({\mathbb {I}}_x\) in time \(O(|{\mathbb {I}}_x|\cdot n^2)\). Since, \(\mathsf {s\text {-}nec}_2(V_x)\leqslant |{\mathbb {I}}_x|\), the time required to compute these sets and data structures is less than \(O(|{\mathcal {A}}|\cdot |{\mathbb {I}}_x| \cdot (4\mathsf {mim}(V_x))^{4\mathsf {mim}(V_x)}\cdot \log (\mathsf {s\text {-}nec}_2(V_x)) \cdot n^3)\).

For each \(i\in {\mathbb {I}}_x\) and \(X\in {\mathcal {A}}\), we can decide whether X is a partial solution associated with i and compute \(\mathsf {aux}(X,i)\), \(\mathsf {cc}(X,i)\) in time \(O(\log (\mathsf {s\text {-}nec}_2(V_x))\cdot n^3)\). For doing so, we simply start by computing \(\mathsf {rep}_{2}^{V_x}(C)\) and \(\mathsf {rep}_{1}^{V_x}(\{v\})\) for each \(C\in \mathsf {cc}(X{\setminus }S)\) and \(\{v\}\in \left( {\begin{array}{c}X\cap S\\ 1\end{array}}\right) \), this is doable in \(O( \log (\mathsf {s\text {-}nec}_2(V_x))\cdot n^3)\) since \(|\mathsf {cc}(X{\setminus }S)|+|X\cap S|\leqslant n\). Then with standard algorithmic techniques, we check whether X satisfies all the conditions of Definition 12 and compute \(\mathsf {aux}(X,i)\) and \(\mathsf {cc}(X,i)\).

Given two partial solutions XW associated with i, \(\mathsf {cc}(X,i)\) and \(\mathsf {cc}(W,i)\), we can decide whether \(X\sim _i W\) in time \(O(\mathsf {mim}(V_x)) \leqslant O(n)\). We deduce that, for each \(i\in {\mathbb {I}}_x\), we can compute \(\mathsf {reduce}({\mathcal {A}},i)\) in time \(O(|{\mathcal {A}}|\cdot (4\mathsf {mim}(V_x))^{4\mathsf {mim}(V_x)} \cdot \log (\mathsf {s\text {-}nec}_2(V_x))\cdot n^3)\). We deduce the running time to compute \(\mathsf {reduce}({\mathcal {A}})\) by multiplying the running time needed for \(\mathsf {reduce}({\mathcal {A}},i)\) by \(|{\mathbb {I}}_x|\). \(\square \)

We are now ready to prove the main theorem of this paper. For two subsets \({\mathcal {A}}\) and \({\mathcal {B}}\) of \(2^{V(G)}\), we define the merging of \({\mathcal {A}}\) and \({\mathcal {B}}\), denoted by \({\mathcal {A}}\otimes {\mathcal {B}}\), as \({\mathcal {A}}\otimes {\mathcal {B}}:=\{ X\cup Y \mid X\in {\mathcal {A}}\,\text { and }\, Y\in {\mathcal {B}}\}\). Observe that \({\mathcal {A}}\otimes {\mathcal {B}}=\varnothing \) whenever \({\mathcal {A}}=\varnothing \) or \({\mathcal {B}}=\varnothing \).

Theorem 21

There exists an algorithm that, given an n-vertex graph G and a rooted layout \((T,\delta )\) of G, solves Subset Feedback Vertex Set in time

$$\begin{aligned} O\left( \sum _{x\in V(T)} |{\mathbb {I}}_x|^3\cdot (4\mathsf {mim} (V_x))^{12\mathsf {mim} (V_x)}\cdot \log (\mathsf {s-nec} _2(V_x)) \cdot n^3\right) . \end{aligned}$$

Proof

The algorithm is a usual bottom-up dynamic programming algorithm. For every node x of T, the algorithm computes a set of partial solutions \({\mathcal {A}}_x \subseteq 2^{V_x}\) such that \({\mathcal {A}}_x\) represents \(2^{V_x}\) and \(|{\mathcal {A}}_x|\leqslant |{\mathbb {I}}_x| \cdot (4\mathsf {mim}(V_x))^{4\mathsf {mim}(V_x)}\). For the leaves x of T such that \(V_x=\{v\}\), we simply take \({\mathcal {A}}_x= 2^{V_x} = \{\varnothing , \{v\}\}\). In order to compute \({\mathcal {A}}_x\) for x an internal node of T with a and b as children, our algorithm will simply compute \({\mathcal {A}}_x= \mathsf {reduce}({\mathcal {A}}_a\otimes {\mathcal {A}}_b)\). Once the the set \({\mathcal {A}}_r\) is computed with r the root of T, our algorithm outputs a set \(X\in {\mathcal {A}}_r\) of maximum weight.

By Lemma 20, we have \(|{\mathcal {A}}_x|\leqslant |{\mathbb {I}}_x|\cdot (4\mathsf {mim}(V_x))^{4\mathsf {mim}(V_x)}\), for every node x of T. The following claim helps us to prove that \({\mathcal {A}}_x\) represents \(2^{V_x}\) for the internal nodes x of T.

Claim 22

Let x be an internal of T with a and b as children. If \({\mathcal {A}}_a\) and \({\mathcal {A}}_b\) represent, respectively, \(2^{V_a}\) and \(2^{V_b}\), then \(\mathsf {reduce} ({\mathcal {A}}_a\otimes {\mathcal {A}}_b)\) represents \(2^{V_x}\).

Proof

Assume that \({\mathcal {A}}_a\) and \({\mathcal {A}}_b\) represent, respectively, \(2^{V_a}\) and \(2^{V_b}\). First, we prove that \({\mathcal {A}}_a\otimes {\mathcal {A}}_b\) represents \(2^{V_x}\). We have to prove that, for every \(Y\subseteq \overline{V_x}\), we have \(\mathsf {best}({\mathcal {A}}_a\otimes {\mathcal {A}}_b,Y)=\mathsf {best}(2^{V_x},Y)\). Let \(Y\subseteq \overline{V_x}\). By definition of \(\mathsf {best}\), we have the following

$$\begin{aligned} \mathsf {best}({\mathcal {A}}_a\otimes {\mathcal {A}}_b,Y)&= \mathsf {max}\{ {\mathsf {w}}(X)+ {\mathsf {w}}(W)\mid X\in {\mathcal {A}}_a\wedge W\\&\quad \in {\mathcal {A}}_b\wedge G[X\cup W\cup Y] \text { is an { S}-forest} \} \\&= \mathsf {max}\{ \mathsf {best}({\mathcal {A}}_a,W\cup Y) + {\mathsf {w}}(W) \mid W\in {\mathcal {A}}_b \}. \end{aligned}$$

As \({\mathcal {A}}_a\) represents \(2^{V_a}\), we have \(\mathsf {best}({\mathcal {A}}_a,W\cup Y)=\mathsf {best}(2^{V_a},W\cup Y)\) and we deduce that \(\mathsf {best}({\mathcal {A}}_a\otimes {\mathcal {A}}_b,Y)=\mathsf {best}(2^{V_a}\otimes {\mathcal {A}}_b,Y)\). Symmetrically, as \({\mathcal {A}}_b\) represents \(2^{V_b}\), we infer that \(\mathsf {best}(2^{V_a}\otimes {\mathcal {A}}_b,Y)=\mathsf {best}(2^{V_a}\otimes 2^{V_b},Y)\). Since \(2^{V_a}\otimes 2^{V_b}= 2^{V_x}\), we conclude that \(\mathsf {best}({\mathcal {A}}_a\otimes {\mathcal {A}}_b,Y)\) equals \(\mathsf {best}(2^{V_x},Y)\). As this holds for every Y, it proves that \({\mathcal {A}}_a\otimes {\mathcal {A}}_b\) represents \(2^{V_x}\). By Lemma 20, we know that \(\mathsf {reduce}({\mathcal {A}}_a\otimes {\mathcal {A}}_b)\) represents \({\mathcal {A}}_a\otimes {\mathcal {A}}_b\). As the relation “represents” is transitive, we conclude that \(\mathsf {reduce}({\mathcal {A}}_a\otimes {\mathcal {A}}_b)\) represents \(2^{V_x}\). \(\square \)

For the leaves x of T, we obviously have that \({\mathcal {A}}_x\) represents \(2^{V_x}\), since \({\mathcal {A}}_x=2^{V_x}\). From Claim 22 and by induction, we deduce that \({\mathcal {A}}_x\) represents \(2^{V_x}\) for every node x of T. In particular, \({\mathcal {A}}_r\) represents \(2^{V(G)}\) with r the root of T. By Definition 19, \({\mathcal {A}}_r\) contains a set X of maximum size such that G[X] is an S-forest. This proves the correctness of our algorithm.

It remains to prove the running time. Observe that, for every internal node x of T with a and b as children, the size of \({\mathcal {A}}_a\otimes {\mathcal {A}}_b\) is at most \(|{\mathbb {I}}_x|^2\cdot (4\mathsf {mim}(V_x))^{8\mathsf {mim}(V_x)}\) and it can be computed in time \(O(|{\mathbb {I}}_x|^2\cdot (4\mathsf {mim}(V_x))^{8\mathsf {mim}(V_x)}\cdot n^2)\). By Lemma 20, the set \({\mathcal {A}}_x=\mathsf {reduce}({\mathcal {A}}_a\otimes {\mathcal {A}}_b)\) is computable in time \(O(|{\mathbb {I}}_x|^3\cdot (4\mathsf {mim}(V_x))^{12\mathsf {mim}(V_x)}\cdot \log (\mathsf {s\text {-}nec}_2(V_x))\cdot n^3)\). This proves the running time. \(\square \)

3.1 Algorithmic Consequences

In order to obtain the algorithmic consequences of our meta-algorithm given in Theorem 21, we need the following lemma which bounds the size of each set of indices with respect to the considered parameters.

Lemma 23

For every \(x\in V(T)\), the size of \({\mathbb {I}}_x\) is upper bounded by:

  • \(2^{O(\mathsf {rw} (V_x)^3)}\),

  • \(2^{O(\mathsf {rw} _{{\mathbb {Q}}}(V_x)^2\log (\mathsf {rw} _{{\mathbb {Q}}}(V_x)))}\),

  • \(n^{O(\mathsf {mim} (V_x)^2)}\).

Proof

For \(A\subseteq V(G)\), let \(\mathsf {mw}(A)\) be the number of different rows in the matrix \(M_{A,\overline{A}}\). Observe that, for every \(A\subseteq V(G)\), we have \(\mathsf {mw}(A)=\{ \mathsf {rep}_{1}^{A}(\{v\}) \mid v\in A\}\). Remember that the \({\mathscr {X}}_{\mathsf {vc}}^{S}\)’s and \({\mathscr {Y}}_{\mathsf {vc}}^{S}\)’s are subsets of \(\{ \mathsf {rep}_{1}^{V_x}(\{v\}) \mid v\in V_x\}\) and \(\{ \mathsf {rep}_{1}^{\overline{V_x}}(\{v\}) \mid v\in \overline{V_x}\}\) respectively. From Definition 10, we have \(|{\mathscr {X}}_{\mathsf {vc}}^{\overline{S}}|+|{\mathscr {X}}_{\mathsf {vc}}^{S}|+|{\mathscr {Y}}_{\mathsf {vc}}^{\overline{S}}| + |{\mathscr {Y}}_{\mathsf {vc}}^{S}| \leqslant 4\mathsf {mim}(V_x)\), for every \(({\mathscr {X}}_{\mathsf {vc}}^{\overline{S}},{\mathscr {X}}_{\mathsf {vc}}^{S}, {\mathscr {X}}_{\overline{\mathsf {vc}}},{\mathscr {Y}}_{\mathsf {vc}}^{\overline{S}},{\mathscr {Y}}_{\mathsf {vc}}^{S})\in {\mathbb {I}}_x\). Thus, the size of \({\mathbb {I}}_x\) is at most

$$\begin{aligned} \mathsf {nec}_1(V_x)\cdot \big (\mathsf {nec}_2(V_x)+ \mathsf {mw}(V_x) + \mathsf {nec}_2(\overline{V_x}) + \mathsf {mw}(\overline{V_x})\big )^{4\mathsf {mim}(V_x)}. \end{aligned}$$

Rank-Width By Lemma 4, we have \(\mathsf {nec}_1(V_x)\leqslant 2^{\mathsf {rw}(V_x)^2}\) and \(\mathsf {nec}_2(V_x),\mathsf {nec}_2(\overline{V_x})\leqslant 2^{2\mathsf {rw}(V_x)^2}\). Moreover, there is at most \(2^{\mathsf {rw}(V_x)}\) different rows in the matrices \(M_{V_x,\overline{V_x}}\) and \(M_{\overline{V_x},V_x}\), so \(\mathsf {mw}(V_x)\) and \(\mathsf {mw}(\overline{V_x})\) are upper bounded by \(2^{\mathsf {rw}(V_x)}\). By Lemma 3, we have \(4\mathsf {mim}(V_x)\leqslant 4\mathsf {rw}(V_x)\). We deduce from these inequalities that \(|{\mathbb {I}}_x|\leqslant 2^{\mathsf {rw}(V_x)^2}\cdot (2^{2\mathsf {rw}(V_x)^2 + 1} + 2^{\mathsf {rw}(V_x)+1})^{4\mathsf {rw}(V_x)}\in 2^{O(\mathsf {rw}(V_x)^3)}\).

\({\mathbb {Q}}\)-Rank-Width    By Lemma 4, we have \(\mathsf {nec}_1(V_x),\mathsf {nec}_2(V_x),\mathsf {nec}_2(\overline{V_x})\in 2^{O(\mathsf {rw}_{\mathbb {Q}}(V_x)\log (\mathsf {rw}_{\mathbb {Q}}(V_x)))}\). Moreover, there is at most \(2^{\mathsf {rw}_{\mathbb {Q}}(V_x)}\) different rows in the matrices \(M_{V_x,\overline{V_x}}\) and \(M_{\overline{V_x},V_x}\), so \(\mathsf {mw}(V_x)\) and \(\mathsf {mw}(\overline{V_x})\) are upper bounded by \(2^{\mathsf {rw}_{\mathbb {Q}}(V_x)}\). By Lemma 3, we have \(4\mathsf {mim}(V_x)\leqslant 4\mathsf {rw}_{\mathbb {Q}}(V_x)\). We deduce from these inequalities that

$$\begin{aligned} |{\mathbb {I}}_x|\leqslant 2^{O(\mathsf {rw}_{\mathbb {Q}}(V_x)\log (\mathsf {rw}_{\mathbb {Q}}(V_x)))}\cdot \Big (2^{O(\mathsf {rw}_{\mathbb {Q}}(V_x)\log (\mathsf {rw}_{\mathbb {Q}}(V_x)))} + 2^{\mathsf {rw}_{\mathbb {Q}}(V_x)+1}\Big )^{4\mathsf {rw}_{\mathbb {Q}}(V_x)}. \end{aligned}$$

We conclude that \(|{\mathbb {I}}_x|\in 2^{O(\mathsf {rw}_{\mathbb {Q}}(V_x)^2\log (\mathsf {rw}_{\mathbb {Q}}(V_x)))}\).

Mim-Width By Lemma 4, we know that \(\mathsf {nec}_1(V_x)\leqslant |V_x|^{\mathsf {mim}(V_x)}\), \(\mathsf {nec}_2(V_x) \leqslant |V_x|^{2\mathsf {mim}(V_x)}\), and \(\mathsf {nec}_2(\overline{V_x})\leqslant |\overline{V_x}|^{2\mathsf {mim}(V_x)}\). We can assume that \(n>2\) (otherwise the problem is trivial), so \(\mathsf {nec}_2(V_x)+\mathsf {nec}_2(\overline{V_x})\leqslant |V_x|^{2\mathsf {mim}(V_x)} + |\overline{V_x}|^{2\mathsf {mim}(V_x)} \leqslant n^{2\mathsf {mim}(V_x)}\). Moreover, notice that, for every \(A\subseteq V(G)\), we have \(\{ \mathsf {rep}_{1}^{A}(\{v\}) \mid v\in A\}\leqslant |A|\).

We deduce that \(|{\mathbb {I}}_x|\leqslant n^{\mathsf {mim}(V_x)} \cdot (n+n^{2\mathsf {mim}(V_x)})^{4\mathsf {mim}(V_x)}\). As we assume that \(n>2\), we have \(|{\mathbb {I}}_x|\leqslant n^{8\mathsf {mim}(V_x)^2+5\mathsf {mim}(V_x)}\in n^{O(\mathsf {mim}(V_x)^2)}\).

\(\square \)

Now we are ready to state our algorithms with respect to the parameters rank-width \(\mathsf {rw}(G)\) and \({\mathbb {Q}}\)-rank-width \(\mathsf {rw}_{\mathbb {Q}}(G)\). In particular, with our next result we show that Subset Feedback Vertex Set is in FPT parameterized by \(\mathsf {rw}_{\mathbb {Q}}(G)\) or \(\mathsf {rw}(G)\).

Theorem 24

There exist algorithms that solve Subset Feedback Vertex Set in time \(2^{O(\mathsf {rw} (G)^3)}\cdot n^4\) and \(2^{O(\mathsf {rw} _{{\mathbb {Q}}}(G)^2\log (\mathsf {rw} _{{\mathbb {Q}}}(G))))}\cdot n^{4}\).

Proof

We first compute a rooted layout \({\mathcal {L}}=(T,\delta )\) of G such that \(\mathsf {rw}({\mathcal {L}})\in O(\mathsf {rw}(G))\) or \(\mathsf {rw}_{\mathbb {Q}}({\mathcal {L}})\in O(\mathsf {rw}_{\mathbb {Q}}(G))\). This is achieved through a \((3k + 1)\)-approximation algorithm that runs in FPT time \(O(8^k \cdot n^4)\) parameterized by \(k \in \{\mathsf {rw}(G),\mathsf {rw}_{\mathbb {Q}}(G)\}\) [34]. Then, we apply the algorithm given in Theorem 21. Observe that for every node \(x\in V(T)\), by Lemma 23, \(|{\mathbb {I}}_x|^3\) lies in \(2^{O(\mathsf {rw}(V_x)^3)}\) and \(2^{O(\mathsf {rw}_{\mathbb {Q}}(V_x)^2\log (\mathsf {rw}_{\mathbb {Q}}(V_x)))}\) and by Lemma 4, \(\mathsf {s\text {-}nec}_2(V_x)\) lies in \(2^{O(\mathsf {rw}(V_x)^2)}\) and \(2^{O(\mathsf {rw}_{\mathbb {Q}}(V_x)\log (\mathsf {rw}_{\mathbb {Q}}(V_x)))}\). Moreover, Lemma 3 implies that \(\mathsf {mim}(V_x)^{\mathsf {mim}(V_x)}\) is upper bounded by \(2^{\mathsf {rw}(G) \log (\mathsf {rw}(G))}\) and \(2^{\mathsf {rw}_{\mathbb {Q}}(G)\log (\mathsf {rw}_{\mathbb {Q}}(G))}\). Therefore, we get the claimed runtimes for SFVS since T contains \(2n-1\) nodes. \(\square \)

Regarding mim-width, our algorithm given below shows that Subset Feedback Vertex Set is in XP parameterized by the mim-width of a given rooted layout. Note that we cannot solve SFVS in FPT time parameterized by the mim-width of a given rooted layout unless \(\textsf {FPT} =\textsf {W}[1]\), since Subset Feedback Vertex Set is known to be W[1]-hard for this parameter even for the special case of \(S=V(G)\) [29]. Moreover, contrary to the algorithms given in Theorem 24, here we need to assume that the input graph is given with a rooted layout. However, our next result actually provides a unified polynomial-time algorithm for Subset Feedback Vertex Set on well-known graph classes having bounded mim-width and for which a layout of bounded mim-width can be computed in polynomial time [1] (e.g., Interval graphs, Permutation graphs, Circular Arc graphs, Convex graphs, k -Polygon, Dilworth-k and Co-k -Degenerate graphs for fixed k).

Theorem 25

There exists an algorithm that, given an n-vertex graph G and a rooted layout \({\mathcal {L}}\) of G, solves Subset Feedback Vertex Set in time \(n^{O(\mathsf {mim} ({\mathcal {L}})^2)}\).

Proof

We apply the algorithm given in Theorem 21. By Lemma 4, we have \(\mathsf {s\text {-}nec}_2(V_x)\leqslant n^{O(\mathsf {mim})}\) and from Lemma 23 we have \(|{\mathbb {I}}_x|^3\in n^{O(\mathsf {mim}(V_x)^2)}\). The claimed runtime for SFVS follows by the fact that the rooted tree T of \({\mathcal {L}}\) contains \(2n-1\) nodes. \(\square \)

Let us relate our results for Subset Feedback Vertex Set to the Node Multiway Cut. It is known that Node Multiway Cut reduces to Subset Feedback Vertex Set [20]. In fact, we can solve Node Multiway Cut by adding a new vertex v with a large weight that is adjacent to all terminals and, then, run our algorithms for Subset Feedback Vertex Set with \(S= \{v\}\) on the resulting graph. Now observe that any extension of a rooted layout \({\mathcal {L}}\) of the original graph to the resulting graph has mim-width \(\mathsf {mim}({\mathcal {L}})+1\). Therefore, all of our algorithms given in Theorems 24 and 25 have the same running times for the Node Multiway Cut problem.

4 Conclusion

This paper highlights the importance of the d-neighbor-equivalence relation to obtain meta-algorithm for several width measures at once. We extend the range of applications of this relation [3, 7, 22, 35] by proving that it is useful for the atypical acyclicity constraint of the Subset Feedback Vertex Set problem. It would be interesting to see whether this relation can be helpful with other kinds of constraints such as 2-connectivity and other generalizations of Feedback Vertex Set such as the ones studied in [6]. In particular, one could consider the following generalization of Odd Cycle Transversal:

figure b

Similar to SFVS, we can solve SOCT in time \(k^{O(k)}\cdot n^{O(1)}\) parameterized by treewidth and this is optimal under ETH [2]. We do not know whether SOCT is in XP parameterized by mim-width, though it is in FPT parameterized by clique-width or rank-width, since we can express it in MSO\(_1\) (with the characterization used in [2]).

For many well-known graph classes a decomposition of bounded mim-width can be found in polynomial time. However, for general graphs it is known that computing mim-width is W[1]-hard and not in APX unless NP = ZPP [40], while Yamazaki [42] shows that under the small set expansion hypothesis it is not in APX unless P = NP. For dynamic programming algorithms as in this paper, to circumvent the assumption that we are given a decomposition, we want functions fg and an algorithm that given a graph of mim-width OPT computes an f(OPT)-approximation to mim-width in time \(n^{g(OPT)}\), i.e. XP by the natural parameter. This is the main open problem in the field. The first task could be to decide if there is a constant c and a polynomial-time algorithm that given a graph G either decides that its mim-width is larger than 1 or else returns a decomposition of mim-width c.