Approximation Algorithms (vertex cover)

Approximation Algorithms (vertex cover)
Arash Rafiey
March 24, 2015
Arash Rafiey
Approximation Algorithms (vertex cover)
Consider a problem that we can not solved in polynomial time.
We may be able to find a solution that is guaranteed to be close to
optimal and it can be found in polynomial time.
Arash Rafiey
Approximation Algorithms (vertex cover)
Consider a problem that we can not solved in polynomial time.
We may be able to find a solution that is guaranteed to be close to
optimal and it can be found in polynomial time.
In other words, we are looking for an approximation algorithm. We
want to design an algorithm that finds a solution for an arbitrary
instance of the problem and the solution is close to optimal (For
example is at most twice the OPT solution ).
Arash Rafiey
Approximation Algorithms (vertex cover)
Consider a problem that we can not solved in polynomial time.
We may be able to find a solution that is guaranteed to be close to
optimal and it can be found in polynomial time.
In other words, we are looking for an approximation algorithm. We
want to design an algorithm that finds a solution for an arbitrary
instance of the problem and the solution is close to optimal (For
example is at most twice the OPT solution ).
There are several techniques in designing approximation algorithms.
Greedy approach is one of them. Linear programming and
rounding are other possible methods.
Arash Rafiey
Approximation Algorithms (vertex cover)
An approximation algorithm for vertex cover
Let G = (V , E ) be a graph.
Consider the following greedy algorithm :
Vertex-Cover(G)
1. Start with empty set M.
2. As long as there exists an edge e = uv outside M add e into M.
3. Return VC = {u ∈ V |uv ∈ M} // all the nodes in M .
Arash Rafiey
Approximation Algorithms (vertex cover)
Analysis
Let OPT be an optimal solution for vertex cover in G .
Arash Rafiey
Approximation Algorithms (vertex cover)
Analysis
Let OPT be an optimal solution for vertex cover in G .
1) It is clear that the optimal solution must pick from each edge in
M at least one end. So for each edge uv in M
at least one of the u, v must be in OPT . Therefore |OPT | ≥ |M|.
Arash Rafiey
Approximation Algorithms (vertex cover)
Analysis
Let OPT be an optimal solution for vertex cover in G .
1) It is clear that the optimal solution must pick from each edge in
M at least one end. So for each edge uv in M
at least one of the u, v must be in OPT . Therefore |OPT | ≥ |M|.
2) We also note that VC is a vertex cover for G . To see that:
consider an edge xy in E . If none of the x, y is in VC then we
should have added xy into M. Therefore VC is a vertex cover.
Arash Rafiey
Approximation Algorithms (vertex cover)
Analysis
Let OPT be an optimal solution for vertex cover in G .
1) It is clear that the optimal solution must pick from each edge in
M at least one end. So for each edge uv in M
at least one of the u, v must be in OPT . Therefore |OPT | ≥ |M|.
2) We also note that VC is a vertex cover for G . To see that:
consider an edge xy in E . If none of the x, y is in VC then we
should have added xy into M. Therefore VC is a vertex cover.
3) Observe that |VC | = 2|M|.
Arash Rafiey
Approximation Algorithms (vertex cover)
Analysis
Let OPT be an optimal solution for vertex cover in G .
1) It is clear that the optimal solution must pick from each edge in
M at least one end. So for each edge uv in M
at least one of the u, v must be in OPT . Therefore |OPT | ≥ |M|.
2) We also note that VC is a vertex cover for G . To see that:
consider an edge xy in E . If none of the x, y is in VC then we
should have added xy into M. Therefore VC is a vertex cover.
3) Observe that |VC | = 2|M|.
(4) Now from (2) and (3) we conclude that VC is a vertex cover
and |VC | ≤ 2|OPT |.
Arash Rafiey
Approximation Algorithms (vertex cover)
Analysis
Let OPT be an optimal solution for vertex cover in G .
1) It is clear that the optimal solution must pick from each edge in
M at least one end. So for each edge uv in M
at least one of the u, v must be in OPT . Therefore |OPT | ≥ |M|.
2) We also note that VC is a vertex cover for G . To see that:
consider an edge xy in E . If none of the x, y is in VC then we
should have added xy into M. Therefore VC is a vertex cover.
3) Observe that |VC | = 2|M|.
(4) Now from (2) and (3) we conclude that VC is a vertex cover
and |VC | ≤ 2|OPT |.
Therefore Vertex-Cover(G) is a 2-approximation algorithm. The
running time is O(|E |).
Arash Rafiey
Approximation Algorithms (vertex cover)
Heuristic algorithm to find exact solution for vertex cover
Suppose we want to find a vertex cover of size k in a given graph
G = (V , E ).
Arash Rafiey
Approximation Algorithms (vertex cover)
Heuristic algorithm to find exact solution for vertex cover
Suppose we want to find a vertex cover of size k in a given graph
G = (V , E ).
One way of finding the optimal is to consider every possible subset
S of size k from V and check whether S is a vertex cover.
Arash Rafiey
Approximation Algorithms (vertex cover)
Heuristic algorithm to find exact solution for vertex cover
Suppose we want to find a vertex cover of size k in a given graph
G = (V , E ).
One way of finding the optimal is to consider every possible subset
S of size k from V and check whether S is a vertex cover.
It takes O kn ∈ O(nk ).
But imagine k = 10 and n = 1024. In this case it takes
102410 = 2100 . Very time consuming!
Arash Rafiey
Approximation Algorithms (vertex cover)
Heuristic algorithm to find exact solution for vertex cover
Suppose we want to find a vertex cover of size k in a given graph
G = (V , E ).
One way of finding the optimal is to consider every possible subset
S of size k from V and check whether S is a vertex cover.
It takes O kn ∈ O(nk ).
But imagine k = 10 and n = 1024. In this case it takes
102410 = 2100 . Very time consuming!
We are going to design an algorithm with running time
O(2k |V (G )|). When k is 10 and n = 1024 we end up with
210 × 210 = 220 . It can be handle by one processor.
Arash Rafiey
Approximation Algorithms (vertex cover)
Vertex-Cover(G,k)
1. if k = 0 and G has an edge return NO solution.
2. Let e = uv in G .
3. Set F = Vertex − Cover (G − v , k − 1),
4.
if ( F exists ) return F ∪ {v }.
5. Set F = Vertex − Cover (G − u, k − 1),
6.
if ( F exists ) return F ∪ {u}.
Arash Rafiey
Approximation Algorithms (vertex cover)
After at most k steps we call Vertex-Cover(G,k) with k = 0 and
the algorithm returns.
Therefore we are searching in a binary tree (number of recursion
calls) with depth at most k.
Each step of the algorithm we spend some time to provide a new
instance O(|V (G )|).
The number of leaves in a search tree is 2k (binary of depth k).
Therefore the running time is O(2k |V (G )|)
Arash Rafiey
Approximation Algorithms (vertex cover)