Classifying Subset Feedback Vertex Set for $H$-Free Graphs

In the Feedback Vertex Set problem, we aim to find a small set $S$ of vertices in a graph intersecting every cycle. The Subset Feedback Vertex Set problem requires $S$ to intersect only those cycles that include a vertex of some specified set $T$. We also consider the Weighted Subset Feedback Vertex Set problem, where each vertex $u$ has weight $w(u)>0$ and we ask that $S$ has small weight. By combining known NP-hardness results with new polynomial-time results we prove full complexity dichotomies for Subset Feedback Vertex Set and Weighted Subset Feedback Vertex Set for $H$-free graphs, that is, graphs that do not contain a graph $H$ as an induced subgraph.


Introduction
In a graph transversal problem the aim is to find a small set of vertices within a given graph that must intersect every subgraph that belongs to some specified family of graphs.Apart from the Vertex Cover problem, the Feedback Vertex Set problem is perhaps the best-known graph transversal problem.A vertex subset S is a feedback vertex set of a graph G if S intersects every cycle of G.In other words, the graph G − S obtained by deleting all vertices of S is a forest.We can now define the problem:

Feedback Vertex Set
Instance: a graph G and an integer k.
Question: does G have a feedback vertex set S with |S| ≤ k?
The Feedback Vertex Set problem is well-known to be NP-complete even under input restrictions.For example, by Poljak's construction [15], the Feedback Vertex Set problem is NP-complete even for graphs of finite girth at least g (the girth of a graph is the length of its shortest cycle).To give another relevant example, Feedback Vertex Set is also NP-complete for line graphs [10].
In order to understand the computational hardness of Feedback Vertex Set better, other graph classes have been considered as well, in particular those that are closed under vertex deletion.Such graph classes are called hereditary.It is readily seen that a graph class G is hereditary if and only if G can be characterized by a (possibly infinite) set F of forbidden induced subgraphs.From a systematic point of view it is natural to first consider the case where F has size 1, say F = {H} for some graph H.This leads to the notion of Hfreeness: a graph G is H-free for some graph H if G does not contain H as an induced subgraph, that is, G cannot be modified into H by a sequence of vertex deletions.
As Feedback Vertex Set is NP-complete for graphs of finite girth at least g for every g ≥ 1, it is NP-complete for H-free graphs whenever H has a cycle.As it is NP-complete for line graphs and line graphs are claw-free, Feedback Vertex Set is NP-complete for H-free graphs whenever H has an induced claw (the claw is the 4-vertex star).In the remaining cases, the graph H is a linear forest, that is, the disjoint union of one or more paths.When H is a linear forest, several positive results are known even for the weighted case.Namely, for a graph G, we can define a (positive) weighting as a function w : V → Q + .For v ∈ V , w(v) is the weight of v, and for S ⊆ V , we define the weight w(S) = u∈S w(u) of S as the sum of the weights of the vertices in S.This brings us to the following generalization of Feedback Vertex Set:

Weighted Feedback Vertex Set
Instance: a graph G, a positive vertex weighting w of G and a rational number k. Question: does G have a feedback vertex set S with w(S) ≤ k?
Note that if w is a constant weighting function, then we obtain the Feedback Vertex Set problem.We denote the r-vertex path by P r , and the disjoint union of two vertex-disjoint graphs G 1 and G 2 by G 1 +G 2 = ((V (G 1 )∪V (G 2 ), E(G 1 )∪ E(G 2 )), where we write sG for the disjoint union of s copies of G.It is known that Weighted Feedback Vertex Set is polynomial-time solvable for sP 3free graphs [11] and P 5 -free graphs [1].The latter result was recently extended to (sP 1 + P 5 )-free graphs for every s ≥ 0 [11].We write H ⊆ i G to denote that H is an induced subgraph of G.We can now summarize all known results [1,10,11,15] as follows.
Theorem 1. (Weighted) Feedback Vertex Set for the class of H-free graphs is polynomial-time solvable if H ⊆ i sP 3 or H ⊆ i sP 1 + P 5 for some s ≥ 1, and is NP-complete if H is not a linear forest.
Note that the open cases of Theorem 1 are when H is a linear forest with P 2 + P 4 ⊆ i H or P 6 ⊆ i H.
The (Weighted) Feedback Vertex Set problem can be further generalized in the following way.Let T be some specified subset of vertices of a graph The NP-complete cases in Theorem 1 carry over to (Weighted) Subset Feedback Vertex Set; just set T := V (G) in both cases.However, this is no longer true for the polynomial-time cases: Fomin et al. [7] proved NP-completeness of Subset Feedback Vertex Set for split graphs, which form a subclass of 2P 2free graphs.Interestingly, Papadopoulos and Tzimas [14] proved that Weighted Subset Feedback Vertex Set is NP-complete for 5P 1 -free graphs, whereas Brettell et al. [4] proved that Subset Feedback Vertex Set can be solved in polynomial time even for (sP 1 + P 3 )-free graphs for every s ≥ 1 [4].Hence, in contrast to many other transversal problems, the complexities on the weighted and unweighted subset versions do not coincide for H-free graphs.
It is also known that Weighted Subset Feedback Vertex Set can be solved in polynomial time for permutation graphs [13] and thus for its subclass of P 4 -free graphs.The latter result also follows from a more general result related to the graph parameter mim-width [16].Namely, Bergougnoux, Papadopoulos and Telle [3] proved that Weighted Subset Feedback Vertex Set is polynomial-time solvable for graphs for which we can find a decomposition of constant mim-width in polynomial time [3]; the class of P 4 -free graphs is an example of such a class.Brettell et al. [5] extended these results by proving that Weighted Subset Feedback Vertex Set, restricted to H-free graphs, is polynomial-time solvable if The above results leave open a number of unresolved cases for both problems, as identified in [4] and [5], where the following open problems are posed: Open Problem 1 Determine the complexity of Weighted Subset Feedback Vertex Set for H-free graphs if H ∈ {2P 1 + P 3 , P 1 + P 4 , 2P 1 + P 4 }.
Open Problem 2 Determine the complexity of Subset Feedback Vertex Set for H-free graphs if H = sP 1 + P 4 for some integer s ≥ 1.

Our Results
We completely solve Open Problems 1 and 2.
In Section 3, we prove that Weighted Subset Feedback Vertex Set is polynomial-time solvable for (2P 1 + P 4 )-free graphs.This result generalizes all known polynomial-time results for Weighted Feedback Vertex Set.It also immediately implies polynomial-time solvability for the other two cases in Open Problem 1, as (2P 1 +P 3 )-free graphs and (P 1 +P 4 )-free graphs form subclasses of (2P 1 + P 4 )-free graphs.Combining the aforementioned NP-completeness results of [7] and [14] for 2P 2 -free graphs and 5P 1 -free graphs, respectively, with the NP-completeness results in Theorem 1 for the case where H has a cycle or a claw and this new result gives us the following complexity dichotomy (see also Fig. 2).
Theorem 2. For a graph H, Weighted Subset Feedback Vertex Set on H-free graphs is polynomial-time solvable if H ⊆ i 2P 1 + P 4 , and is NP-complete otherwise.
In Section 4 we solve Open Problem 2 by proving that Subset Feedback Vertex Set is polynomial-time solvable for (sP 1 + P 4 )-free graphs, for every s ≥ 1.This result generalizes all known polynomial-time results for Weighted Feedback Vertex Set.After combining it with the aforementioned NP-completeness results of [7] and Theorem 1 we obtain the following complexity dichotomy.Theorem 3.For a graph H, Subset Feedback Vertex Set on H-free graphs is polynomial-time solvable if H ⊆ i sP 1 + P 4 for some s ≥ 0, and is NP-complete otherwise.
Due to Theorems 2 and 3 we now know where exactly the complexity jump between the weighted and unweighted versions occurs.
Our proof technique for these results is based on the following two ideas.First, if the complement F T of a T -feedback vertex set contains s vertices of small degree in F T , then we can "guess" these vertices and their neighbours in F T .We then show that after removing all the other neighbours of small-degree vertices, we will obtain a graph of small mim-width.If F T does not contain s small-degree vertices, we will argue that F T contains a bounded number of vertices of T .We guess these vertices and exploit their presence.This is straightforward for Subset Feedback Vertex Set but more involved for Weighted Subset Feedback Vertex Set.The latter was to be expected from the hardness construction for Weighted Subset Feedback Vertex Set on 5P 1 -free graphs, in which |T | = 1 (but as we will show our algorithm is able to deal with that construction due to the (2P 1 + P 4 )-freeness of the input graph).
We finish our paper with a brief discussion on related graph transversal problems and some open questions in Section 5.

Preliminaries
Let G = (V, E) be a graph.If S ⊆ V , then G[S] denotes the subgraph of G induced by S, and G − S is the graph G[V \ S].We say that S is independent if G[S] has no edges, and that S is a clique and G[S] is complete if every pair of vertices in S is joined by an edge.A (connected) component of G is a maximal connected subgraph of G.The neighbourhood of a vertex u ∈ V is the set N (u) = {v | uv ∈ E}.A graph is bipartite if its vertex set can be partitioned into at most two independent sets.
Recall that for a graph G = (V, E) and a subset T ⊆ V , a T -feedback vertex set is a set S ⊆ V that intersects all T -cycles.Note that G − S is a graph that has no T -cycles; we call such a graph a T -forest.Thus the problem of finding a T -feedback vertex set of minimum size is equivalent to finding a T -forest of maximum size.Similarly, the problem of finding a T -feedback vertex set of minimum weight is equivalent to finding a T -forest of maximum weight.These maximisation problems are actually the problems that we will solve.Consequently, any T -forest will be called a solution for an instance (G, T ) or (G, w, T ), respectively, and our aim is to find a solution of maximum size or maximum weight, respectively.
Throughout our proofs we will need to check if some graph F is a solution.The following lemma shows that we can recognize solutions in linear time.The lemma combines results claimed but not proved in [9,14].It is easy to show but for an explicit proof we refer to [4, Lemma 3].
In our proofs we will not refer to Lemma 1 explicitly, but we will use it implicitly every time we must check if some graph F is a solution.

The Weighted Variant
In this section, we present our polynomial-time algorithm for Weighted Subset Feedback Vertex Set on (2P 1 + P 4 )-free graphs.
Outline.Our algorithm is based on the following steps.We first show in Section 3.1 how to compute a solution F that contains at most one vertex from T , which moreover has small degree in F .In Section 3.2 we then show that if two vertices of small degree in a solution are non-adjacent, we can exploit the (2P 1 + P 4 )-freeness of the input graph G to reduce to a graph G ′ of bounded mim-width.The latter enables us to apply the algorithm of Bergougnoux, Papadopoulos and Telle [3].In Section 3.3 we deal with the remaining case, where all the vertices of small degree in a solution F form a clique and F contains at least two vertices of T .We first show that every vertex of T that belongs to F must have small degree in F .Hence, as the vertices in T ∩ V (F ) must also induce a forest, F has exactly two adjacent vertices of T , each of small degree in F .This structural result enables us to do a small case analysis.We combine this step together with our previous algorithmic procedures into one algorithm.
Remark.Some of the lemmas in the following three subsections hold for (sP 1 + P 4 )-free graphs, for every s ≥ 2, or even for general graphs.In order to re-use these lemmas in Section 4, where we consider Subset Feedback Vertex Set for (sP 1 + P 4 )-free graphs, we formulate these lemmas as general as possible.

Three Special Types of Solutions
In this section we will show how we can find three special types of solutions in polynomial time for (2P 1 + P 4 )-free graphs.These solutions have in common that they contain at most one vertex from the set T and moreover, this vertex has small degree in F .
Let G = (V, E) be a graph and let T ⊆ V be a subset of vertices of G.A T -forest F is a ≤1-part solution if F contains at most one vertex from T and moreover, if F contains a vertex u from T , then u has degree at most 1 in F .The following lemma holds for general graphs and is easy to see, but we need it for our algorithm.
Lemma 2. For a graph G = (V, E) with a positive vertex weighting w and a set T ⊆ V , it is possible to find a ≤1-part solution of maximum weight in polynomial time.Proof.The solution F = G − T has maximum weight over all solutions that contain no vertex of T .Let |V | = n.We now consider all O(n) possibilities of choosing a vertex u ∈ T to be in the ≤1-part solution F that we are looking for.Consider u ∈ T to be in F .In the case where u has no neighbour in F , we can set F to be the subgraph of G induced by u and all non-neighbours of u in V \ T .Otherwise, if N (u) \ T = ∅, then we consider all O(n) possibilities of choosing a neighbour v ∈ N (u) \ T to be in F as well.Afterwards, we define F to be the subgraph induced by u, v and all non-neighbours of u in V \ T ; see also Fig. 3.It is readily seen that this algorithm is correct and runs in polynomial time.⊓ ⊔ Let G = (V, E) be a graph and let T ⊆ V be a subset of vertices of G.A T -forest F is a 2-part solution if F contains exactly one vertex u of T and u has exactly two neighbours v 1 and v 2 in F .We say that u is the center of F and that v 1 and v 2 are the center neighbours.Let A be the connected component of F that contains u.Then we say that A is the center component of F .We make the following observation.Lemma 3. Let A be the center component of a 2-part solution F with center u.Then A − u consists of exactly two connected components (each of which containing a different center neighbour).
Proof.Note that A − u can contain at most two connected components as u has degree 2 in A. For a contradiction, assume that A − u is connected.Then A − u contains a path between the two center neighbours of u.This implies that u ∈ T is on a cycle in A, contradicting the fact that F is a T -forest.
⊓ ⊔ We will prove how to find 2-part solutions in polynomial time even for general graphs.In order to do this, we will reduce to a classical problem, namely:

Weighted Vertex Cut
Instance: a graph G = (V, E), two distinct non-adjacent terminals t 1 and t 2 , and a positive vertex weighting w.Task: determine a set S ⊆ V \ {t 1 , t 2 } of minimum weight such that t 1 and t 2 are in different connected components of G − S.
The Weighted Vertex Cut problem is well known to be polynomial-time solvable by standard network flow techniques.Lemma 4. Weighted Vertex Cut is polynomial-time solvable.
We use Lemma 4 to prove the following lemma.
Lemma 5.For a graph G = (V, E) with a positive vertex weighting w and a set T ⊆ V , it is possible to find a 2-part solution of maximum weight in polynomial time.
Proof.Let |V | = n.We consider every possible choice of center u and center neigbours v 1 , v 2 .Note there are O(n 3 ) options.For each choice of u, v 1 , v 2 we do as follows.First we check that u ∈ T , {v 1 , v 2 } ∩ T = ∅, u is adjacent to both v 1 and v 2 and there is no edge between v 1 and v 2 .If the check fails, the guess is discarded.We remove every neighbour of u that is not in {v 1 , v 2 }.We also remove every vertex of T \ {u} from G, as u will be the only vertex of F that belongs to T .We denote the resulting graph by G ′ .By Lemma 3, it remains to solve Weighted Vertex Cut for the instance that consists of G ′ − u, with v 1 and v 2 as terminals and the restriction of w to V (G ′ ) \ {u}; see also Fig. 4. By Lemma 4, this can be done in polynomial time.In the end we return a solution of maximum weight.As the total number of different options to consider is O(n 3 ), our algorithm runs in polynomial time.
⊓ ⊔ Let G = (V, E) be a graph and let T ⊆ V be a subset of vertices of G.A Tforest F is a 3-part solution if F contains exactly one vertex u of T and u has exactly three neighbours v 1 , v 2 , v 3 in F .Again we say that u is the center of F ; that v 1 , v 2 , v 3 are the center neighbours; and that the connected component of F that contains u is the center component of F .We make the same observation as we did in Lemma 3.
Lemma 6.Let A be the center component of a 3-part solution F with center u.
Then A − u consists of exactly three connected components (each of which containing a different center neighbour).
Proof.Note that A − u can contain at most three connected components as u has degree 3 in A. For a contradiction, assume that A − u contains at most two connected components.Then one of these components contains at least two of the three center neighbours of u.Then A − u contains a path between these two center neighbours.This implies that u ∈ T is on a cycle in A, contradicting the fact that F is a T -forest.

⊓ ⊔
Let A be the center component of a 3-part solution F with center u.By Lemma 6, we have that A − u consists of exactly three connected components D 1 , D 2 and D 3 .We say that F is full if every D i (i = 1, 2, 3) has size at least 2. We now prove the following structural lemma for (2P 1 + P 4 )-free graphs.
Lemma 7. Let G be a (2P 1 +P 4 )-free graph.Let A be the center component of a full 3-part solution F for G that has center u.Then F = A and every connected component of A − u is a complete graph.
Proof.Let v 1 , v 2 , v 3 be the center neighbours of F .By Lemma 6, we have that A − u consists of exactly three connected components D 1 , D 2 and D 3 , where we assume that v i ∈ V (D i ) for i ∈ {1, 2, 3}.As F is full, we have that for i ∈ {1, 2, 3}, D i contains a vertex x i adjacent to v i .
We will first prove that F = A. Suppose that F contains a vertex y / ∈ V (A).
We will now prove that every D i is complete.We consider D 1 , as the arguments for D 2 and D 3 will be the same.First suppose that D 1 contains a vertex z not adjacent to v 1 .As D 1 is connected we may assume without loss of generality that z has distance 2 from v 1 in D 1 , and so D 1 contains a vertex z ′ that is adjacent to both v 1 and z.Then z, z ′ , v 1 , u, x 2 , x 3 induce a 2P 1 + P 4 in G, a contradiction.Hence, v 1 is adjacent to every other vertex in D 1 .Now suppose that D 1 still contains two non-adjacent vertices p and q.As v 1 is adjacent to every vertex of V (D 1 ) \ {v 1 }, we find that v 1 / ∈ {p, q}.Then x 2 , v 2 , u, v 3 , p, q induce a 2P 1 + P 4 in G, a contradiction.

⊓ ⊔
We are now ready to prove the following lemma.
Lemma 8.For a (2P 1 +P 4 )-free graph G = (V, E) with a positive vertex weighting w and a set T ⊆ V , it is possible to find a 3-part solution of maximum weight in polynomial time.
Proof.Let |V | = n.We consider every possible choice of center u and center neighbours v 1 , v 2 , v 3 .Note that there are O(n 4 ) options.For each choice of u, v 1 , v 2 , v 3 we do as follows.First we check that u ∈ T , {v 1 , v 2 , v 3 } is disjoint from T and independent, and that u is adjacent to v 1 , v 2 and v 3 .If the check fails, the guess is discarded.We remove every neighbour of u that is not in {v 1 , v 2 , v 3 }.This gives us a graph G ′ .Note that G ′ contains the 3-part solution F of G if u is the center of F and v 1 , v 2 , v 3 are the center neighbours.Say A is the center component of F .Then, by Lemma 6, we have that A − u consists of exactly three connected components D 1 , D 2 and D 3 , say We first search for a maximum weight 3-part solution of G ′ with center u and center neighbours v 1 , v 2 , v 3 that is not full.This means that at least one of the connected components D 1 , D 2 , D 3 has size 1, so at least one of v 1 , v 2 , v 3 is adjacent only to u in F .We consider each of the three options.We first examine the case where v 1 has degree 1 in F .In order to do this, we remove u and v 1 from G ′ , and we also remove all neighbours of v 1 from G ′ .This gives us a graph G 1 .It remains to solve Weighted Vertex Cut for the instance that consists of G 1 , with v 2 and v 3 as terminals and the restriction of w to V (G 1 ).This takes polynomial time by Lemma 4. We repeat the same steps with respect to v 2 and also with respect to v 3 .From all the non-full 3-part solutions found we remember one with the largest weight.
We now search for a maximum weight 3-part solution of G ′ with center u and center neighbours v 1 , v 2 , v 3 that is full.We remove every vertex not equal to u that is adjacent to at least two vertices from {v 1 , v 2 , v 3 } from G ′ .We may do this, as D 1 , D 2 , D 3 are distinct connected components of A − u, so such a vertex will not be in any of D 1 , D 2 , or D 3 .By Lemma 7, every vertex in F is adjacent to one of v 1 , v 2 , v 3 .Hence, we may also remove every vertex not adjacent to any vertex from {v 1 , v 2 , v 3 } from G ′ .Finally, we remove every vertex of T \{u} from G ′ , as u will be the only vertex of F that belongs to T .We denote the resulting graph by G ′′ ; see also Fig. 5.By construction, every vertex of G ′′ −{u, v 1 , v 2 , v 3 } is adjacent to exactly one of {v 1 , v 2 , v 3 }.Moreover, we constructed G ′′ in polynomial time.
We will now consider all O(n 3 ) options for choosing neighbours x 1 , x 2 , x 3 of v 1 , v 2 , v 3 , respectively; note that these vertices are guessed to be in respectively.As F is full, these vertices x 1 , x 2 , x 3 exist by definition.For each chosen triple x 1 , x 2 , x 3 we do as follows.We first check if {x 1 , x 2 , x 3 } forms an independent set.This must hold as D 1 , D 2 , D 3 are distinct connected components of A − u.So, if the check fails, the guess is discarded.From G ′′ , we remove every neighbour of v 1 that is adjacent to at least one of {x 2 , x 3 }; every neighbour of v 2 that is adjacent to at least one of {x 1 , x 3 }; and every neighbour of v 3 that is adjacent to at least one of {x 1 , x 2 }.By Lemma 7, we also remove for i ∈ {1, 2, 3}, every neighbour of v i that is not adjacent to x i .We denote the resulting graph by F * .v1 v2 v3 u ∈ T Fig. 5.The graph G ′′ constructed in the proof of Lemma 8.Note that {v1, v2, v3} is an independent set and that every vertex not in {u, v1, v2, v3} is adjacent to exactly one of v1, v2, v3.The desired components D1, D2 and D3 of G ′′ −u are, if they exist, subgraphs of the rectangular boxes.However, there might be edges between two vertices from two different boxes and we must deal with this situation.
By construction, every vertex not in {u, v 1 , v 2 , v 3 , x 1 , x 2 , x 3 } is not adjacent to u and is adjacent to both vertices of exactly one of the pairs {v 1 , x 1 }, {v 2 , x 2 } or {v 3 , x 3 }.We claim that F * is the desired full 3-part solution (for this particular branch). 5In order to see this, assume that F * − u is not the disjoint union of three complete graphs D 1 , D 2 , D 3 .By construction, this means that one of the following two cases must hold: (i) F * − u has two adjacent vertices r and r ′ that have a different neighbour in {v 1 , v 2 , v 3 }, or (ii) F * − u has a connected component that is not a complete graph.
For a contradiction, assume that Case (i) holds.Say, r is adjacent to v 1 and r ′ is adjacent to v 2 .By construction of F * , we find that r is adjacent to x 1 but not to x 2 or x 3 , whereas r ′ is adjacent to x 2 but not to x 1 or x 3 .Recall also that {x 1 , x 2 , x 3 } is an independent set and that u is not adjacent to any vertex of {r, r ′ , x 1 , x 2 , x 3 }.However, now the vertices x 1 , r, r ′ , x 2 , u, x 3 induce a 2P 1 + P 4 in F * , a contradiction as F * being an induced subgraph of G is (2P 1 + P 4 )free (see also Fig. 6).Hence, Case (i) does not hold, and thus F * − u consists of three different connected components that contain the sets {v 1 , x 1 }, {v 2 , x 2 } and {v 3 , x 3 }, respectively. 5For the remainder of the proof, the fact that G is (2P1 +P4)-free is again crucial.If G is 5P1-free and thus (3P1 + P4)-free, but not (2P1 + P4)-free, the proof will not work.Namely, in that case, we would obtain the gadget of Papadopoulos and Tzimas [14] for proving NP-hardness of Subset Feedback Vertex Set for 5P1-free graphs (in their proof the center u and the three center neighbours each have large weight while T = {u} and a reduction from Vertex Cover for 3-partite graphs is used).We conclude that Case (ii) must hold if F * is not a full 3-part solution.We prove that this leads to another contradiction.Let y, y ′ be two non-adjacent vertices in say the connected component of F * − u that contains v 1 .As v 1 is adjacent to every vertex of that component, we find that v 1 is not equal to y or y ′ .However, now x 2 , v 2 , u, v 3 , y, y ′ induce a 2P 1 + P 4 , a contradiction; see also Fig. 6.Hence, we conclude that F * is indeed the desired full 3-part solution.
From all the full 3-part solutions we found we remember one with the largest weight.It remains to compare the maximum weight non-full solution with the maximum weight full solution and pick one with the largest weight.The correctness of the algorithm follows from the arguments above.As the total number of branches is polynomial and processing each of them takes polynomial time as well, the running time of the algorithm is polynomial.⊓ ⊔

Mim-Width
We also need some known results that involve the mim-width of a graph.This width parameter was introduced by Vatshelle [16].For the definition of mimwidth we refer to [16], as we do not need it here.A graph class G has bounded mim-width if there exists a constant c such that every graph in G has mimwidth at most c.The mim-width of a graph class G is quickly computable if it is possible to compute in polynomial time a so-called branch decomposition for a graph G ∈ G whose mim-width is bounded by some function in the mim-width of G.We can now state the aforementioned result of Bergougnoux, Papadopoulos and Telle in a more detailed way.

Theorem 4 ([3]
). Weighted Subset Feedback Vertex Set is polynomialtime solvable for every graph class whose mim-width is bounded and quickly computable.
Belmonte and Vatshelle [2] proved that the mim-width of the class of permutation graphs is bounded and quickly computable.As P 4 -free graphs form a subclass of the class of permutation graphs, we immediately obtain the following lemma. 6emma 9.The mim-width of the class of P 4 -free graphs is bounded and quickly computable.
For a graph class G and an integer p ≥ 0, we let G + pv be the graph class that consists of all graphs that can be modified into a graph from G by deleting at most p vertices.The following lemma follows in a straightforward way from a result of Vatshelle [16].
Lemma 10.If G is a graph class whose mim-width is bounded and quickly computable, then the same holds for the class G + pv, for every constant p ≥ 0.
We will now explain the relevance of the above results in a slightly more general way (such that we can apply the next lemma in Section 4 as well).Let G = (V, E) be an (sP 1 + P 4 )-free graph for some s ≥ 2 and let T ⊆ V .Let F be a T -forest of G.We define the core of F as the set of vertices of F that have at most 2s − 1 neighbours in F .We say that F is core-complete if the core of F has no independent set of size at least s; otherwise F is core-incomplete. 7We prove the following algorithmic result.
Lemma 11.Let s ≥ 2. For an (sP 1 + P 4 )-free graph G = (V, E) with a positive vertex weighting w and a set T ⊆ V , it is possible to find a core-incomplete solution of maximum weight in polynomial time.
Proof.Let |V | = n.A core-incomplete solution F has a core that contains an independent set U = {u 1 , . . ., u s } of size s.By definition, core vertices have degree at most 2s−1 in F .We consider all O(n s ) options of choosing the vertices u 1 , . . ., u s .We check if U is an independent set.If the check fails, the guess is discarded.For each choice, we consider all O(n s(2s−1) ) options of choosing a set Z of size at most s(2s − 1) that contains the (at most 2s − 1) neighbours of each u i (1 ≤ i ≤ s) in F .For each choice of Z we now do as follows.We delete every neighbour of every u i that is not in Z from G, that is, we delete the set N (U ) \ Z.Let G ′ be the new graph; see also Fig. 7.Note that N G ′ (U ) = Z.Let w ′ be the restriction of w to V (G ′ ) and let As G is (sP 1 + P 4 )-free, G ′ is also (sP 1 + P 4 )-free.As U is an independent set of size s and N G ′ (U ) = Z, this means that G ′ − (U ∪ Z) is P 4 -free.Let G be the class of P 4 -free graphs.Then, as |U ∪ Z| ≤ s(2s − 1) + s = 2s 2 , we have that G ′ belong to G + 2s 2 v.As the mim-width of the class G of P 4 -free graphs is bounded and quickly computable by Lemma 9, we can apply Lemma 10 and then we can use Theorem 4 on (G ′ , w ′ , T ′ ).Since the number of branches is O(n 2s 2 ), the running time of our algorithm is polynomial.
Fig. 7.The graph G ′ from the proof of Lemma 11.

The Algorithm
In this section we present our algorithm for Weighted Subset Feedback Vertex Set restricted to (2P 1 + P 4 )-free graphs.We first need to prove one more structural lemma for core-complete solutions.We prove this lemma for any value s ≥ 2, such that we can use this lemma in the next section as well.However, for s = 2 we have a more accurate upper bound on the size of the core.
Lemma 12.For some s ≥ 2, let G = (V, E) be an (sP 1 + P 4 )-free graph.Let T ⊆ V .Let F be a core-complete T -forest of G such that T ∩ V (F ) = ∅.Then the core of F contains every vertex of T ∩ V (F ), and T ∩ V (F ) has size at most 2s − 2. If s = 2, the core of F is a clique of size at most 2 (in this case T ∩ V (F ) has size at most 2 as well).
Proof.Consider a vertex u ∈ T ∩ V (F ).For a contradiction, assume that u does not belong to the core of F .Then u has at least 2s neighbours in F .Let V u = {v 1 , . . ., v p } for some p ≥ 2s be the set of neighbours of u in F .Let A be the connected component of F that contains u.As F is a T -forest, A − u consists of p connected components D 1 , . . ., D p such that v i ∈ V (D i ) for i ∈ {1, . . ., p}.In particular, this implies that V u = {v 1 , . . ., v p } must be an independent set.As the core of F has no independent set of size s, this means that at most s − 1 vertices of V u may belong to the core of F .Recall that p ≥ 2s.Hence, we may assume without loss of generality that v 1 , . . ., v s+1 do not belong to the core of F .This means that v 1 , . . ., v s+1 each have degree at least 2s in A. Hence, for i ∈ {1, . . ., s + 1}, vertex v i is adjacent to some vertex w i in D i .As s ≥ 2, we have that 2s > s + 1 and hence, vertex v s+2 exists.However, now the vertices w 1 , v 1 , u, v s+2 , w 2 , w 3 , . . ., w s+1 induce an sP 1 + P 4 , a contradiction (see also Fig. 8).
From the above, we conclude that every vertex of T ∩ V (F ) belongs to the core of F .As F is a T -forest, T ∩ V (F ) induces a forest, and thus a bipartite graph.As F is core-complete, every independent set in the core has size at most s − 1.Hence, T ∩ V (F ) has size at most 2(s − 1) = 2s − 2. Now suppose that s = 2.As F is core-complete, the core of F must be a clique.As the core of F contains T ∩ V (F ) and T ∩ V (F ) induces a forest, this means that the core of F , and thus also T ∩ V (F ), has size at most 2.This completes the proof of the lemma.By using the above results and the results from Sections 3.1 and 3.2, we are now able to prove our main result.
Proof.Let G = (V, E) be a (2P 1 + P 4 )-free graph, and let T be some subset of V .Let w be a positive vertex weighting of G.We aim to find a maximum weight T -forest F for (G, T, w) (recall that we call T -forests solutions for our problem).As s = 2, the core of F is, by definition, the set of vertices of F that have maximum degree at most 3 in F .We first compute a core-incomplete solution of maximum weight; this takes polynomial time by Lemma 11 (in which we set s = 2).We will now compute in polynomial time a core-complete solution F of maximum weight for (G, T, w).We then compare the weights of the two solutions found to each other and pick one with the largest weight.
By Lemma 12, it holds for every core-complete solution F that T ∩ V (F ) belongs to the core of F , and moreover that |T ∩ V (F )| ≤ 2. We first compute a core-complete solution F with |T ∩ V (F )| ≤ 1 of maximum weight.As T ∩ V (F ) belongs to the core of F , we find that if |T ∩ V (F )| = 1, say T ∩ V (F ) = {u} for some u ∈ T , then u has maximum degree at most 3 in F .Hence, in the case where |T ∩ V (F )| ≤ 1, it suffices to compute a ≤1-part solution, 2-part solution and 3-part solution for (G, T, w) of maximum weight and to remember one with the largest weight.By Lemmas 2, 5 and 8, respectively, this takes polynomial time.
It remains to compute a core-complete solution F with |T ∩ V (F )| = 2 of maximum weight.By Lemma 12, it holds for every such solution F that both vertices of T ∩ V (F ) are adjacent and are the only vertices that belong to the core of F .
We consider all O(n 2 ) possibilities of choosing two adjacent vertices of T to be the two core vertices of F .Consider such a choice of adjacent vertices u 1 , u 2 .So, u 1 and u 2 are the only vertices of degree at most 3 in the solution F that we are looking for and moreover, all other vertices of T do not belong to F .Suppose one of the vertices u 1 , u 2 has degree 1 in F .First let this vertex be u 1 .Then we remove u 1 and all its neighbours except for u 2 from G. Let G ′ be the resulting graph.Let T ′ = T \ ({u 1 } ∪ (N (u 1 ) \ {u 2 })), and let w ′ be the restriction of w to G ′ .We now compute for (G ′ , w ′ , T ′ ), a ≤1-part solution and 2-part solution of maximum weight with u 2 as center.By Lemmas 2 and 5, respectively, this takes polynomial time. 8We then add u 1 back to the solution to get a solution for (G, w, T ).We do the same steps with respect to u 2 .In the end we take a solution with largest weight.
So from now on, assume that both u 1 and u 2 have degree at least 2 in F .We first argue that in this case both u 1 and u 2 have degree exactly 2 in F .For a contradiction, suppose u 1 has degree 3 in F (recall that u 1 has degree at most 3 in F ). Let v 1 and v ′ 1 be two distinct neighbours of 1 and D 2 , respectively.However, now x 2 , v 2 , u 2 , u 1 , x 1 , x ′ 1 induce a 2P 1 + P 4 in F and thus also in G, a contradiction; see also Fig. 9.
From the above we conclude that each of u 1 and u 2 has exactly one other neighbour in F .Call these vertices v 1 and v 2 , respectively.We consider all O(n 2 ) possibilities of choosing v 1 and v Let G ′ be the graph obtained from G by removing every vertex of T , every neighbour of u 1 except v 1 and every neighbour of u 2 except v 2 .Let w ′ be the restriction of w to G ′ .Then, it remains to solve Weighted Vertex Cut for the instance (G ′ , v 1 , v 2 , w ′ ).By Lemma 4, this can be done in polynomial time.Out of all the solutions found for different pairs u 1 , u 2 we take one with the largest weight.Note that we found this solution in polynomial time, as the number of branches is O(n 4 ).
As mentioned we take a solution of maximum weight from all the solutions found in the above steps.The correctness of our algorithm follows from the fact that we exhaustively considered all possible situations.Moreover, the number of situations is polynomial and processing each situation takes polynomial time.Hence, the running time of our algorithm is polynomial.

The Unweighted Variant
In this section, we present our polynomial-time algorithm for Subset Feedback Vertex Set on (sP 1 + P 4 )-free graphs for every s ≥ 0. As this problem is a special case of Weighted Subset Feedback Vertex Set (namely when w ≡ 1), we can use some of the structural results from the previous section.
Theorem 6. Subset Feedback Vertex Set is polynomial-time solvable on (sP 1 + P 4 )-free graphs for every s ≥ 0.
Proof.Let G = (V, E) be an (sP 1 + P 4 )-free graph for some integer s, and let T ⊆ V .Let |V | = n.As the class of (sP 1 + P 4 )-free graphs is a subclass of the class of ((s + 1)P 1 + P 4 )-free graphs, we may impose any lower bound on s; we set s ≥ 2. We aim to find a T -forest F of G of maximum size (recall that we call T -forests solutions for our problem).We first compute a maximum-size core-incomplete solution for (G, T ).By Lemma 11, this takes polynomial time.It remains to compare the size of this solution with a maximum-size core-complete solution, which we compute below.
By Lemma 12, we find that T ∩ V (F ) has size at most 2s − 2 for every corecomplete solution F ; see also Fig. 10.We consider all O(n 2s−2 ) possibilities of choosing the vertices of T ∩ V (F ).For each choice of T ∩ V (F ) we do as follows.We note that the set of vertices of G − T that do not belong to F has size at most |T ∩ V (F )|; otherwise F ′ = V \ T would be a larger solution than F .Hence, we can consider all O(n |T ∩V (F )| ) = O(n 2s−2 ) possibilities of choosing the set of vertices of G − T that do not belong to F , or equivalently, of choosing the set of vertices of G − T that do belong to F .In other words, we guessed F by brute force, and the number of guesses is O(n 4s−4 ).In the end we found in polynomial time a maximum-size core-complete solution.We compare it with the maximum-size core-incomplete solution found above and pick one with the largest size.

Conclusions
By combining known hardness results with new polynomial-time results, we completely classified the complexities of Weighted Subset Feedback Vertex Set and Subset Feedback Vertex Set for H-free graphs.We recall that the classical versions Weighted Feedback Vertex Set and Feedback Vertex Set are not yet completely classified due to missing cases when H is a linear forest (see Theorem 1).We finish our paper with a brief discussion on the variant where instead of intersecting every T -cycle, a solution only needs to intersect every T -cycle of odd length.These two problems are called Weighted Subset Odd Cycle Transversal and Subset Odd Cycle Transversal, respectively.
So far, both these problems behave in exactly the same way on H-free graphs as their feedback vertex set counterparts (see [4] and [5]).So, the only open cases for Weighted Subset Odd Cycle Transversal on H-free graphs are the ones where H ∈ {2P 1 +P 3 , P 1 +P 4 , 2P 1 +P 4 } and the only open cases for Subset Odd Cycle Transversal on H-free graphs are the ones where H = sP 1 + P 4 for some s ≥ 1.Since solutions F for these problems may only contain vertices of T of high degree, we can no longer use the proof technique from this paper, and new ideas are needed.

Fig. 1 .
Fig. 1.Two examples of a slightly modified Petersen graph with the set T indicated by square vertices.In both examples, the set ST of black vertices is a T -feedback vertex set.On the left, ST \ T = ∅.On the right, ST ⊆ T ..

Fig. 3 .
Fig. 3.The ≤1-part solution (in grey) constructed in the proof of Lemma 2. Such a solution consists of the vertex u ∈ T , the set V \ (N (u) ∪ T ) and possibly a vertex v ∈ N (u) \ T .

Fig. 4 .
Fig. 4. The 2-part solution (in grey) constructed in the proof of Lemma 5.The graph G ′ consists of the vertex u, the independent set {v1, v2} and the set V \ (N (u) ∪ T ).The 2-part solution is obtained from G ′ after deleting the vertices of a minimum weight vertex cut of G ′ − u that separates v1 from v2.

Fig. 6 .
Fig.6.The contradictions obtained in Lemma 8. On the left we have Case (i) and on the right, Case (ii): in both cases we obtain an induced 2P1 + P4 (highlighted by the black vertices and thick edges).

Fig. 8 .
Fig.8.An example of the contradiction obtained in Lemma 12: the assumption that a vertex u ∈ T does not belong to the core of a core-complete solution leads to the presence of an induced sP1 + P4 (highlighted by the black vertices and thick edges).

1 x2Fig. 9 .
Fig.9.The situation in Theorem 5 where u1 has degree at least 3 in F and u2 has degree 2 in F ; this leads to the presence of an induced 2P1 + P4 (highlighted by the black vertices and thick edges).

2 Fig. 10 .
Fig. 10.The situation in Theorem 6 where we search for a largest core-complete solution for (G, T ).
at least one vertex of every T -cycle; see also Fig.1.We now consider the following generalizations of Feedback Vertex Set:Subset Feedback Vertex SetInstance: a graph G, a subset T ⊆ V (G) and an integer k.
Question: does G have a T -feedback vertex set S T with |S T | ≤ k? Weighted Subset Feedback Vertex Set Instance: a graph G, a subset T ⊆ V (G), a positive vertex weighting w of G and a rational number k. Question: does G have a T -feedback vertex set S T with w(S T ) ≤ k?