Approx-Vertex-Cover (G = (V, E))
{
C = empty-set;
E'= E;
While E' is not empty do
{
Let (u, v) be any edge in E’
Add u and v to C;
Remove from E' all edges incident to u or v
}
Return C
}
The idea is to take an edge (u, v) one by one, put both vertices to C, and remove all the edges incident to u or v. We carry on until all edges have been removed. C is a VC.
Example
Step-1
The edge (b,c), shown heavy, is the first edge chosen by APPROX-VERTEX-COVER. Vertices b and c, shown lightly shaded, are added to the set C containing the vertex cover being created. Edges (a, b), (c, e), and (c,d), shown dashed, are removed since they are now covered by some vertex in C.
Step-2
Step-3
Edge (e, f) is added to A. Edge (d,g) is added to C.
Step-4
The set C, which is the vertex cover produced by APPROX-VERTEX-COVER, contains the
six vertices b, c, d, e, f, g. Approximate vertex cover. C=6
Optimal Vertex Cover
Running Time
The running time of this algorithm is O(V+E), using the adjacency list to represent E`. The algorithm has O(|E|) iterations of the loop, across all loop iterations, O(|V|) vertices are added to C. Therefore it is O(E + V), so is polynomial.
Approx-Vertex-Cover (G = (V, E))
{
C = empty-set;
E'= E;
While E' is not empty do ----------------- > O (E)
{
Let (u, v) be any edge in E’
Add u and v to C; -------------------- -----> O (V)
Remove from E' all edges incident to u or v
}
Return C
}
O ( E + V )
§Goal: Since this a minimization problem, we are interested in the smallest possible C/C*. Specifically we want to show C/C* ≤ 2 = p(n).
In other words, we want to show that APPROX-VERTEX-COVER algorithm returns a vertex-cover that is at most twice the size of an optimal cover.
| C* | ≥ A ----------------------------- (1)
| C* | ≥ A
|C| = 2|A|------------------------- (2)
Therefore: |C| = 2|A| <= 2|C*|
|c|/|c*| ≤ 2 = p(n)
[Because we have added both vertices, we get c = 2|A| but OPTIMAL-VERTEX-COVER would have added one of two. c/c* ≤ p(n) = 2.]
No comments:
Post a Comment