Given an undirected graph G=⟨V,E⟩ in which each vertex i is associated with a weight wi, the vertex cover problem asks for the subset of vertices with minimum weight, such that every edge in G is incident to at least one vertex in the set.
The problem can be formulate as integer program then relaxed as linear program. Let n and m be the number of vertices and edges respectively. For every vertex i∈[n], there is a indicator variable xi∈[0,1]. The linear program is given as
Now we show how to use this condition to construct an approximate primal solution. We begin with an initial values of x=(0,0,...,0) and y=(0,0,...,0). Note that y is a dual feasible solution and condition (2) holds. However x is not a primal feasible solution. In the following we give an algorithm that maintains the feasibility of y and condition (2) while restores the feasibility of x.
Algorithm 1 -- an 2 approximation algorithm
while ∃(i,j)∈E,s.t.,xi+xj<1 increase yi,j as much as possible until either
1.∑(i,k)∈Eyi,k=wi, then set xi=1 2.∑(j,k)∈Eyj,k=wj, then set xj=1
Note that in the inner loop, if two conditions hold simultaneously, we need only set one of xi and xj to 1.
Now we analyze the algorithm. It is apparent that ∑(i,j)∈Eyi,j≤wi∀i∈[i] holds throughout the algorithm. Moreover, for i∈[i], xi=0 or xi=1. In the latter case, we must have ∑(i,k)∈Eyi,k=wi. We conclude that when the algorithm terminates,