6 Feedback Vertex Set

In this chapter we will use the technique of layering, introduced in Chapter 2, to obtain a factor 2 approximation algorithm for: Problem 6.1 (Feedback vertex set) Given an undirected graphG= (V,E) and a functionw assigning nonnegative weights to its vertices,find a minimum weight subset ofV whose removal leaves an acyclic graph.

6.1 Cyclomatic weighted graphs

Order the edges ofG in an arbitrary order. The characteristic vector of a sim- ple cycleC inG is a vector in GF[2] m,m= E , which has 1’s in components corresponding to edges ofC and 0’s in the| remaining| components. The space ofG is the subspace of GF[2] m that is spanned by the characteristic vectors of all simple cycles ofG, and the cyclomatic number ofG, denoted cyc(G), is the dimension of this space. Theorem 6.2 cyc(G) = E V +κ(G), whereκ(G) denotes the number of connected components| ofG|−.| |

Proof: The cycle space of a graph is the direct sum of the cycle spaces of its connected components, and so its cyclomatic number is the sum of the cyclomatic numbers of its connected components. Therefore, it is sufficient to prove the theorem for a connected graphG. LetT be a spanning inG. For each nontree edgee, define its funda- mental cycle to be the unique cycle formed inT e . The set of characteristic vectors of all such cycles is linearly independent∪{ (each} cycle includes an edge that is in no other fundamental cycle). Thus, cyc(G) E V + 1. Each edgee ofT defines a fundamental cut(S, S)≥ in| G|−,S| |V(S and S are the vertex sets of two connected components formed by⊂ removinge from T ). Define the characteristic vector of a cut to be a vector in GF[2]m that has 1’s in components corresponding to the edges ofG in the cut and 0’s in the remaining components. Consider the V 1 vectors defined by edges ofT . Since each cycle must cross each cut an| |− even number of times, these vectors are orthogonal to the cycle space ofG. Furthermore, these V 1 | |− 6.1 Cyclomatic weighted graphs 55

vectors are linearly independent, since each cut has an edge (the tree edge defining this cut) that is not in any of the other V 2 cuts. Therefore the dimension of the orthogonal complement to the cycle| |− space is at least V 1. Hence, cyc(G) E V + 1. Combining with the previous inequality| we|− get cyc(G) = E≤| V|− |+| 1. ✷ | |−| | Denote byδ G(v) the decrease in the cyclomatic number of the graph on removing vertexv. Since the removal of a feedback vertex setF= v 1, . . . , vf decreases the cyclomatic number ofG down to 0, { }

�f

cyc(G) = δGi 1 (vi), − i=1

whereG 0 =G and, fori> 0,G i =G v 1, . . . , vi . By Lemma 6.4 below, we get: −{ } � cyc(G) δ (v). (6.1) ≤ G v F ∈ Let us say that a function assigning vertex weights is cyclomatic if there is a constantc> 0 such that the weight of each vertexv isc δ G(v). By inequality (6.1), for such a weight function,c cyc(G) is a lower· bound on OPT. The importance of cyclomatic weight functions· is established in Lemma 6.5 below, which shows that for such a weight function, any minimal feedback vertex set has a weight within twice the optimal. Let degG(v) denote the ofv inG, and comps(G v) denote the number of connected components formed by removingv from− G. The claim below follows in a straightforward way by applying Theorem 6.2 toG and G v. − Claim 6.3 For a connected graphG,δ (v) = deg (v) comps(G v). G G − − Lemma 6.4 LetH be a subgraph ofG (not necessarily vertex induced). Then,δ (v) δ (v). H ≤ G Proof: It is sufficient to prove the lemma for the connected components ofG andH containingv. We may thus assume w.l.o.g. thatG andH are connected (H may be on a smaller set of vertices). By Claim 6.3, proving the following inequality is sufficient:

deg (v) comps(H v) deg (v) comps(G v). H − − ≤ G − − We will show that edges inG H can only help this inequality. Let − c1, c2, . . . , ck be components formed by removingv fromH. Edges ofG H not incident atv can only help merge some of these components (and− of 56 6 Feedback Vertex Set

course, they don’t change the degree ofv). An edge ofG H that is incident atv can lead to an additional component, but this is− compensated by the contribution the edge has to the degree ofv. ✷

Lemma 6.5 IfF is a minimal feedback vertex set ofG, then � δ (v) 2 cyc(G). G ≤ · v F ∈

Proof: Since the cycle space ofG is the direct sum of the cycle spaces of its connected components, it suffices to prove the lemma for a connected graph G. LetF= v 1, . . . , vf , and letk be the number of connected components obtained by{ deletingF }fromG. Partition these components into two types: those that have edges incident to only one of the vertices ofF , and those that have edges incident to two or more vertices ofF . Lett andk t be the number of components of thefirst and second type, respectively.− We will prove that

�f �f δ (v ) = (deg (v ) comps(G v )) 2( E V ), G i G i − − i ≤ | |−| | i=1 i=1 � f thereby proving the lemma. Clearly, i=1 comps(G v i) =f+t. Therefore, we are left to prove −

�f deg (v ) 2( E V ) +f+ t. G i ≤ | |−| | i=1

v1 v2 vk . . .

. . . comp. 1 comp. 2 comp. k

SinceF is a feedback vertex set, each of thek components is acyclic and is therefore a tree. Thus, the number of edges in these components is V f k. Next, we put a lower bound on the number of edges in the cut (|F,|− V −F). − 6.2 Layering applied to feedback vertex set 57

SinceF is minimal, eachv F must be in a cycle that contains no other i ∈ vertices ofF . Therefore, eachv i must have at least two edges incident at one of the components. For eachv i, arbitrarily remove one of these edges from G, thus removing a total off edges. Now, each of thet components must still have at least one edge and each of thek t components must still have at least two edges incident atF . Therefore,− the number of edges in the cut (F,V F ) is at leastf+t + 2(k t) =f+2k t. These− two facts imply that− −

�f deg (v ) 2 E 2( V f k) (f+2k t). G i ≤ | |− | |− − − − i=1

The lemma follows. ✷

Corollary 6.6 Letw be a cyclomatic weight function on the vertices ofG, and letF be a minimal feedback vertex set in it. Thenw(F) 2 OPT. ≤ ·

6.2 Layering applied to feedback vertex set

Let us now deal with arbitrary weighted graphs. Consider the following basic operation: Given graphG=(V,E) and a weight functionw, let � � w(v) c = min . v V δ (v) ∈ G

The weight functiont(v)=cδ G(v) is the largest cyclomatic weight function in w. Definew �(v)=w(v) t(v) to be the residual weight function. Finally, − letV � be the set of vertices having positive residual weight (clearly,V � V), ⊂ and letG � be the subgraph ofG induced onV �. Using this basic operation, decomposeG into a nested sequence of induced subgraphs, until an acyclic graph is obtained, each timefinding the largest cyclomatic weight function in the current residual weight function. Let these graphs beG=G G G , whereG is acyclic;G is the induced 0 ⊃ 1 ⊃···⊃ k k i subgraph ofG on vertex setV i, whereV=V 0 V 1 V k. Lett i, i= 0, . . . , k 1 be the cyclomatic weight function de⊃fined⊃··· on⊃ graphG . Thus, − i w0 =w is the residual weight function forG 0,t 0 is the largest cyclomatic weight function inw ,w =w t is the residual weight function forG , 0 1 0 − 0 1 and so on. Finally,w k is the residual weight function forG k. For convenience, definet k =w k. Since the weight of a vertexv has been decomposed into the weightst 0, t1, . . . , tk, we have � ti(v)=w(v). i:v V ∈ i 58 6 Feedback Vertex Set

The next fact suggests an algorithm for constructing a feedback vertex set on which Lemma 6.5 can be applied.

Lemma 6.7 LetH be a subgraph ofG=(V,E), induced on vertex setV � ⊂ V . LetF be a minimal feedback vertex set inH, and letF � V V � be a ⊆ − minimal set such thatF F � is a feedback vertex set forG. ThenF F � is a minimal feedback vertex∪ set forG. ∪

Proof: SinceF is minimal forH, for eachv F , there is a cycle, sayC, in ∈ H that does not use any other vertex ofF . SinceF � V � = ,C uses only ∩ ∅ one vertex,v, fromF F � as well, and sov is not redundant.✷ ∪ After the entire decomposition,F k = is a minimal feedback vertex set ofG . Fori=k,k 1,..., 1, the minimal feedback∅ vertex setF found inG k − i i is extended in a minimal way using vertices ofV i 1 V i to yield a minimal − − feedback vertex set, sayF i 1, forG i 1. The last set,F 0, is a feedback vertex set forG. − −

Gk

Gk-1 Fk-1

. . .

G1 F1 - F2

G0 0 -F F1

Algorithm 6.8 (Feedback vertex set) 1. Decomposition phase H G,w � w,i 0 ← ← ← WhileH is not acyclic,� � w�(u) c min u H ← ∈ δH (u) G H,t c δ ,w � w � t i ← i ← · Gi ← − i H the subgraph ofG i induced by verticesu withw �(u)>0 i ←i+1, ← k i,G k H 2. Extension← phase← F k ← ∅ Fori=k,...,1, extendF i to a feedback vertex setF i 1 ofG i 1 by − − adding a minimal set of vertices fromV i 1 V i. − − OutputF 0. 6.2 Layering applied to feedback vertex set 59

Theorem 6.9 Algorithm 6.8 achieves an approximation guarantee of factor 2 for the feedback vertex set problem.

Proof: LetF ∗ be an optimal feedback vertex set forG. SinceG i is an induced subgraph ofG,F ∗ V i must be a feedback vertex set forG i (not necessarily optimal). Since the∪ weights of vertices have been decomposed into the functionst i, we have

�k �k OPT =w(F ∗) = t (F ∗ V ) OPT , i ∩ i ≥ i i=0 i=0 where OPTi is the weight of an optimal feedback vertex set ofG i with weight functiont i. By decomposing the weight ofF 0, we get

�k �k w(F ) = t (F V ) = t (F ). 0 i 0 ∩ i i i i=0 i=0

By Lemma 6.7,F is a minimal feedback vertex set inG . Since for 0 i i i ≤ ≤ k 1,t i is a cyclomatic weight function, by Lemma 6.5,t i(Fi) 2OPT i; recall− thatF = . Therefore, ≤ k ∅ �k w(F ) 2 OPT 2 OPT. 0 ≤ i ≤ · i=0 ✷

Example 6.10 A tight example for the algorithm is given by the graph obtained by removing a perfect matching from a complete bipartite graph and duplicating every edge. (Note that the algorithm works for parallel edges as well. If a tight example without parallel edges is desired, then a vertex with very high weight can be placed on every edge.) s s €◗€ ✏✏✑ ❙ ◗€€ ✏✏✑✓ ...... €✏ ...... ✓ . . ❙ ◗✏ €✑ . . ✏ € . . ✏ ◗ ✑ ✓€ . . s✏ ❙ €s . . € ◗✑ ✏ . . € ✓ ✏ . . ❅ €❙✑ ◗✏ . . € ✏ . . ✑ €✏ ✓◗ . . ❅ ❙✏ € . . ✑✏ €◗ . . ✏ ✓ € . . s✑✏ ❅ ◗€s . . ❙ . . ◗ ✓ ✑ . . ❅ ❙ ✑ . . ◗ . . ✓ ✑ . . ◗ ❅ ❙ . . ✑ . . . ✓ ◗ . . . ✑❅❙ . . . ◗ . . . . ✓ ✑ . . . ◗❅❙ . . ✑ . . ✓ ◗ . . ✑ ❅❙ . . ◗ . . s ✓ ❅◗❙✑ s ...... 60 6 Feedback Vertex Set

Assuming that the graph is cyclomatic weighted, each vertex receives the same weight. The decomposition obtained by the algorithm consists of only one nontrivial graph,G itself, on which the algorithm computes a minimal feedback vertex set. A possible output of the algorithm is the set shown above; this set contains 2n 2 vertices as compared with the optimum ofn given by one side of the bipartition.− ✷

6.3 Exercises

6.1 A natural greedy algorithm forfinding a minimum feedback vertex set is to repeatedly pick and remove the most cost-effective vertex, i.e., a vertex minimizingw(v)/δ H (v), whereH is the current graph, until there are no more cycles left. Give examples to show that this is not a constant factor algorithm. What is the approximation guarantee of this algorithm?

6.2 Give an approximation factor preserving reduction from the problem to the feedback vertex set problem (thereby showing that improving the factor for the latter problem will also improve it for the former; also see Section 30.1).

6.4 Notes

Algorithm 6.8 is due to Bafna, Berman, and Fujito [19] (see also Becker and Geiger [23] and Chudak, Goemans, Hochbaum, and Williamson [46] for other factor 2 algorithms for the feedback vertex set problem).