Edge deletion to tree-like graph classes

For a fixed property (graph class) ${\Pi}$, given a graph G and an integer k, the ${\Pi}$-deletion problem consists in deciding if we can turn $G$ into a graph with the property ${\Pi}$ by deleting at most $k$ edges. The ${\Pi}$-deletion problem is known to be NP-hard for most of the well-studied graph classes, such as chordal, interval, bipartite, planar, comparability and permutation graphs, among others; even deletion to cacti is known to be NP-hard for general graphs. However, there is a notable exception: the deletion problem to trees is polynomial. Motivated by this fact, we study the deletion problem for some classes similar to trees, addressing in this way a knowledge gap in the literature. We prove that deletion to cacti is hard even when the input is a bipartite graph. On the positive side, we show that the problem becomes tractable when the input is chordal, and for the special case of quasi-threshold graphs we give a simpler and faster algorithm. In addition, we present sufficient structural conditions on the graph class ${\Pi}$ that imply the NP-hardness of the ${\Pi}$-deletion problem, and show that deletion from general graphs to some well-known subclasses of forests is NP-hard.


Introduction
A graph modification problem consists in deleting or adding edges or vertices to a graph so that the resulting graph fullfils some pre-specified properties. More formally, for a fixed property Π that usually represents membership to a graph class, given a graph G and an integer k, the Πdeletion (resp. completion, editing) problem consists in deciding whether it is possible to modify the graph by deleting (resp. adding, or adding and deleting) at most k edges to obtain a new graph that fullfils the property Π. There is one more version of this type of problems, which is the Π-vertex-deletion, that consists of determining if there exists an induced subgraph with the property Π, obtained by deleting at most k vertices. These are the decision versions of graph modification problems, which also admit an optimization version. When k is not a part of the input, the most natural goal in graph modification problems is to find a minimum modification, this is, to determine the smallest subset of edges or vertices that one has to delete or add to obtain a graph with the desired property.
Graphs are very useful to model quite diverse real world and theoretical structures. In particular, graph modification can be used to model and solve a wide variety of problems in many dissimilar fields, such as database and inconsistency management [14], computer vision [5], and molecular biology [8,9], to name a few. Furthermore, many fundamental problems in graph theory can be reinterpreted as graph modification problems. For example, the Connectivity problem can be thought of as the problem of finding the minimum number of vertices or edges that disconnect the graph when removed from it.
Unfortunately, most graph modification problems turn out to be intractable. Yannakakis [16] proved that finding a maximum connected subgraph with a property Π is NP-hard not only for every "non-trivial" hereditary property Π, but also for other properties that are not hereditary. One example of this are trees and stars: even though trees and stars are not hereditary classes, every connected induced subgraph of a tree is a tree and every connected induced subgraph of a star is a star. As a consequence of the aforementioned result by Yannakakis, removing the minimum number of vertices to obtain a tree or a star turns out to be NP-hard.
As for the Π-deletion problem, there are no such general results. The relationship between the vertex and the edge version of the problem is also not consistent. One example we might consider is the property Π of being a forest. In this case, the Π-deletion problem is equivalent to that of finding a spanning tree for each connected component of the input graph, which is easy. Whereas it follows from the results by Yannakakis that minimum vertex deletion for an induced forest is NP-hard. Furthermore, concerning Π-deletion problem there are some NP-hardness results that hold for some quite large families of hereditary properties, such as the property of being P k -free, or cluster. An interesting characterization of the Π-deletion problem for a large and natural family of graph properties, similar to the one given by Yannakakis, can be found in [1]. In this paper, it was shown the NP-hardness of the Π-deletion problem for every monotone property Π that holds for all bipartite graphs. This certainly encompasses many properties, for example the one of being triangle-free.
The Π-deletion problem turns out to be hard for most graph classes (e.g. planar, chordal, bipartite, interval and proper interval, split, threshold, etc), but polynomially solvable for trees. This work is motivated by the exploration of the tractable-intractable threshold of the Π-deletion problem when Π is a graph class closely related to trees, such as constellations, caterpillars, and cactus. We find that the decision version of all these problems is NP-complete, even for bipartite graphs. However, we were able to find a polynomial algorithm for cactus deletion when the input graph is restricted to chordal graphs. Furthermore, for the cactus case we prove that the problem is fixed-parameter tractable (FPT) for bounded clique-width graphs, by resorting to Courcelle's celebrated theorem [7].
This article is organized as follows. Section 2 presents basic definitions, Section 3 gives NPcompleteness proofs for constellations, caterpillars, and cacti. In Section 3.4, we propose sufficient structural properties for a graph class Π so that the Π-deletion problem results NP-hard within bipartite graphs. Section 4 focuses on positive results: we prove that cactus deletion is polynomialtime solvable when the input graph G is chordal; a specialized, efficient procedure is presented for quasi-threshold graphs. We also give in Section 4.3 the proof that cactus deletion is FPT for bounded clique-width graphs. Finally, the last Section 5 is devoted to conclusions and future work directions.

Definitions
All the graphs in this paper are undirected and simple, unless explicitly stated otherwise. Let G be a graph, and let V (G) and E(G) denote its vertex and edge sets, respectively. We denote by n the number of vertices and by m the number of edges. Further, we use the standard notation N (V ′ ) for the neighborhood of a subset V ′ of V . Whenever it is clear from the context, we simply write V and E and note G = (V, E). For basic definitions not included here, we refer the reader to [4].
Given a graph G and S ⊆ V , the subgraph of G induced by S, denoted by G[S], is the graph with vertex set S such that two vertices of S are adjacent if and only if they are adjacent in G. When G ′ and G[S] are isomorphic for some S ⊆ V , by abuse of terminology we say that G ′ is an induced subgraph of G. If V ′ ⊆ V and E ′ ⊆ E, we simply say that H = (V ′ , E ′ ) is a subgraph of G, whether E ′ consists of all the edges between vertices in V ′ or only a subset of those. For any family F of graphs, we say that G is F -free if G does not contain any graph F ∈ F as an induced subgraph. If F ∈ F is the unique element of F , we may write F -free, instead. If a graph G is F -free, then the graphs in F are called the forbidden induced subgraphs of G. A graph property Π is hereditary if Π is inherited by every induced subgraph of a graph.
A graph is complete if all its vertices are pairwise adjacent. A vertex is universal if it is adjacent to all the vertices in a graph. A clique in a graph G is a complete induced subgraph of G. Also, we will often use this term for the vertex set that induces the clique. We denote by K n the complete graph of n vertices. Let , and the join of G 1 and G 2 is the graph Any cograph can be constructed from K 1 by repeated application of union and join operations. A graph is quasi-threshold if it is {P 4 , C 4 }-free. Analogously as for cographs, quasi-threshold graphs can be defined recursively from K 1 by either repeatedly considering disjoint unions, or adding a universal vertex.
A graph is cluster if it is the union of cliques. A graph is a block graph if every maximal 2-connected component (i.e. every block ) is a clique.
A graph G is an interval graph if it admits an intersection model consisting of intervals on the real line, that is, a family I of intervals on the real line and a one-to-one correspondence between the set of vertices of G and the intervals of I such that two vertices are adjacent in G if and only if the corresponding intervals intersect. A proper interval graph is an interval graph that admits a proper interval model, this is, an intersection model in which no interval is properly contained in any other.
A graph G is a bipartite graph if its vertex set can be partitioned into two sets V 1 , V 2 of pairwise nonadjacent vertices. A bipartite graph is complete if every pair of vertices v 1 ∈ V 1 , v 2 ∈ V 2 is an edge of the graph and, if |V 1 | = n and |V 2 | = m, we denote it by K n,m .
A forest is an acyclic graph. A tree is a connected acyclic graph. The vertices of degree 1 of a graph are called pendant vertices and pendant vertices of a tree are called leaves. A path is a sequence of vertices v 1 , v 2 , . . . , v k such that v i and v i+1 are adjacent for each 1 ≤ i ≤ k − 1 and v i v j is not an edge for every pair of non-consecutive vertices v i and v j . We denote by P k a path with k vertices.
A graph G is a caterpillar if G is a tree in which the removal of all the leaves results in a path (called the spine or central path).
A star is a complete bipartite graph K 1,n for some n ≥ 0. A constellation is a forest where each connected component is a star.
A graph G is a cactus if G is connected and every edge of the graph lies in at most one cycle. Given a graph class Π, we say that a subgraph H of G is a maximum spanning Π if H belongs to Π and the number of edges is maximum among all the Π-subgraphs of G. A graph G is chordal if it contains no induced cycles of length greater than 3.
A graph G is planar if it admits a planar embedding, this is, there is a way to draw it on the plane such that its edges intersect only at their endpoints.
A hamiltonian path (resp. cycle) is a path (resp. cycle) that visits each vertex of a graph exactly once. A dominating set of a graph G = (V, E) is a subset D ⊆ V such that each vertex in V \ D is adjacent to at least one vertex in D.
Given a graph G, the decision problem Hamiltonian Path consists on deciding if there is a hamiltonian path in G, or not. For its part, given a graph G and a integer k, the decision problem Dominating Set consists on determining whether there is a dominating set of G of size at most k. Both problems are known to be NP-complete, even when the input is restricted to subclasses of bipartite or chordal graphs (see, for example, [2,3,6,10,17]).
we focus our attention in a superclass of trees.
This section is organized as follows. First, we show in Sections 3.1 and 3.2 that the problem is intractable for constellations and caterpillars. In Section 3.3, we focus our study to superclasses of trees by considering cactus graphs as the target class. We prove that the problem is hard for bipartite graphs and some of its subclasses, thus obtaining hardness for the general case. Finally, in Section 3.4 we generalize the previous hardness results for Π-deletion by obtaining sufficient structural conditions for the target class Π.

Constellations
The first target class we consider is constellations. We show Deletion to constellations is equivalent to Dominating Set in the following way.
Conversely, let H be a spanning constellation of G obtained by the deletion of |E(G)|−|V (G)|+ k edges, and let D = {u | u is the center of a star in H}. Notice that |E(H)| = |V (G)| − k and, since it is acyclic, it contains exactly k connected components. Hence |D| = k, as the connected components of H are stars and D has precisely one vertex from each star. Since D is a dominating set of H, it is also a dominating set of G and the result follows.
For the general case, we get the following corollary.
Corollary 3.2. The problem Deletion to constellations is NP-complete for general graphs. Remark 3.3. Notice that Deletion to constellations remains hard for any graph classes for which Dominating Set is hard. In particular, this problem remains hard for planar bipartite graphs [17] and split graphs [2,6]. On the other hand, it can be polynomially solved within cographs and outerplanar graphs [15].

Caterpillars
We continue studying the general deletion problem by considering another subclass of trees, namely caterpillars, as the target class. Proof. The problem is clearly in NP. We prove the hardness of Deletion to caterpillar by reducing the problem from Hamiltonian Path.
Let G = (V, E) be an instance of Hamiltonian Path. We define an instance of Deletion to caterpillar as follows. Let H = (W, F ) be a graph obtained by subdividing each edge of G precisely twice. In other words, for each edge e = uv ∈ E, add two vertices u e , v e such that uu e , u e v e , v e v ∈ F .
Suppose there is a hamiltonian path in G. Consider the following spanning caterpillar C of H. The spine is the hamiltonian path of G, where instead of traversing the edge e = uv ∈ E, we traverse the path u, u e , v e , v in H. Notice that the only vertices that are not visited by the spine in H are those intermediate new vertices u e , v e for some e = uv ∈ E that is not in the hamiltonian path. For these pairs of unvisited vertices, add the edges uu e and v e v to C. The resulting subgraph is a spanning caterpillar of H.
Conversely, a spanning caterpillar C of H has a spine S. Let us see that we can extract a hamiltonian path in G from this spine. Suppose there is a vertex u ∈ G that is not a part of the spine S in H. Notice that, in a spanning caterpillar of H, all vertices should be incident to at least one edge in C. The vertex u in H is adjacent only to intermediate new vertices, thus there is an edge u e u ∈ C and such that u e ∈ S. However, the only vertex adjacent to u e besides u is another intermediate vertex v e . Hence, both u e , v e ∈ S and therefore we can consider u as a vertex in S. The hamiltonian path is precisely the path resulting of traversing the edges uv ∈ G for which the path u, u e , v e , v is a part of the spine of C in H.
Remark 3.5. Similarly as in the case of Deletion to constellations, notice that the same proof given for Theorem 3.4 suffices to show that Deletion to caterpillar remains hard for graphs classes for which Hamiltonian Path is hard for closed for double subdivision of edges, which is the case of planar bipartite graphs [10].

Cacti
Instead of focusing on subclasses, we now turn our attention to a superclass of trees.
Theorem 3.6. Deletion to cactus is NP-complete even for bipartite graphs.
Proof. Membership in NP is clear. For the NP-hardness, we reduce the problem from Partition into P 3 : Given a graph G = (V, E), the problem Partition to P 3 (PIP3) consists in deciding whether there exists a partition of V into vertex-disjoint P 3 's. PIP3 is known to be NP-hard, even for subcubic bipartite graphs [12].
Let G be a subcubic bipartite instance of PIP3, with bipartition {X, Y }. We may assume that |V (G)| is divisible by 3, otherwise the answer is trivially negative. Let H be a graph with Notice that H is bipartite. Let k = |E(H)| − 4|V (G)|/3 − 4. We will show that there is a partition into P 3 's for G if and only if there is a spanning cactus subgraph of H that is obtained by removing at most k edges from E(H).
First, suppose G has a partition P into (induced) P 3 's, and let E(P) be the set of edges appearing in P. Let S be the set of endpoints of each P 3 in P, S X = S ∩ X, and It is easy to see that  Notice that by replacing c in the equation |E(H ′ )| = |V (H ′ )| + c − 1, it follows that exactly k edges were removed from H. Also note that the equality must hold in |E(H ′ )| ≥ ℓ i ≥ 4c, implying that ℓ 1 = . . . = ℓ c = 4 and that each edge belongs to exactly one C 4 . Since x ′ and y ′ belong to exactly one cycle, namely C = xx ′ y ′ yx, all the other cycles must contain vertices from G. Finally, every degree 2 vertex of each cycle C in H ′ that is not C lies in G. Consider a partition into P 3 's as follows. For each cycle C such that either x ∈ C or y ∈ C, take the P 3 consisting of C \ {x} or C \ {y}, respectively. We will show that for each C such that all its vertices lie in G, exactly one of its vertices v lies in another cycle of the cactus. Since G is a subcubic graph, each vertex v in such a cycle C lies in at most two cycles of the cactus. Moreover, precisely one edge incident to v is either xv or yv. If there are two vertices v and v ′ in C such that both lie in other cycles, then the edges of the vv ′ -path in C also belong to another cycle, using edges of E(H ′ ) \ C, a contradiction. Hence, if v is the only vertex of such a cycle C belonging to another cycle, we may take the P 3 consisting of C \ {v}. This gives a partition into P 3 's of G.

Sufficient conditions for hardness results within bipartite graphs
All the previous deletion problems remain hard even if the input graph is bipartite. In this section, we give a set of sufficient conditions for a property Π such that Π-deletion remains hard within bipartite graphs.
Remark 3.9. A bipartite claw-free acyclic graph is the union of paths.
The following result summarizes necessary conditions for the graph class Π in order to obtain hardness for the Π-deletion problem. (ii) Π is claw-free; (iii) Π is even-hole-free.
Then, Π-deletion is NP-hard, even when the input is restricted to planar bipartite graphs of maximum degree 3, or chordal bipartite graphs.
Proof. It follows from Remark 3.8, (ii) and (iii) that the final graph obtained after Π-deletion will be a bipartite claw-free acyclic graph. Moreover, it follows from Remark 3.9 and (i) that a solution exists and that the resulting graph is the union of paths.
For the NP-hardness, we give a reduction from Hamiltonian Path. Let us consider a bipartite graph G. From the previous observations, any subgraph belonging to Π has at most |V (G)| − 1 edges. Furthermore, the equality holds if and only if the resulting graph is a path, implying that the original graph has a hamiltonian path. On the other hand, if the original graph has a hamiltonian path, removing all other |E(G)| − (|V (G)| − 1) edges will turn the graph into a path. Hence, G is hamiltonian if and only if there is a Π-deletion of size |E(G)| − (|V (G)| − 1).
Finally, since Hamiltonian Path is hard even for planar bipartite graphs of maximum degree 3 and chordal bipartite graphs, the same argument shows that Π-deletion is hard even restricted to these classes.

Corollary 3.11. The Π-deletion problem is NP-hard when Π is the class of proper interval graphs, paths, claw-free chordal, power of paths and cycles, even if the input is a bipartite graph.
Finally, an interesting remark is that, if a class has bounded treewidth, it follows from [13] that deletion to proper interval graphs is polynomial-time solvable. In particular, this implies that the problem is easy for trees, cacti, and outerplanar graphs, which is a nice contrast with the hardness for planar bipartite graphs of maximum degree 3 and chordal bipartite graphs.

Algorithms for cactus deletion
For the natural classes considered in Section 3, the complexity of Deletion to constellations and Deletion to caterpillar is very well understood, since they are closely related to the extensively studied Hamiltonian Path and Dominating Set problems. In this section we devote our attention to Deletion to cactus, for which no previous results were known.
Recall that Deletion to cactus is NP-complete even for subcubic bipartite graphs. This motivated the search for positive results on this problem. In Section 4.1 we study the problem within chordal graphs, showing that it turns out to be polynomial-time solvable. However, this result does not lead trivially to such an algorithm. With this in mind, in Section 4.2 we focus on subclasses of chordal graphs, and give an explicit efficient algorithm when the input is a quasithreshold graph. Finally, and based on the intractability of cactus deletion in the general case, in Section 4.3 we study the parameterized complexity of the problem and give a MSOL formula for cactus deletion.

Deletion to cactus within chordal graphs
In this section we will prove that cactus deletion from chordal graphs is polynomial-time solvable. To do this, we will resort to a result by Lovász [11] which shows that, given a 3-uniform hypergraph, finding the maximum Berge-acyclic subhypergraph can be solved in polynomial time.
We start this section by giving some definitions that will be useful in the sequel. Afterward, given a chordal graph G, we define an auxiliary hypergraph and use the aforementioned result by Lovász to find a maximum spanning cactus of G. A Berge-cycle is a sequence (E 1 , x 1 , . . . , E n , x n ) with n ≥ 2 such that: 1. E i are distinct hyperedges, 2. x i are distinct vertices, and 3. for every 1 ≤ i ≤ n, x i belongs to E i and E i+1 , where subindices are modulo n.
A hypergraph is Berge-acyclic if it contains no Berge-cycle.
Let G = (V, E) be a chordal graph. We denote by H(G) = (V, E) the hypergraph whose hyperedges are precisely those subsets that induce a 3-cycle in G.
Notice that, if G ′ is a subgraph of G such that G ′ is a cactus and each cycle has length 3, then H(G ′ ) is a Berge-acyclic subhypergraph of H(G). Also notice that two vertices are adjacent in H(G) if there is an hyperedge that contains both of them, this is, if both vertices lie in some 3-cycle of G. In particular, this implies that there is an edge in G that joins them.
Given a set of edges  Proof. First, let us see that every cycle in F i is a 3-cycle. Toward a contradiction, let C = x 1 x 2 . . . x n x 1 be an induced cycle in F i of length n > 3. Since C is an induced cycle, there are no chords between vertices in C. Thus, every hyperedge that intersects C contains at most two vertices of C. Furthermore, each hyperedge that shares two vertices with C contains precisely two consecutive vertices of C, for if not we find a chord in the cycle C. In addition, notice that no edge in F i lies in two distinct hyperedges of H ′ (G) since it is a Berge-acyclic subhypergraph of H(G). By simplicity, let us denote by (E i , x i ) to the hyperedge in H ′ (G) that gives us the edge x i x i+1 in the cycle C. However, {(E i , x i ) : i = 1, . . . , n} is a Berge-cycle in H ′ (G) and this results in a contradiction.
Also notice that, if C 1 and C 2 are two distinct induced cycles in F i , then C 1 and C 2 share at most one vertex. This follows once more from the fact that no edge in F i lies in two distinct hyperedges of H ′ (G). It follows immediately from the previous discussion that each F i is a cactus.
Let D ⊆ E be those edges that do not lie in any 3-cycle of G. Notice that these edges are not considered when obtaining H(G).
of H(G). Let F 1 and F 2 be two connected components of G ′ such that F 1 and F 2 are connected in the original graph G by some missing edges of G. Since the missing edges belong to 3-cycles that are not considered in H ′ (G), there exists a vertex x in F 1 such that x is adjacent (in G) to two distinct vertices y 1 , y 2 in F 2 , and such that {x, y 1 , y 2 } is a hyperedge of H(G) \ H ′ (G), or vice versa. Let us assume without loss of generality that x in F 1 . This gives a procedure to construct the spanning cactus, in the following way: 1. Do while there is more than one connected component in G ′ 2. Find two connected components F 1 and F 2 such that they can be joined by a single edge e that belongs to E \ E(G ′ ). Define F := F 1 ∪ F 2 ∪ {e}.
Let us denote with X(G ′ ) the resulting subgraph.
Lemma 4.4. Let G be a chordal graph. There is always an optimal spanning cactus of G such that each cycle has length 3. We call this kind of solution a triangular-SC of G.
Proof. Suppose that the statement is false and let H be a counterexample maximizing the number of cycles of length 3 and, subject to that, minimizing the length of the minimum cycle of length greater than 3. Let C = {x 1 , . . . , x k } be a minimum cycle with k > 3. Since G is chordal, G[C] must contain a chord. Without loss of generality, let x 1 x i be such chord. We claim that is an optimal spanning cactus of G. Note that C ′ = {x 1 , x i , . . . , x k } is a cycle in H ′ , and since each edge of E(C ′ ) \ {x 1 x i } belongs to exactly one cycle of H, it also belongs to exactly one cycle in H ′ , namely C ′ . Moreover, edges in {x j x j+1 | 2 ≤ j ≤ i − 1} belong to one cycle in H and to no cycle in H ′ . Hence H ′ is an spanning cactus of G with at least the same number of cycles of length 3 as H and since the length of C ′ is smaller than the length of C the result follows.
We have the following remark as a direct consequence of the previous lemma.
Remark 4.5. A sub-optimal triangular-SC of G always has fewer triangles than an optimal triangular-SC of G.
Using all the previous results, it follows that: Proof. If this is not true, then there is an optimal triangular-SC Y such that |Y | > |X|. It follows from Remark 4.5 that Y has more triangles than X. If we consider the corresponding hypergraph for Y , then this gives us a Berge-acyclic subhypergraph of H(G) that is bigger than the maximum H ′ (G) = (V ′ , E ′ ) that we found before. This results in a contradiction.

Cactus deletion from Quasi-Threshold
In the previous subsection, we provided proof that cactus deletion is polynomial when the input graph is chordal. Nevertheless, it is not trivial to derive an explicit algorithm from this result, ultimately based on matroid theory. The following results complete the section by giving simple and efficient procedures for some subclasses of chordal graphs. Now, we focus on quasi-threshold graphs, and in the next subsection we deal with cluster and block graphs.
Lemma 4.7. Let G = G 1 ⊕ G 2 be a cograph. Then, there is a spanning cactus subgraph H with maximum number of edges such that each cycle of H is either a C 3 or a C 4 and has a vertex in V (G 1 ) and a vertex in V (G 2 ).
Proof. Let H be a spanning cactus subgraph of G with the maximum number of edges, such that it contains a cycle C k = v 0 , . . . , v k−1 . If H has a C k with k > 4 containing vertices from both G 1 and G 2 , then C k has at least one chord uv, and we can replace C k for a smaller cycle by adding uv and deleting an edge connecting u and one of its neighbors in C k . If k ≤ 4 and C k has a vertex in V (G 1 ) and a vertex in V (G 2 ) the result follows. Let us now assume without loss of generality that the vertices of C k are all contained in V (G 1 ). We will construct another spanning cactus H ′ from H having the same number of edges, such that C k is transformed into a set of cycles, each of them having a vertex in V (G 1 ) and a vertex in V (G 2 ). The graph H ′ starts as a copy of the spanning cactus H. Let v ∈ V (G 2 ), and let v i be the vertex of C k at a shortest distance from v in H ′ . Notice that every path from a vertex of C k to v in H ′ passes through v i . Consider now vertices v i−1 and v i+1 (the sums and subtractions are considered modulo k), which are the neighbours of v i in C k . Delete edges v i−1 v i and v i v i+1 from H ′ . For the resulting path P k−1 obtained by removing these two edges from C k , extract a maximum matching M of P k−1 and delete the remaining edges E(P k−1 ) \ M from H ′ . Finally, for each edge e = u 1 u 2 ∈ M , add the edges vu 1 and vu 2 from G to H ′ . Moreover, if k − 1 is odd, then there is an unsaturated vertex w in P k−1 . Add the edge vw from G to H ′ . These edges exist in G, since u 1 , u 2 , w ∈ V (G 1 ) and v ∈ V (G 2 ). As the reader may easily verify, the resulting graph H ′ is a spanning cactus of G, in which the cycle C k has been replaced by a collection of cycles having a vertex in V (G 1 ) and a vertex in V (G 2 ). Moreover, the new cactus H ′ has (k − 1) − |E(P k−1 ) \ M | − 2 more edges than H, which was optimal. We conclude that k has to be either 3 or 4. Furthermore, the repeated application of this procedure allows to transform any spanning cactus H having C 3 or C 4 entirely contained in V (G 1 ) or V (G 2 ) into another spanning cactus H ′ in which these cycles have a vertex in V (G 1 ) and a vertex in V (G 2 ), and such that |E(H ′ )| = |E(H)|. Proof. It follows from the definition of quasi-threshold graph that G has a universal vertex v, since it is connected. In other words, G is the join of a graph G 1 containing a single vertex and another quasi-threshold graph G 2 . From Lemma 4.7, it follows that there is a subgraph H having the maximum possible number of edges such that v belongs to each cycle of H. Without loss of generality, we may assume that each cycle is a triangle. Therefore, to find such cycles it is enough to find a maximum matching in G 2 .

Parameterized complexity of deletion to cactus
Given a graph G, first order formulas for a graph-theoretic problem are constructed using atomic formulas and logical connectives. The variables used in the expression are elements of V (G) or E(G). The atomic formulas allowed are edg(x, y), that expresses the adjacency between two vertices x and y in V (G), and the formula x = y, the expression of equality between x and y. The logical connectives are ¬ (negation), ∨ (conjunction), ∧ (disjunction), and ⇒ (implication). Quantification of members of the vertex set is performed by using existential (∃x) and universal quantification (∀x). Monadic second order logic is an extension of first-order logic by quantification over sets of elements: we may use formulas of the form ∃φ(X) which says that there exists a set X that satisfies the formula φ. In the context of graphs there are two natural options for what constitutes an element: we allow quantification over sets of vertices or quantification over sets of edges. This leads to two different logics which are sometimes referred to as M SOL 1 (or simply M SOL) and M SOL 2 , respectively, where M SOL 2 allows quantification over sets of edges and vertices whereas M SOL only allows quantification over sets of vertices. We state the well known theorem by Courcelle et al. that we will use in this section: Theorem 4.9. [7] Let φ be a M SOL 1 formula expressing a graph property. Then φ can be decided for a graph G of clique-width c in time τ (|φ|, c) · |V (G)|, for some function τ .
We are now ready to state the main result of this section: Proof. We present a MSOL formula for the problem; by Theorem 4.9, the result immediately follows. Given a formula φ, we will write ∃X ⊆ V φ as abbreviation for ∃X((∀x)(x ∈ X → x ∈ V )∧φ) and also X = Y as abbreviation for ¬(X ⊆ Y ∧ Y ⊆ X). Let G = (V, E) be our input graph.
The formula (1) expresses the existence of k (not necessarily distinct) edges of G, namely is a cactus, this is, H is connected and every edge belongs to at most one cycle.
We now give the precise definition of the main formula Cactus(G) and its parts: Where: Notice that this Theorem immediately provides an FPT algorithm for deletion to cactus, parameterized by the number of deleted edges and the clique-width of the graph. Alas, the most natural parameterization is the one given by fixing only the number of edges k to be deleted. We briefly discuss now a relation between k and the treewidth of the input graph G.
Let f (n) be the maximum number of edges in a cactus with n vertices. If G is a graph having more than f (|V (G)|) + k edges, then G cannot be modified into a cactus with k edge deletions. Let g(n) be the minimum number of vertices of degree at most 2 in a cactus of n vertices. With k deletions, the degree of at most 2k vertices can be changed. Hence, if the number of vertices of degree at most 2 in a graph G is less than g(n) − 2k, then we are dealing with a No instance.
Lemma 4.11. Let G be a graph, and let H = (V (G), E(G) \ S) be a cactus. Then, the treewidth of G is at most 2|S| + 2.
Proof. Since the treewidth of a cactus is at most 2, we can just consider a tree decomposition T of width 2 of H and add all the endpoints of every edge in S to all the bags of T . Clearly, this is a tree decomposition of G with width at most 2|S| + 2.
As a consequence of the previous lemma, it follows that, for any graph G there is a bound for its treewidth that depends solely on number k of edges that are deleted to obtain a cactus subgraph, thus the clique-width of G is also bounded by k. Note that k is also the positive integer in Theorem 4.10, and let φ be the formula of the theorem. It is easy to see that the length of φ depends only on k. As a result, we may apply Theorem 4.9, thus obtaining that φ can be decided in time τ ′ (k)|V (G)| for some function τ ′ . This gives the following result as a corollary: Corollary 4.12. There exists an FPT algorithm for Deletion to cactus, parameterized by k, the number of allowed deletions.

Conclusions and future work
In this work, we study the Π-deletion problem in some classes close to trees. We obtain hardness results for Π-deletion when Π is constellations, caterpillars and cactus. We also obtain a list of properties that are sufficient to determine that, if the graph class Π fulfils these conditions, then Π-deletion is NP-hard even when the input is a bipartite graph. Given the hardness of these results, we then focus our study on positive results for Deletion to cactus by restricting the input graph to chordal and quasi-threshold graphs. We also show that Deletion to cactus is linear within graph classes of bounded clique-width, and that the problem is also FPT when parameterized by the number of edges that we are allowed to delete.
One possible future direction for this work is to deepen the study of Deletion to cactus within other graph classes. We know that Deletion to cactus is polynomial-time solvable for quasi-threshold graphs, thus a natural question arises regarding the complexity of this problem in superclasses of quasi-threshold graphs that are not chordal, such as cographs. Another interesting graph class to restrict the input of the problem are planar graphs. Another natural direction to continue is to use Theorem 4.10 and restrict the input of cactus deletion to graph classes having bounded clique-width, in order to use their structural properties to design efficient algorithms for this problem.
Finally, we present an interesting related question: given a spanning tree T of a graph G, is the problem of completing T to a maximum spanning cactus by using only edges of G polynomial? Notice that the same problem is NP-hard if we ask for a maximum spanning chordal graph: consider a graph G, and add a universal vertex u. Consider the spanning tree T to be the star centered in the universal vertex u. Hence, the problem is equivalent to that of deletion to chordal in the original graph.