Approximation Algorithms: Vertex Cover, TSP, and Set Cover
Anchor (Master): Cormen, Leiserson, Rivest and Stein 2022 Introduction to Algorithms 4e (MIT Press) Ch. 35; Vazirani 2001 Approximation Algorithms (Springer) Ch. 1-2, 15 (tight analysis of greedy Set Cover, LP rounding, primal-dual methods)
Intuition Beginner
When a problem is NP-hard, we cannot find the exact optimal solution efficiently. But we can often find a solution that is provably close to optimal. An approximation algorithm runs in polynomial time and guarantees its output is within a known factor of the best possible answer.
Think of packing a suitcase. Finding the absolute optimal arrangement is hard. But you can guarantee fitting at least half of what the optimal arrangement would hold, using a simple strategy: just keep adding the largest item that fits. This is not perfect, but it is good, and you can prove exactly how good.
Three classic problems illustrate the range of what approximation can achieve. Vertex Cover has a simple 2-approximation: repeatedly pick an edge, add both its endpoints to the cover, and remove all edges touching them. Metric TSP has a 3/2-approximation via Christofides' clever construction combining a minimum spanning tree with a perfect matching. Set Cover has a logarithmic approximation via the greedy strategy. Each algorithm is simple, but proving its guarantee requires careful comparison against an unknown optimum.
Visual Beginner
Vertex Cover 2-approximation on a path graph:
(a)---(b)---(c)---(d)---(e)
Step 1: Pick edge (b,c), add {b,c} to cover, remove all edges touching b or c
Remaining: (a) (d)---(e)
Step 2: Pick edge (d,e), add {d,e} to cover, remove all edges touching d or e
Remaining: (a)
Cover = {b, c, d, e} — size 4
OPT = {b, d} — size 2
Ratio: 4/2 = 2 (matches the guarantee)| Problem | Approximation ratio | Technique | Hardness threshold |
|---|---|---|---|
| Vertex Cover | 2 | Maximal matching | 1.36 (or 2 - eps under UGC) |
| Metric TSP | 3/2 | Christofides (MST + matching) | 123/122 (recent) |
| General TSP | None (no constant factor) | — | Unapproximable |
| Set Cover | ln n | Greedy (most uncovered first) | (1 - eps) ln n |
Worked example Beginner
We run the 2-approximation for Vertex Cover on a small graph. The graph has 4 vertices and edges (a path).
Step 1. Pick the first edge . Add both endpoints: cover . Remove edges and (both touch vertex 1 or 2). Remaining edges: .
Step 2. Pick edge . Add both endpoints: cover . No edges remain.
The algorithm returns a vertex cover of size 4. The optimal cover is of size 2 (vertices 2 and 3 touch every edge). The ratio is , matching the guarantee exactly.
For a better result, note that we could have just picked edges greedily and kept only one endpoint per edge—but that loses the guarantee. The 2-approximation is simple and provably correct because every edge in the matching must have at least one endpoint in any cover, and we pick both.
Check your understanding Beginner
Formal definition Intermediate+
Definition (approximation algorithm). Let be an NP-optimisation problem with objective function . A polynomial-time algorithm is an -approximation for (minimisation) if for every instance , . For maximisation, .
Definition (Vertex Cover). Given an undirected graph , find a minimum subset such that for every edge , .
Definition (Metric TSP). Given a complete graph with edge weights satisfying the triangle inequality ( for all ), find a Hamiltonian cycle of minimum total weight.
Definition (Set Cover). Given a universe and a collection of subsets of with , find the smallest sub-collection with .
Counterexamples to common slips
"An approximation algorithm with ratio 2 always finds a solution of size exactly twice the optimum." The ratio is an upper bound. The algorithm can do better on specific instances.
"General TSP can be approximated within some constant factor." Without the triangle inequality, TSP cannot be approximated within any polynomial-time computable function unless P = NP, by reduction from Hamiltonian cycle.
"The greedy Set Cover algorithm is optimal among all polynomial-time algorithms." It achieves ratio , and no polynomial-time algorithm does better than unless P = NP (Dinur-Steurer 2014). So it is essentially optimal, but the match is up to the factor.
Key theorem with proof Intermediate+
Theorem (2-approximation for Vertex Cover). The maximal-matching algorithm for Vertex Cover returns a cover of size at most .
Proof. The algorithm repeatedly picks an arbitrary uncovered edge , adds both and to the cover , and removes all edges incident to or . It terminates when no edges remain.
Correctness. Every edge is either picked (and both endpoints are in ) or removed because one of its endpoints was picked with another edge. So every edge has at least one endpoint in .
Approximation ratio. Let be the set of edges picked by the algorithm. These edges form a matching (no two share a vertex) because after picking an edge, we remove all incident edges. So .
Every edge in must have at least one endpoint in any vertex cover (even the optimal one), and since the edges in are disjoint (no shared vertices), each requires a distinct vertex in the cover. Therefore , which gives .
Bridge. The maximal-matching algorithm is the foundational reason Vertex Cover is approximable within factor 2: the matching provides a dual lower bound on the optimum through the LP relaxation, and this builds toward the LP-rounding perspective where the same factor emerges from rounding fractional solutions. This is exactly the pattern that appears again in Set Cover where the greedy algorithm's ratio matches the integrality gap of the LP, and it generalises to the primal-dual method that unifies many approximation algorithms. The central insight is that a combinatorial lower bound (matching for Vertex Cover, frequency counting for Set Cover) paired with a greedy algorithm gives a provable ratio, and putting these together with the hardness bounds from 47.03.06 shows that for Vertex Cover the gap between 2-approximation and hardness is either small (1.36 under PCP) or zero (2 - eps under UGC).
Exercises Intermediate+
Lean formalization Intermediate+
Mathlib has no formalization of approximation algorithms, approximation ratios, or the analysis of specific approximation algorithms. A SetCover.greedy definition with a proof that it achieves ratio would require the harmonic number bound, LP integrality gap analysis, and the dual-fitting proof technique. The Vertex Cover 2-approximation via maximal matching could be formalised using Mathlib's SimpleGraph and Matching structures, but the connection to the LP relaxation and integrality gap is absent. This unit ships without a lean_module.
Advanced results Master
Three results extend the basic approximation framework in different directions.
Result 1 (primal-dual method). The LP-rounding approach for Vertex Cover can be replaced by a purely combinatorial primal-dual algorithm that achieves the same 2-approximation without solving an LP. The algorithm maintains a dual feasible solution (a matching) and raises dual variables until a primal feasible solution (a cover) is obtained. This method generalises to many problems: Steiner Forest, Facility Location (constant-factor), and -Median (constant-factor). The primal-dual method is the workhorse of approximation algorithm design because it avoids the overhead of LP solving while retaining the same approximation guarantee [Vazirani Ch. 15].
Result 2 (PTAS and FPTAS). Some problems admit a Polynomial-Time Approximation Scheme (PTAS): for every , a -approximation runs in time . Euclidean TSP has a PTAS (Arora 1998, Mitchell 1999). Knapsack has an FPTAS (Fully Polynomial-Time Approximation Scheme) running in time . The boundary between PTAS-existence and hardness is characterised by the theory of APX-completeness: a problem is APX-hard if it admits no PTAS unless P = NP [CLRS Ch. 35].
Result 3 (recent improvements in TSP). Karlin, Klein and Oveis Gharan (2020) proved a -approximation for Metric TSP, breaking the 3/2 barrier of Christofides' 1976 algorithm. This was improved to by subsequent work. The technique uses the max-entropy sampling distribution on the spanning tree polytope and analyses the expected parity correction. The result is a landmark because the 3/2 barrier stood for over four decades [CLRS Ch. 35 notes].
Synthesis. Approximation algorithms provide the algorithmic counterpart to the hardness results of 47.03.06: where the PCP theorem establishes that no algorithm can cross certain ratio barriers, approximation algorithms show how close to those barriers we can get. The central insight is that the gap between the algorithmic ratio and the hardness bound defines the frontier of our understanding—Vertex Cover sits at ratio 2 with hardness at 1.36 (or under UGC), Set Cover has a tight match at , and Metric TSP sits at 3/2 with hardness at 123/122. This builds toward the randomised methods of 47.05.04 where randomness provides additional power for approximation in counting problems, and this is exactly the pattern that generalises from combinatorial optimisation to the broader landscape of NP-hard problems. Putting these together with the PCP theorem yields the full picture of what is efficiently computable.
Full proof set Master
Proposition 1 (greedy Set Cover approximation ratio). The greedy algorithm for Set Cover achieves an approximation ratio of where .
Proof. Let the greedy algorithm pick sets in order. At step , it picks the set covering the most uncovered elements; let be the number of newly covered elements at step . Assign a price of to each element covered at step . The total cost of the greedy solution equals the total price assigned: , but we want to compare costs, not just count sets.
For weighted Set Cover, assign price to each element covered at step . The total greedy cost is .
Consider any set in the optimal solution. When is examined at step , at most of its elements are uncovered. Since greedy picks the set with the most uncovered elements, . Each uncovered element of at step receives price at most .
The total price charged to elements of is at most . Since every element belongs to some set in the optimal cover: . So the greedy cost is at most .
Proposition 2 (no constant-factor approximation for general TSP). For any polynomial-time computable function , TSP without the triangle inequality cannot be approximated within factor unless P = NP.
Proof. Reduce Hamiltonian Cycle to TSP. Given graph , create a TSP instance on with if and otherwise. If has a Hamiltonian cycle, the optimal TSP tour has weight . If not, every tour must use at least one non-edge, giving weight at least . An algorithm distinguishing these cases solves Hamiltonian Cycle.
For stronger inapproximability: set non-edge weights to . Then YES instances have and NO instances have . An -approximation would return a tour of cost at most in the YES case and at least in the NO case, distinguishing them. This works for any polynomial-time computable .
Connections Master
47.02.03— NP-completeness is the starting point: every problem discussed here is NP-hard to solve exactly, and approximation is the response to that intractability.47.04.01— Amortised analysis techniques appear in the running-time analysis of approximation algorithms, particularly for data-structure-based implementations of greedy algorithms.47.03.06— Hardness of approximation provides the matching lower bounds: Vertex Cover at 1.36, Set Cover at , and general TSP at no constant factor.47.05.04— FPRAS extends approximation to counting problems where the output is a numerical estimate rather than a combinatorial structure.47.05.05— Derandomisation techniques can convert randomised approximation algorithms into deterministic ones with the same guarantee.
Historical & philosophical context Master
The study of approximation algorithms began in the 1960s and 1970s with the greedy algorithm for Set Cover (Johnson 1974, Lovász 1975) and the 2-approximation for Vertex Cover. Christofides' 3/2-approximation for Metric TSP appeared in 1976 and stood as the best known ratio for 44 years until Karlin, Klein and Oveis Gharan's 2020 improvement.
The field matured through the lens of LP relaxations: the work of Hochbaum (1982) on LP rounding for Vertex Cover, the primal-dual framework of Bar-Yehuda and Even (1981), and the comprehensive treatment by Vazirani (2001). The tight analysis of greedy Set Cover (achieving and hardness at ) represents one of the few cases where the algorithmic upper bound matches the complexity-theoretic lower bound up to lower-order terms [CLRS Ch. 35].
The philosophical lesson is that NP-hardness does not mean we must give up entirely: approximation algorithms provide rigorous, practical solutions with provable quality guarantees. The question shifts from "can we solve it?" to "how close can we get?", and the answer is often surprisingly good.
Bibliography Master
@book{cormen2022introduction,
author = {Cormen, Thomas H. and Leiserson, Charles E. and Rivest, Ronald L. and Stein, Clifford},
title = {Introduction to Algorithms},
edition = {4th},
publisher = {MIT Press},
year = {2022},
}
@book{vazirani2001approximation,
author = {Vazirani, Vijay V.},
title = {Approximation Algorithms},
publisher = {Springer},
year = {2001},
}
@article{christofides1976worst,
author = {Christofides, Nicos},
title = {Worst-Case Analysis of a New Heuristic for the Travelling Salesman Problem},
journal = {Technical Report, Carnegie Mellon University},
year = {1976},
}
@article{karlin2020slightly,
author = {Karlin, Anna R. and Klein, Nathan and Oveis Gharan, Shayan},
title = {A Slightly Better Approximation Algorithm for the Traveling Salesman Problem},
journal = {Proceedings of the 53rd ACM Symposium on Theory of Computing},
year = {2021},
pages = {32--45},
}
@article{feige1998threshold,
author = {Feige, Uriel},
title = {A Threshold of $\ln n$ for Approximating Set Cover},
journal = {Journal of the ACM},
volume = {45},
number = {4},
pages = {634--652},
year = {1998},
}