Exercise

Reduce Hamiltonian Cycle to TSP

Map an undirected graph to a complete weighted TSP instance and prove the threshold equivalence.

Assignment sources

Semester A 2026 assignmentsOfficial assignmentexercise4.pdfQ3Authoritative course artifact
Semester B 2026 assignmentsOfficial assignmentassignment3.pdfQ3Authoritative course artifact
Noy 2025 high-quality exam preparation and community solutionsCommunity solutionפתרון מטלה 4 - סיבוכיות.pdfAssignment 4High-quality preparation and community solution — not official

Problem

Given an undirected graph G=(V,E)G=(V,E) with n≥3n\ge3, construct a complete weighted graph on VV and threshold BB such that GG has a Hamiltonian cycle iff the resulting decision-TSP instance has a tour of cost at most BB. Prove both directions, polynomial size, and NP membership.

Prerequisites

Know the unit definitions and how resources are measured against encoded input length. Distinguish a conditional theorem, a reduction, and an algorithm.

Hint 1

Give original edges cost 1 and missing edges cost 2.

Hint 2

Every tour has exactly nn edges.

Hint 3

A tour itself is a polynomial certificate.

Guided construction

Hamiltonian Cycle → TSP

Step 1 of 6
Hamiltonian Cycle to TSP on five verticesA pentagon of five original cost-1 edges is completed by a pentagram of five cost-2 chords; the pentagon itself is a tour of cost five, exactly the budget B = n = 5.Source G — 5 vertices, 5 edges12345
Original edge of G — cost 1

Full solution

Construct the complete graph KVK_V. Set c(u,v)=1c(u,v)=1 when {u,v}∈E\{u,v\}\in E and c(u,v)=2c(u,v)=2 otherwise, and choose B=nB=n. The construction lists O(n2)O(n^2) edges and uses one-bit costs, hence is polynomial.

If GG has a Hamiltonian cycle, use the same cyclic ordering in KVK_V. All its nn edges are original and have cost one, so the tour costs exactly nn and is feasible.

Conversely, every Hamiltonian tour in the complete graph contains exactly nn edges and each edge costs at least one. A tour of cost at most nn must therefore have cost exactly nn, forcing every chosen edge to cost one. By construction all those edges belong to EE, so the same cyclic ordering is a Hamiltonian cycle of GG. This proves the many-one equivalence, including the equality boundary at the threshold.

Decision-TSP is in NP for integer costs encoded in binary: a certificate is a permutation of the vertices. The verifier checks that every vertex occurs once, adds the nn indicated edge costs using polynomial-bit arithmetic, includes the return edge, and compares the sum with BB. Thus combining membership with the reduction from the NP-complete Hamiltonian-cycle problem proves NP-completeness of this TSP decision variant.

Completeness of the target graph matters. Missing source edges are not deleted; they receive a penalty. The threshold then ensures that a low-cost tour cannot use them. Using zero and one with threshold zero is also possible, but positive costs match common TSP definitions. This reduction proves decision hardness; it is not an approximation-preserving reduction and says nothing by itself about metric TSP, because costs 1 and 2 happen to satisfy the triangle inequality but the optimum gap is too small for arbitrary approximation claims.

Checkpoints

Check both logical directions, halting of every relevant branch, and that output length and construction time are polynomial in the encoded input length.

Common mistakes

  • Forgetting the closing edge of the tour.
  • Using threshold nn without observing all costs are at least one.
  • Claiming an approximation result from a decision reduction.

Sources and verification

  • 2026 transcript 14
  • Sipser 3e, sec. 7.5
  • Garey-Johnson, GT37 and ND22
  • Corpus coverage note: No direct merged-summary coverage.
  • Catalog mapping: data/exercises.json; statements and solutions are independently written; personal submissions are non-authoritative.

Provenance and confidence

The exercise is an original synthesis. Confidence reflects verification of the mathematical claim against the textbook sources listed above; course sources are used only where direct coverage is identified.