Sub topic 8
Why General TSP Cannot Be Approximated
The previous chapter gave a 2-approximation for TSP when distances obey the triangle inequality. It is natural to hope that a weaker constant, say 10 or 1000, could be achieved without that assumption. That hope fails. Unless P = NP, no polynomial-time algorithm approximates general TSP within any constant factor. The bound also fails for many factors that grow with n, such as 2^n.
This chapter assumes you know what NP-completeness and polynomial-time reductions are, that Hamiltonian Cycle is NP-complete, and how the approximation ratio is defined for minimization problems. It also assumes you have read the metric TSP chapter.
The Problem Without the Triangle Inequality
In general TSP the input is a complete graph on n vertices with a nonnegative weight d(u, v) on every pair. The task is to find a tour, meaning a cycle that visits every vertex exactly once, of minimum total weight. Nothing ties the weights together. A direct edge may cost far more than a two-hop detour.
The metric algorithms depend on that tie. The double-tree algorithm shortcuts past repeated vertices, and the triangle inequality guarantees that a shortcut never costs more than the path it replaces. Without the inequality a single shortcut can be arbitrarily expensive, so the analysis collapses. The question this chapter answers is whether a cleverer algorithm could still succeed. It cannot.
The Gap-Introducing Reduction
The proof is a reduction from Hamiltonian Cycle. The goal is to show that a ρ-approximation for TSP would decide an NP-complete problem in polynomial time.
Building the instance
Start with an undirected graph G = (V, E) with n ≥ 3 vertices. Build a TSP instance on the same vertices:
- d(u, v) = 1 if {u, v} is an edge of G.
- d(u, v) = ρn + 1 otherwise.
This takes O(n²) time, as long as the number ρn + 1 can be written down in polynomial time. The section on gotchas comes back to that condition.
The two cases
G has a Hamiltonian cycle. That cycle is a tour that uses only weight-1 edges, so OPT = n.
G has no Hamiltonian cycle. Every tour must use at least one pair that is not an edge of G. Otherwise the tour itself would be a Hamiltonian cycle in G. One heavy edge plus n − 1 edges of weight at least 1 gives
cost ≥ (ρn + 1) + (n − 1) = ρn + n > ρn.
So OPT > ρn.
The optimum is either exactly n or more than ρn, with nothing in between. This empty interval is the gap, and a reduction that creates one is called a gap-introducing reduction.
Using the gap
Suppose algorithm A runs in polynomial time and always returns a tour of cost at most ρ · OPT. Run A on the constructed instance:
- If G is Hamiltonian, A returns a tour of cost at most ρ · n.
- If G is not Hamiltonian, every tour costs more than ρn, so A's tour does too.
The test "is A's cost ≤ ρn?" therefore decides Hamiltonian Cycle in polynomial time, and that would imply P = NP. The tour A returns does not even need to be inspected. Its cost alone carries the answer.
Seeing the Gap in Code
The script below builds the instance and finds the optimum by brute force, which stands in for the hypothetical approximation algorithm. It applies the decision rule to two graphs on four vertices. The first is a 4-cycle with a chord, which is Hamiltonian. The second is a star, which is not.
from itertools import permutations
def build_tsp_instance(n, edges, rho):
heavy = rho * n + 1
dist = [[0 if i == j else heavy for j in range(n)] for i in range(n)]
for u, v in edges:
dist[u][v] = dist[v][u] = 1
return dist
def tour_cost(dist, tour):
return sum(dist[tour[i]][tour[(i + 1) % len(tour)]] for i in range(len(tour)))
def optimal_tour_cost(dist):
n = len(dist)
return min(tour_cost(dist, (0,) + p) for p in permutations(range(1, n)))
def satisfies_triangle_inequality(dist):
n = len(dist)
return all(dist[i][k] <= dist[i][j] + dist[j][k]
for i in range(n) for j in range(n) for k in range(n))
def decide_hamiltonian(n, edges, rho):
dist = build_tsp_instance(n, edges, rho)
cost = optimal_tour_cost(dist) # any rho-approximation would do here
return cost, cost <= rho * n, satisfies_triangle_inequality(dist)
rho = 2
cycle_with_chord = [(0, 1), (1, 2), (2, 3), (3, 0), (0, 2)]
star = [(0, 1), (0, 2), (0, 3)]
print("cycle+chord:", decide_hamiltonian(4, cycle_with_chord, rho))
print("star: ", decide_hamiltonian(4, star, rho))Output:
cycle+chord: (4, True, False)
star: (20, False, False)The star's optimum is 20. Each leaf needs two tour neighbors, but the center can serve only two leaf slots in total, so at least two heavy edges are needed: 1 + 1 + 9 + 9 = 20. The threshold is ρn = 8, and both answers fall well clear of it. Both instances also fail the triangle inequality check. The next section explains why that failure is required.
Where the Proof Breaks for Metric TSP
The constructed weights violate the triangle inequality as badly as possible. For a non-edge {u, w} that shares a neighbor v, the direct cost is ρn + 1, while the detour u → v → w costs 2. This is the only possible way the reduction could work. If it produced metric instances, it would contradict the 2-approximation from the previous chapter.
Try to repair the instance by replacing every weight with its shortest-path distance, the metric closure. In a connected G, non-adjacent vertices at distance two then get weight 2, and farther pairs get larger graph distances. The gap disappears. A non-Hamiltonian graph may now have an optimum tour of only n + 1. The closure models a walk that may revisit vertices, and that relaxation is exactly what makes metric TSP easier.
| Variant | Weights | Best known polynomial-time guarantee | Constant-factor approximation possible? |
|---|---|---|---|
| General TSP | Arbitrary | None | No, unless P = NP |
| Metric TSP | Triangle inequality | 3/2 (Christofides), slightly below 3/2 (Karlin–Klein–Oveis Gharan) | Yes |
| (1,2)-TSP | All weights 1 or 2 | Constant factor below 8/7 | Yes, but no PTAS unless P = NP |
| Euclidean TSP | Points in the plane | 1 + ε for any ε > 0 (Arora, Mitchell) | Yes, arbitrarily close to 1 |
Setting ρ = 1 in the reduction gives weights 1 and 2. That is a (1,2)-TSP instance, which is metric, and it shows that even this restricted version is NP-hard to solve exactly.
Gotchas and Edge Cases
How large can ρ be?
The argument never used the fact that ρ is a constant. It works for any ρ(n) as long as the weight ρ(n) · n + 1 can be computed and written with polynomially many bits. For ρ(n) = 2^n the heavy weight has about n + log n bits, which is fine, so even a 2^n-approximation is ruled out. For ρ(n) = 2^(2^n) the weight needs exponentially many bits, so the construction no longer runs in polynomial time and the argument says nothing.
The conclusion is conditional
The result is "impossible unless P = NP", not "impossible". It also covers only worst-case guarantees. Heuristics such as 2-opt or Lin–Kernighan often perform well on real instances. They simply cannot offer a ratio that holds for every input.
Asymmetric and relaxed variants
The same reduction works for directed graphs through Directed Hamiltonian Cycle. Asymmetric TSP without the triangle inequality is therefore just as inapproximable. Asymmetric TSP with the triangle inequality does have a constant-factor approximation (Svensson, Tarnawski, and Végh, 2018). Between the two extremes sits the τ-relaxed triangle inequality, d(u, w) ≤ τ(d(u, v) + d(v, w)). For that variant there are constant-factor approximations whose ratio grows with τ. The obstruction is the unbounded violation itself, not the absence of strict metricity.
Why "gap" is the key idea
Most NP-hardness proofs show that telling yes-instances from no-instances is hard. A gap-introducing reduction also pulls the two kinds of instance far apart in objective value, so that even a rough estimate of OPT separates them. The chapter on gap reductions and the PCP theorem generalizes this idea to problems such as MAX-3SAT. For those problems no simple weighting trick creates a gap, and much deeper tools are needed.
Exercises
Exercise
In the reduction, could the non-edge weight be ρn instead of ρn + 1? Justify your answer for n ≥ 2.
Show answer
Yes. In the non-Hamiltonian case a tour has at least one heavy edge and n − 1 other edges of weight at least 1, so its cost is at least ρn + (n − 1) ≥ ρn + 1 > ρn. The gap is preserved. The +1 only makes the inequality obvious.
Exercise
Someone claims a polynomial-time n-approximation for general TSP. Using the reduction with ρ(n) = n, what weight would non-edges get, and what would the claim imply?
Show answer
Non-edges get weight n·n + 1 = n² + 1, which has O(log n) bits, so the construction is polynomial. Hamiltonian graphs give OPT = n, and other graphs give OPT > n². Comparing the algorithm's cost with n² would decide Hamiltonian Cycle, which implies P = NP.
Exercise
Apply the metric closure (shortest-path distances in G) to the star on vertices {0, 1, 2, 3} centered at 0. What is the optimal tour cost, and why does the gap disappear?
Show answer
Leaf-to-leaf distances become 2 and center-to-leaf distances stay 1. The tour 0, 1, 2, 3, 0 costs 1 + 2 + 2 + 1 = 6, which is optimal, against n = 4 for a Hamiltonian graph. The ratio 6/4 = 1.5 is bounded, so a constant-factor algorithm cannot tell the cases apart. The closure satisfies the triangle inequality, and that destroys the gap.
Exercise
Why does the reduction not show that Euclidean TSP is hard to approximate?
Show answer
Euclidean distances always satisfy the triangle inequality, so no Euclidean instance can have weight 1 on edges u–v and v–w together with a huge weight on u–w. The construction cannot be realized with points in the plane. In fact, Euclidean TSP has a PTAS.