Design and Analysis of Algorithms

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 15

Design and Analysis of

Algorithms
6.046

Lecture 18
Approximation Algorithms II
Prof. Piotr Indyk
Approximation algorithms

• In the previous episode:


– Vertex cover (twice: greedy and linear
programming)
– Set Cover
• Today:
– Traveling Salesperson Problem
Approximation Algorithms

• An algorithm A for a minimization problem is r-


approximate, if, on any input of size n:
– The cost CA of the solution produced by the
algorithm, and
– The cost COPT of the optimal solution
are such that CA ≤ r COPT
• For maximization problems, replace by
CA ≥ 1/r COPT
TSP

• Metric Traveling Salesperson


Problem (TSP)
– Input:
• a set P of n points,
• a distance function d(p,q)
– The function d(p,q) is non-
negative, symmetric
and satisfies the triangle
inequality:
d(pi,pj) ≤ d(pi,pk) + d(pk,pj)
– Output: shortest cycle that visits
each vertex exactly once
2-approximation for TSP

• Compute MST T
– An edge between any pair of points
– Weight = distance between endpoints
• Compute a tree-walk W of T
– Each edge visited twice
• Convert W into a cycle C using
shortcuts
2-approximation: Proof
• Notation:
– COPT = optimal cycle
– T = MST
– W = tree walk of T
• Observe that:
– Cost(T) ≤ Cost(COPT )
• Removing an edge from COPT gives a spanning tree; T is a
spanning tree of minimum cost
– Cost(W) = 2 Cost(T)
• Each edge visited twice
– Cost(C) ≤ Cost(W)
• Triangle inequality
Þ Cost(C) ≤ 2 Cost(COPT )
Better approximation?

• The bottleneck: converting tree T into the


walk W
– Induces a factor of 2
• Can we do better ?
• Yes! (Christofides’76; Serdyukov’76)
• Main idea: convert tree T into a walk W in a
better way
• Note: we will use certain facts in a black-
box manner
Creating better walk

• Eulerian tour of a graph: a tour that visits


each edge exactly once
• Theorem: A graph G has an Euler Tour if
and only if every vertex has even degree
• Proof: 6.042
The algorithm

• Compute MST T
• Let O be the set of odd
degrees in T
• Compute min-cost
matching M of vertices in O
– O has even size, details next slide
• Compute the Euler tour W
of T+ M
• Convert W into a cycle C
using shortcuts, as before
Matching
• Claim: The size of O is even
• Proof:
– The sum of vertex degrees in any graph
is even (hand-shaking lemma)
– If |O| was odd, then the sum of the
degrees in T would be odd –
contradiction
• Thus, vertices in O can be matched
• Minimum matching can be found in
polynomial time (Edmonds’65)
Approximation factor
• Notation:
– COPT = optimal cycle
– T = MST
– O = odd vertices in T
– M = min cost matching of O
– W = Euler tour of T+M
• Claim: Cost(M) ≤ Cost(COPT )/2
• Proof:
– Let Codd be the min cost tour on the odd vertices O
only. We have cost(Codd) ≤ cost(COPT)
– Odd edges on Codd form a matching and even edges
on Codd form a matching
– One of them has cost ≤ Cost(COPT )/2
• Thus Cost(W) ≤ Cost(T)+Cost(M)
≤ 3/2 Cost(COPT )
• Shortcutting can only decrease the cost
Maximum Cardinality
Matching

• Given a graph G=(V,E), find matching M in


G of maximum size
• In Lecture 10, we have seen an algorithm
for maximum cardinality matching in
bipartite graphs via reduction to maximum
flow
– Finds optimal solution, but slow-ish:
O(VE) time
• Can we approximate faster ?
2-Approximation algorithm

• Find maximal matching Mmax in G (as in


previous lecture)
• Show that |Mmax| ≥ |MOPT|/2
Maximal matching algorithm

On input G=(V,E)
• Set E ’ = E
• Set M=f
• While E ’ ¹ f (some edges not covered yet)
– Pick any edge (u,v) of E’
– Add (u,v) to M
– Remove from E’ every edge incident to either u or v
• Return M

Total runtime: O(E)


2-approximation

• Claim: |Mmax| ≥ |MOPT|/2


• Proof:
– Each edge added to Mmax “blocks” at
most two edges in MOPT
– The maximal matching algorithm will run
for at least |MOPT|/2 iterations

You might also like