Volume 14, Number 5
DEPTH-FIRST
INFORMATION
PROCESSING LETTERS
23 July 1982
SEARCH AND THE VERTEX COVER PROBLEM
Carla SAVAGE Computer Science Department, North Carolina State Unioersity, Raleigh, NC 27650, U.S.A. Received 16 July 1981; revised version received 25 January 1982 Keywords: Vertex cover, depth-first search, approximation
1. Introduction A vertex cover in an undirected graph G = (V, E) is a subset C of V such that every edge of E is incident with at least one vertex in C. A minimum cover of G is a vertex cover of minimum cardinality. Since the problem of finding a minimum cover in a graph is NP-complete [3], it is of interest to devise efficient ways to find an approximate solution. Our main result in this paper is to show that if T is any depth-first search spanning tree of G [6], the nonleaf vertices of T form a vertex cover of G which is guaranteed to be within a factor two of the minimum cover in size. The vertex cover problem is related to the problem of finding a maximum matching i.n a graph. A matching of G = (V, E) is a subset M of E such that no verterr of V is incident with more than one edge of M. A maximum matching is a matching of maximum cardinality. For bipartite graphs, the size of a maximum matching is equal to the size of a minimum cover [l]. Equality does not always hold for a general graph. However, it is easy to show that the size of a minimum cover is bounded below by thle size of a maximum matching and above by twice the size of a maximum matching. It has been shown by Hopcroft and Karp [4] that a maximum matching in a bipartite graph G = (V,E) can be found in time O((m+ n)fi) where m = j/El and n = ]Vl. From this matching a minimum cover can be found within the same time bound. Although the vertex cover problem is NPcomplete for general graphs [3], a maximum 0020-019OJ82/0000-0000/$02.75
algorithms, graph algorithms, combinatorial
algorithms
matching in a general graph can be found in polynomial time [ 21. In this paper, we use the idea of a proper mdching in a tree, introduced in [5], to exhibit some relationships between a minimum cover in G and a depth-first search (dfs) spanning tree of G. Results on proper matching;s are reviewed in Section 2. If G is a tree, the ‘algorithm of Iiopcroft and Karp can be used to fi,qd a vertex cover in time 0(nla5). We note in Section 3 that a proper ‘matching can be used to find a vertex cover in a tree in time O(n). In Section 4 we prove the main result, that if T is a dfs sparming tree of G, the nonleaf vertices of T form a vertex cover for G no worse than twice the minimum cover in size. If T were an arbitrary spanning tree of G, the nonleaf vertices of T would not necessarily even be a vertex cover for G. As a corollary it is shown that if T is any dfs spanning tree of G, a minimum cover for T is at least half the size of a minimum cover for G. Whereas, if T were an arbitrary spanning tree of G, the ratio of the size of a minimum cover for G to the size of a minimum cover for T could be as large as O(n). Finally, in Section 5, we exhibit some tradeoffs that arise in this approximation technique which may be of use in obtaining a better vertex cover approximation.
0 1982 North-Holland
2. Maximum matchings and trees All trees in this paper are considered to be rooted. A rooted tree T = (V, E, r) is a tree with a 233
Volume 14, Number 5
23 July 1982
INFORMATION PROCESSING LETTERS
vertex r of V distinguished as the root. For v E V, let d(v) denote the distance from v io r. If w E V and (w, v) E E and d(w) = d(v) + 1, then v is the father of w and w is the son of v. Every vertex W, distinct from r, has a father, denoted by f(w). Vertices w, and w2 are brothers if there is a vertex v with v = f(w,) = f(w2). Let T = (V, E, r) be a tree rooted at r. If M is a matching in, T, a vertex v is called free with respect to M if v is not incident with any edge of M. Define a proper matching of T to be a matching M c E which satisfies the following property: If a vertex w # r of T is free with respect to M, then for some brother u of w in T the edge (u, f(w)) is in M. It was shown in [S] that if M is a proper matching in T, then M must be a maximum matching of T. An algorithm was presented which will find, in any rooted tree T, a proper matching in T in time O(n). The main result of [5] is the following. Tbsorem 1. If T is a dfs spanning tree of G and M(T) and M(G) are maximum matchings in T and G, respectively, then ]M(G)]/]M(T)] G 2.
3. Vertex covers and trees
A vertex cover in T, theq can be found in time O(n) by computing a proper matching in T.
4. Vertex cover approximation We now prove the main result. Theorem 3. Let T be a dfs spanning tree of G with NL(T) the set of nonleaves of T and let C(G) be a minimum cover for G. Then NL(T) is a vertex cover for G with ]NL(T)]/]C(G)] e 2. Proof. Let L(T) be the set of leaves of T. Since T is a dfs spanning tree, no edge of G can join two vertices of L(T), so NL(T) is a vertex cover for G. For a vertex v of T, let sons(v) denote the number of sons of v in T. Then,
IWI
=
2
(sons(v) - 1) + 1.
vENL(T)
Let M(T) be a proper (and therefore maximum) maching in T and let X be the set of vertices in T which are free with respect to M(T). If a vertex w in X is not the root of T, then the father of w, v, is a nonleaf vertex which is matched in M(T) with a brother of w. Thus, sons(v) a 2. Since at most one vertex of X may be the root of T, we have IL(T)] a (IX] - 1) + 1 = 1x1.
Let M be a proper matching in the tree T = (V, E, r) and let S be the set of ‘sons’ in the edges of M and F the set of ‘fathers’, that is,
Since IX] .= n - 2]M(t)] and (L(T)] = n - (NL(T)], we have ]NL(T)] < 2]M(T)]. In summary,
S-l (wEV](w,f(w))EM),
and thus ]NL(T)]/]C(G)]
]M(T)] s ]M(G)] G ]C(G)] < INL(T)I G 2]M(T> G 2.
F= (fjw)lwES}. Any vertex not in S or F is free with respect to M. Theorem 2. The set F is a minimum cover for T. Proof. Since iF] = IM], if F is a vertex cover for T, it must be miriimum. To show that F is a vertex cover, let e = (w, v) be an edge of T with f(w) = V. If w is free, v must be in F, since M is proper. If w E S, then v E F by definition of S and F. Thus either w or v must be in F. 234
It can be seen that this bound is tight bY considering the case in which G is a path of (0 dd length and the depth-first search is done from a vertex of degree 1. Note that the string of inequalities IM(T)I 6 (M(G)1 g
IW)l sG IWT)l fGW(T)I
shows that /M(G)]/(M(T)] e 2. This provides a proof of Theorem 1 which is much simpler than the proof appearing in [S]. If T is a dfs spanning tree of G, Theorem 3 can
Volume 14, Number 5
INFORMATION
PROCESSING
be used to relate the size of a minimum cover of T to a minimum cover of G. Corollary 4. If C(G) is a vertex cover of G and T a dfs spanning tree of G with vertex cover C(T), then ICCG)l/lW)l g 2. Proof. Let M(T) be a maximum matching in T and NL(T) the set of nonleaves of T. From the proof of Theorem 3 we have that
IC(T)l G IC(G)l G INL(T)J 6 2(M(T)] = 2)C(T)I. The result follows.
LETTERS
23 July 1982
scheme, more suited to graphs with IM(G)I/JM(T)I < 2/k. c;ln be used to obtain a vertex cover for G within a factor k of the minimum. It should be mentioned here that Gavril has noted another technique for approximating a vertex cover [3]. A maximal matching in G is a matching N with the property that no edge in G joins two vertices which are free with respect to N. The set E(N) of endpoints of edges in N forms a vertex cover for G and the following inequalities will hold: INI Q IM(G)I Q ICWI QlW)I
= 2lNI.
Thus, JE(N)I/IC(G)I d 2. In fact, Note that this bound is tight. If G = K n for n odd, then IC(G)l = n - 1. A dfs spanning tree T for G would be a path of length n - 1 with IC(T)I = i(n - 1).
5. Tradeoffs
If T is a dfs spanning tree of G and C(T), C(G), M(T), M(G) and NL(T) are defined as in the preceding sections, we have the following stnng of inequalities:
We have already noted that IM(G)I/IM\T)I s 2 and INL(T)I//C(G)l s 2 and we must have IC(G)I/IM(G)IS 2. But, in fact, we have the stronger result that the product of any two of these three ratios must be less than or equal to 2. In fact,
IEW -*-*-= IW)l
lW)l IMW
IMW IN/
2 l
So it also occurs in this approximation technique that if E(N) is a relatively bad approximation to C(G), then IC(G)I/IM(G)I is relatively small. Acknowledgement
The author wishes to thank the referees for their helpful comments and in particular for pointing out that the proof of Theorem 3 provides a simple proof of [S, Theorem 1).
References [I] J.A. Bondy and U.S.R. Murty, Graph Theory with Applications (North-Holland, New York).
This shows, for example, that if NL(T) is a relatively bad approximation to C(G), then M(T) is a relatively good approximation to M(G). Also, the ratio IC(G)I/!M(G)I must then be relatively small, a property of G which is independent of the choice of T among dfs spanning trees. It may be possible to show for some k, 1 < k < 2, that if INLtT)I/IC(G)I ’ k, another approximation
[2] S. Even and 0. Kariv, An 0(n2.s) algorithm for maximum matching in general graphs, Proc. 16th Annual ;EEE Symp. on Foundations of Computer science ( 1975) i 13 - I 12. [3) M.R. Garey and D.S. Johnson, Computers and Intra~tahility (Freeman, San Francisco). [4] J.E. Hopcroft and R.M. Karp, An n’, - el maximum matching in bipartite graphs, SIAM J. Comput 2 (1973) 225-231. (51 C. Savage, Maximum matchings and trees Inform. Prarccr~~ Lett. IO (4/S) (1980) 202-205. [6] R.E. I arjan, Depth-first search and linear graph ~l~~~r~t~rn~. SIAM J. Comput. I (1972) l46- 160.