Professional Documents
Culture Documents
vertex-cover problem
traveling-salesman problem
set-covering problem
Approximation Algorithms
Many problems of practical significance are NP-
complete, yet they are too important to abandon
merely because we don’t know how to find an
optimal solution in polynomial time.
There are at least three ways to get around NP-
completeness.
First, if the actual inputs are small, an algorithm
with exponential running time may be perfectly
satisfactory.
Second, we may be able to isolate important special
cases that we can solve in polynomial time.
Approximation Algorithms
Approx-Vertex-Cover
Approx-Vertex-Cover(G) (G)
CC:=
:=Ø;
Ø;
E
E:=
:=E[G];
E[G];
while
whileEEØØdo
do
select
selectany
any(u,v)
(u,v)in
inE
Ewhich
whichwas
wasnot
notselected
selectedbefore;
before;
C:=CC
C:= {u,v};
{u,v};
remove
removefrom
fromEEevery
everyedge
edgeincident
incidenton
oneither
eitheruuor
orvv
return
returnCC
Vertex Cover problem
b c d
a e f g
b c d
a e f g
• 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.
APPROX. VERTEX COVER
b c d
a e f g
b c d
a e f g
b c d
a e f g
• The set C, which is the vertex cover produced contains the six
vertices {b; c; d; e; d; g }
APPROX. VERTEX COVER
b c d
a e f g
The optimal vertex cover for this problem contains only three
vertices: b, d, and e.
APPROX. VERTEX COVER
Approximate Vertex Cover algorithm is a 2-approximation algorithm
Approx-
Approx-TSP-Tour(G,c)
TSP-Tour(G,c)
11 select vertexrrv[G]
selectaavertex v[G]to tobe
beaa“root”
“root”vertex;
vertex;
22 call
callMST-Prim(G,c,r)
MST-Prim(G,c,r)to toconstruct
constructMST
MSTwith
withroot
rootr;r;
33 let
letLL==vertices
verticeson
onpreorder
preordertree
treewalk
walkofofMST;
MST;
44 let
letHH==cycle
cyclethat
thatvisits
visitsvertices
verticesin
inthe
theorder
orderL;
L;
return
returnHH
Approx. TSP
a d
b f g
a d
b f g
a d
b f g
a d
b f g
Computed Tour
Approx. TSP
a d
b f g
Optimal Tour
APPROX-TSP-TOUR is a polynomial-time 2-approximation algorithm
for the Traveling-salesman problem with the triangle inequality.
Proof:
Let H* = optimal tour, T = MST. Deleting all but first appearance
Deleting an edge of H* yields a of each vertex yields preorder
spanning tree. walk.
So, c(T) c(H *). Ex: a,b,c,h,d,e,f,g.
Consider full walk W of T. Corres. cycle H = W with some
Ex: a,b,c,b,h,b,a,d,e,f,e,g,e,d,a. edges removed.
Visits each edge twice Ex: a,b,c,h,d,e,f,g,a.
c(W) = 2c(T).
Hence, c(W) 2c(H*). c(H) c(W).
S1
S3 S2
S5
S6
S4
• An instance (X; F) of the set-covering problem, where X consists
of the 12 black points and F={S1; S2; S3; S4; S5; S6}.
Set-covering problem
S1
S3 S2
S5
S6
S4
Set-covering problem
S1
S3 S2
S5
S6
S4
Set-covering problem
S1
S3 S2
S5
S6
S4
Set-covering problem
The greedy algorithm produces a cover of size 4 by selecting either
the sets S1, S4, S5, and S3 or the sets S1, S4, S5, and S6, in order.
S1
S3 S2
S5
S6
S4
S1
Set Cover
S3 S2
S5
S6
S4