Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

Volume 14, Number 5 INFORMATION PROCESSING LETTERS 23 July 1982

DEPTH-FIRST 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 algorithms, graph algorithms, combinatorial algorithms

1. Introduction matching in a general graph can be found in


polynomial time [ 21.
A vertex cover in an undirected graph G = In this paper, we use the idea of a proper
(V, E) is a subset C of V such that every edge of E mdching in a tree, introduced in [5], to exhibit
is incident with at least one vertex in C. A mini- some relationships between a minimum cover in G
mum cover of G is a vertex cover of minimum and a depth-first search (dfs) spanning tree of G.
cardinality. Since the problem of finding a mini- Results on proper matching;s are reviewed in Sec-
mum cover in a graph is NP-complete [3], it is of tion 2. If G is a tree, the ‘algorithm of Iiopcroft
interest to devise efficient ways to find an ap- and Karp can be used to fi,qd a vertex cover in
proximate solution. Our main result in this paper time 0(nla5). We note in Section 3 that a proper
is to show that if T is any depth-first search ‘matching can be used to find a vertex cover in a
spanning tree of G [6], the nonleaf vertices of T tree in time O(n). In Section 4 we prove the main
form a vertex cover of G which is guaranteed to be result, that if T is a dfs sparming tree of G, the
within a factor two of the minimum cover in size. nonleaf vertices of T form a vertex cover for G no
The vertex cover problem is related to the prob- worse than twice the minimum cover in size. If T
lem of finding a maximum matching i.n a graph. A were an arbitrary spanning tree of G, the nonleaf
matching of G = (V, E) is a subset M of E such vertices of T would not necessarily even be a
that no verterr of V is incident with more than one vertex cover for G. As a corollary it is shown that
edge of M. A maximum matching is a matching of if T is any dfs spanning tree of G, a minimum
maximum cardinality. For bipartite graphs, the cover for T is at least half the size of a minimum
size of a maximum matching is equal to the size of cover for G. Whereas, if T were an arbitrary
a minimum cover [l]. Equality does not always spanning tree of G, the ratio of the size of a
hold for a general graph. However, it is easy to minimum cover for G to the size of a minimum
show that the size of a minimum cover is bounded cover for T could be as large as O(n). Finally, in
below by thle size of a maximum matching and Section 5, we exhibit some tradeoffs that arise in
above by twice the size of a maximum matching. this approximation technique which may be of use
It has been shown by Hopcroft and Karp [4] in obtaining a better vertex cover approximation.
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 2. Maximum matchings and trees
minimum cover can be found within the same time
bound. Although the vertex cover problem is NP- All trees in this paper are considered to be
complete for general graphs [3], a maximum rooted. A rooted tree T = (V, E, r) is a tree with a

0020-019OJ82/0000-0000/$02.75 0 1982 North-Holland 233


Volume 14, Number 5 INFORMATION PROCESSING LETTERS 23 July 1982

vertex r of V distinguished as the root. For v E V, A vertex cover in T, theq can be found in time
let d(v) denote the distance from v io r. If w E V O(n) by computing a proper matching in T.
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).
4. Vertex cover approximation
Vertices w, and w2 are brothers if there is a vertex
v with v = f(w,) = f(w2). We now prove the main result.
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
Theorem 3. Let T be a dfs spanning tree of G with
to M if v is not incident with any edge of M.
NL(T) the set of nonleaves of T and let C(G) be a
Define a proper matching of T to be a matching
minimum cover for G. Then NL(T) is a vertex cover
M c E which satisfies the following property:
for G with ]NL(T)]/]C(G)] e 2.

If a vertex w # r of T is free with respect to


Proof. Let L(T) be the set of leaves of T. Since T is
M, then for some brother u of w in T the
a dfs spanning tree, no edge of G can join two
edge (u, f(w)) is in M.
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
It was shown in [S] that if M is a proper matching of sons of v in T. Then,
in T, then M must be a maximum matching of T.
An algorithm was presented which will find, in IWI = 2 (sons(v) - 1) + 1.
any rooted tree T, a proper matching in T in time vENL(T)

O(n). The main result of [5] is the following.


Let M(T) be a proper (and therefore maximum)
maching in T and let X be the set of vertices in T
Tbsorem 1. If T is a dfs spanning tree of G and which are free with respect to M(T). If a vertex w
M(T) and M(G) are maximum matchings in T and in X is not the root of T, then the father of w, v, is
G, respectively, then ]M(G)]/]M(T)] G 2. 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
3. Vertex covers and trees IL(T)] a (IX] - 1) + 1 = 1x1.

Let M be a proper matching in the tree T = Since IX] .= n - 2]M(t)] and (L(T)] = n - (NL(T)],
(V, E, r) and let S be the set of ‘sons’ in the edges we have ]NL(T)] < 2]M(T)]. In summary,
of M and F the set of ‘fathers’, that is,
]M(T)] s ]M(G)] G ]C(G)] < INL(T)I G 2]M(T>
S-l (wEV](w,f(w))EM), and thus ]NL(T)]/]C(G)] G 2.
F= (fjw)lwES}.
It can be seen that this bound is tight bY
Any vertex not in S or F is free with respect to M. considering the case in which G is a path of (0 dd
length and the depth-first search is done from a
Theorem 2. The set F is a minimum cover for T. vertex of degree 1.
Note that the string of inequalities
Proof. Since iF] = IM], if F is a vertex cover for T,
it must be miriimum. To show that F is a vertex IM(T)I 6 (M(G)1 g IW)l sG
IWT)l fGW(T)I
cover, let e = (w, v) be an edge of T with f(w) = V. shows that /M(G)]/(M(T)] e 2. This provides a
If w is free, v must be in F, since M is proper. If proof of Theorem 1 which is much simpler than
w E S, then v E F by definition of S and F. Thus the proof appearing in [S].
either w or v must be in F. If T is a dfs spanning tree of G, Theorem 3 can

234
Volume 14, Number 5 INFORMATION PROCESSING LETTERS 23 July 1982

be used to relate the size of a minimum cover of T scheme, more suited to graphs with IM(G)I/JM(T)I
to a minimum cover of G. < 2/k. c;ln be used to obtain a vertex cover for G
within a factor k of the minimum.
Corollary 4. If C(G) is a vertex cover of G and T a It should be mentioned here that Gavril has
dfs spanning tree of G with vertex cover C(T), then noted another technique for approximating a vertex
ICCG)l/lW)l g 2. cover [3]. A maximal matching in G is a matching
N with the property that no edge in G joins two
Proof. Let M(T) be a maximum matching in T and vertices which are free with respect to N. The set
NL(T) the set of nonleaves of T. From the proof E(N) of endpoints of edges in N forms a vertex
of Theorem 3 we have that cover for G and the following inequalities will
hold:
IC(T)l G IC(G)l G INL(T)J 6 2(M(T)] = 2)C(T)I.
The result follows. 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 IEW
-*-*-= lW)l IMW 2
for G would be a path of length n - 1 with IC(T)I = IW)l IMW IN/ l

i(n - 1).
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.
5. Tradeoffs

If T is a dfs spanning tree of G and C(T), C(G), Acknowledgement


M(T), M(G) and NL(T) are defined as in the
preceding sections, we have the following stnng of The author wishes to thank the referees for
inequalities: their helpful comments and in particular for point-
ing out that the proof of Theorem 3 provides a
simple proof of [S, Theorem 1).
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 References
three ratios must be less than or equal to 2. In fact,
[I] J.A. Bondy and U.S.R. Murty, Graph Theory with Applica-
tions (North-Holland, New York).
[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.
This shows, for example, that if NL(T) is a rela- [3) M.R. Garey and D.S. Johnson, Computers and Intra~tahil-
tively bad approximation to C(G), then M(T) is a ity (Freeman, San Francisco).
relatively good approximation to M(G). Also, the [4] J.E. Hopcroft and R.M. Karp, An n’, - el

ratio IC(G)I/!M(G)I must then be relatively small, maximum matching in bipartite graphs, SIAM J. Comput 2
(1973) 225-231.
a property of G which is independent of the choice
(51 C. Savage, Maximum matchings and trees Inform. Prarccr~~
of T among dfs spanning trees. It may be possible Lett. IO (4/S) (1980) 202-205.
to show for some k, 1 < k < 2, that if [6] R.E. I arjan, Depth-first search and linear graph ~l~~~r~t~rn~.
INLtT)I/IC(G)I ’ k, another approximation SIAM J. Comput. I (1972) l46- 160.

You might also like