1. Approximation
Algorithms
presented by
Nicolas Bettenburg
1
2. Many problems with practical signiïŹcance
are NP-complete.
Unlikely to ïŹnd a polynomial-time
solution algorithm (nobody knows).
2
3. Work around NP
completeness
âą Small Inputs: stay with exponential
algorithm!
âą Often special cases are solvable in
polynomial time.
âą Find a near-optimal solution in
polynomial time that is good enough.
3
4. Approximation Algorithms
âą For a lot of practical applications near-optimal
solutions are perfectly acceptable.
âą Algorithms that return near-optimal solutions for a
problem are called approximation algorithms.
âą Want to study polynomial time approximation
algorithms for NP-complete problems.
4
5. What is ââgood enoughââ?
For an approximation algorithm A
of input of size n
the cost of solution produced by A is C
Approximation Ratio of A is p(n)
C Câ
max ,
â C
†p(n)
C
5
7. List of 21 Problems
that are NP-complete
Richard Karp, 1972
.
.
.
âą CLIQUE
âą SET PACKING
âą VERTEX COVER
âą SET COVERING
âą FEEDBACK NODE SET
âą FEEDBACK ARC SET
âą KNAPSACK
âą PARTITION
âą MAX-CUT
.
.
.
7
9. Vertex Cover
a subset U of all vertices V, such
that every edge in E is covered.
b c d
a e f g
Covered Edge
an edge e = (vi, vj) is covered if ei or ej is chosen.
9
10. Minimum Vertex Cover
Problem
Input: a Graph G = (V, E)
Output: the smallest subset U â V
such that âe = (vi , vj ) â E, i = j
vi â U or vj â U
10
15. Greedy-Vertex-Cover(G)
1 C = {}
2 do chose v in V with max deg
3 C = C + {v}
4 remove v and every edge
5 adjacent to v
6 until all edges covered
7 return C
15
21. b c d
a e f g
Goodness of solution depends
on the (random) choices made.
21
22. Approx-Vertex-Cover(G)
1 C = {}
2 Eâ = E[G]
3 while Eâ != {}
4 do let (u,v) be some e in Eâ
5 C = C + {u, v}
6 remove from Eâ every edge
7 incident to either u or v
8 end do
9 end while
10 return C
22
23. Approx-Vertex-Cover(G)
1 C = {}
2 Eâ = E[G]
3 while Eâ != {}
4 do let (u,v) be some e in Eâ
5 C = C + {u, v}
6 remove from Eâ every edge
7 incident to either u or v
8 end do
9 end while
10 return C O(|V | + |E|)
23
24. b c d
a e f g
C = {}
E = {(a-b), (b-c), (c-e), (c-d),(e-f),(e-d), (f-d), (d-g)}
24
25. b c d
a e f g
C = {}
E = {(a-b), (b-c), (c-e), (c-d),(e-f),(e-d), (f-d), (d-g)}
25
26. b c d
a e f g
C = {b, c}
E = {(e-f),(e-d), (f-d), (d-g)}
26
27. b c d
a e f g
C = {b, c}
E = {(e-f),(e-d), (f-d), (d-g)}
27
30. b c d
a e f g
C = {b, c, e, f, d, g}
E = {}
30
31. C = {b, c, e, f, d, g}
|C| = 6 = 2 · 3 †2 · |C â |
the algorithm found a 2-approximation.
b c d
a e f g
31
32. Approx-Vertex-Cover(G)
1 C = {}
2 Eâ = E[G]
3 while Eâ != {}
4 do let (u,v) be some e in Eâ
5 C = C + {u, v}
6 remove from Eâ every edge
7 incident to either u or v
8 end do
9 end while
10 return C
C is a vertex cover of G
Proof:
The algorithm loops until every edge in Eâ = E[G] has been
covered (removed) by some vertex in C.
32
33. Approx-Vertex-Cover(G)
1 C = {}
2 Eâ = E[G]
3 while Eâ != {}
4 do let (u,v) be some e in Eâ
5 C = C + {u, v}
6 remove from Eâ every edge
7 incident to either u or v
8 end do
9 end while
10 return C
C is at most 2 times C*
Proof:
Let A be the set of edges picked by algorithm step 4. C*
must include at least one endpoint of each edge in set A. No
two edges share an endpoint, since all adjacent edges are
deleted after picking in line 6. Thus no two edges in A are
covered by the same vertex in C*.
|C â | â„ |A|
33
34. Approx-Vertex-Cover(G)
1 C = {}
2 Eâ = E[G]
3 while Eâ != {}
4 do let (u,v) be some e in Eâ
5 C = C + {u, v}
6 remove from Eâ every edge
7 incident to either u or v
8 end do
9 end while
10 return C
C is at most 2 times C*
Proof:
Each execution of line 4 picks an edge for which neither of
the endpoints are in C already.
|C| = 2 · |A|
|C â | â„ |A|
34
46. The Set Cover Problem
Input: a ïŹnite Set X
Output: a family F of subsets of X,
such that every element of X
belongs to at least one subset in F: X = âȘSâF S
46
47. Set X
S1
S4 S2
S6
S3 S5
Subsets S1, S2, S3, S4, S5, S6
47
48. Set X
S1
S4 S2
S6
S3 S5
Minimum-Size Cover: S3, S4, S5
48