Minimizing over binary variables with one outgoing and one incoming edge at every graph vertex, and , is an assignment problem. Its feasible solutions are cycle covers of a directed graph, whereas a travelling salesman problem requires one Hamiltonian cycle. The relaxed minimum is therefore a lower bound on the tour cost. If its optimum contains a proper subtour , every tour omits at least one edge of . Branching into subproblems that respectively forbid each edge of preserves every possible tour. Solving each child assignment problem and pruning those whose bounds exceed the best tour yields a finite branch and bound algorithm. Equality also permits pruning when only one optimum is wanted.
Metric travelling salesman problem Created 2026-10-07 Updated 2026-10-14
This is the travelling salesman problem on a complete graph with nonnegative symmetric distances satisfying the triangle inequality. Repeated visits can be shortcut without increasing cost. Assigning distance one to edges of an input graph and two to its nonedges creates a metric instance with a tour of cost at most the number of vertices exactly when the graph has a Hamiltonian cycle. Thus the metric problem remains NP-hard.
Write for the partial assignment problem solution sending person to job . The prescribed assignment lower bound from independent task minima is
Every completion must pay at least the minimum in each remaining column, so this is a valid lower bound, even if the minima use the same person several times. At , the one remaining job must go to person 4, and the bound is the exact completed cost.
Use branch and bound with the smallest open bound expanded first. The initial bounds are
For example, . Expand , giving
Expand . Its children are with bound 64 and with bound 65. Completing the first gives at cost 64, our first incumbent. The second cannot improve it. We may also discard , , and , since their lower bounds are at least 64; equality may be pruned when seeking one optimum.
The remaining open prefix is , whose children have bounds
Only can improve the incumbent. Its children and have exact completed costs 69 and 61, respectively. The latter completes to and replaces the incumbent. Every other branch has already been bounded above this value. Thus the optimal assignment is
This branch and bound computation produces fourteen partial nodes: four initial nodes, three below , two below , three below and two below . The last person is assigned automatically at a depth-three node.
For the travelling salesman problem, let mean that the tour goes directly from city to city . Retain only the constraints
This is an assignment problem between cities as departure points and cities as arrival points, solvable by the Hungarian algorithm. Its optimum is a cycle cover of a directed graph, possibly with several disjoint cycles. Since every tour is such a cover, its cost is a lower bound on the best tour cost. This is the assignment relaxation of the travelling salesman problem.
If the minimizing cover is a single Hamiltonian cycle, it supplies a tour and can update the incumbent. Otherwise choose one proper subtour . No tour can contain all edges of , since that would close a cycle before visiting the remaining cities. Make one child subproblem for each edge of , forbidding that edge, and solve its modified assignment problem. These branches may overlap but together retain every possible tour. Prune a child if it is infeasible or its assignment bound is at least the incumbent cost. Further subtours cause further branching. Each branch adds a new forbidden edge, so the search is finite, and the covering property plus the valid lower bounds proves optimality when no open branch remains. This enforces the effect of subtour elimination constraints through branch and bound.
An integer program for the travelling salesman problem must exclude disconnected cycle covers, not merely require one incoming and one outgoing edge. Here is a compact order formulation of the travelling salesman problem. The one-city case is trivial. For , use binary variables for directed edges, , and integer variables for . Minimize subject to
The degree equations give a collection of disjoint directed cycles. Along any selected edge between nondistinguished cities, the last inequality gives . Summing around a cycle avoiding city would yield for its positive length . Thus every cycle must contain city , so there is exactly one tour. Conversely, number the cities after city in tour order, giving . Selected edges satisfy the order inequalities. Unselected edges impose no additional restriction, since . This proves equivalence with tours, including symmetric-distance instances represented by directed variables.
There are variables and rows. For the bit count, store only nonzero coefficients and their indices. The degree equations have entries in total; each order inequality has three entries, so these too have entries. Indices and the coefficients bounded by need bits each. The objective has distance coefficients, each needing at most bits because the PDF's bound is . Therefore
Writing an unnecessarily dense constraint matrix would give a larger encoding; it is the sparse explicit encoding that establishes the requested bound. For the decision version add . A threshold can be capped at , so its relevant binary length is ; negative thresholds can be rejected immediately for nonnegative distances.
A decision problem belongs to NP if its yes-instances have certificates of polynomial length checkable in deterministic polynomial time. It is NP-complete if it belongs to NP and every NP problem has a polynomial-time many-one reduction to it. The preceding construction is a polynomial-time reduction from travelling-salesman decision to integer-linear feasibility. If the former is NP-complete, the latter is consequently NP-hard.
For completeness we must also establish membership in NP for general integer-linear feasibility, rather than just for the binary instances produced by the reduction. An arbitrary feasible integer assignment could be numerically enormous; what is needed is the existence of a short one. We give a small integer feasibility witness by homogeneous cone decomposition.
Split each unrestricted integer variable into the difference of two nonnegative integer variables and add nonnegative integer slacks to inequalities. This gives , , with variables and integer data bounded in absolute value by . Both and are polynomially bounded by the original input length. Consider the homogeneous cone
Every vector in this cone is a nonnegative combination of at most support-minimal rays. To prove this, choose a nonnegative kernel vector of minimal nonempty support contained in the support of a given vector, subtract with the smallest positive coordinate ratio, and repeat. Each subtraction strictly reduces support. On a minimal support the kernel is one-dimensional: an independent kernel direction would let us perturb a positive vector to the boundary of its support without making it zero, contradicting minimality. Cofactors of independent rows therefore give an integer nonnegative generator of each such ray. Every coordinate is bounded by
using the elementary determinant bound. This proves the needed support-minimal rays of a nonnegative kernel facts directly.
Start with any integer feasible and decompose in this way. A ray whose last coordinate is a positive integer normalizes to a point with and ; the coefficients of these normalized points sum to one. Rays with last coordinate zero have integer nonnegative first coordinates with and coordinates at most . Hence
with at most ray terms. Subtract from . The result is still integer, nonnegative and feasible, and satisfies
Its binary length is polynomial, since . The assignment can be checked by exact integer arithmetic in polynomial time. Thus general integer-linear feasibility is in NP. Combining this with the reduction proves
Use a complete directed graph on cities, with integral arc costs and a threshold . A symmetric cost matrix also represents the undirected travelling salesman problem by orienting a tour. Let the binary variable indicate that city follows city , and forbid self-arcs. The decision integer programming formulation asks whether the following system has a solution:
The in-degree and out-degree equations make the selected arcs a cycle cover of a directed graph. Any proper graph cycle on a city set would violate its subset inequality, so the selected arcs form one Hamiltonian cycle. Conversely, a Hamiltonian cycle obeys every inequality: a proper subset cannot contain all the successor arcs of its graph vertices. Thus the binary feasibility system is equivalent to the decision travelling salesman problem. The subset formulation has exponentially many inequalities, which is harmless for this formulation; verifying a proposed tour does not require listing them.
To call this decision problem NP-complete means two separate things. It belongs to NP: a yes-instance has a polynomial-length certificate in computational complexity, namely the cyclic ordering of the cities, and a deterministic algorithm checks distinct visits, the return to the start, and the total cost in polynomial time in the binary input length. It is also NP-hard: every decision problem in NP has a polynomial-time many-one reduction to it, preserving yes and no answers. This is a statement about worst-case computation on finite encodings, not a proof that every individual tour is hard to find or that no polynomial algorithm exists; that last conclusion would require .
For the strict-threshold decision Max-TSP, choose an integer and replace each arc cost by . Every tour uses exactly arcs, so
Set the new threshold to . Its encoding length, the transformed matrix's encoding length and the computation time are all polynomial in the original input length. If thresholds are required to be nonnegative, take ; the same identity works. Symmetry of costs is preserved. This is a polynomial-time many-one reduction from decision travelling salesman problem to decision Max-TSP, so the latter is NP-hard. A tour is again a polynomially verifiable certificate in computational complexity, now checking strict excess over , so
For the approximation algorithm, use the standard nonnegative-length setting on a complete graph; no triangle inequality is required. Solve the maximum-weight assignment problem with diagonal assignments forbidden, for example by applying the Hungarian algorithm to the negative weights. The resulting cycle cover of a directed graph has weight with , since every tour is an allowed assignment.
If it already has a single graph cycle, it is an optimal tour. Otherwise remove a least-weight arc from each graph cycle. A graph cycle of arcs and weight loses at most . The remaining arcs form vertex-disjoint graph paths covering all cities. Join the endpoint of each graph path to the start of the next, cyclically. The required arcs exist by completeness, and their nonnegative weights cannot diminish the retained weight. The resulting single Hamiltonian cycle therefore satisfies
The Hungarian algorithm takes arithmetic operations, and finding the graph cycles, cutting them and patching the graph paths takes further operations. For rational or integer weights these operations have polynomial encoding length, giving polynomial time. With symmetric costs, the same directed construction is a valid undirected tour after forgetting its orientation. This is the cycle-cover patching half-approximation for Max-TSP.
Nonnegativity is essential to this multiplicative guarantee. If arbitrary signed weights were allowed, giving every arc cost would make every tour have weight , while half the optimum is . No tour could achieve the requested bound. Thus “length” has its usual nonnegative meaning in the approximation assertion.
For NP-completeness, use the decision version with an objective threshold. A permutation is a polynomial-size certificate, and its quadratic assignment problem cost is computable in arithmetic operations. To reduce the travelling salesman problem, let be the adjacency matrix of a directed cycle on the facility labels: , with indices cyclic, and every other entry zero. Let be the matrix of city-to-city distances. Then
which is exactly the tour length. Every tour arises from such a permutation. Hence the decision QAP is NP-complete, and finding its optimal value is NP-hard. No factor of two appears in this directed-cycle construction, even when the distance matrix is symmetric.
Fix any complete assignment . Its restriction to the facilities other than is an admissible bijection in the definition of , so
Summing this inequality over gives . Restricting to and minimizing proves
This is the Gilmore-Lawler bound. Its row minima may come from mutually incompatible assignments, so equality is not automatic. To find , fix facility one at location , delete that row and column from , and solve the residual assignment problem using the Hungarian algorithm, adding to its value.
For the supplied instance, the two residual assignment sums at each initial branch are
Use branch and bound to explore , the branch with smallest bound. Its minimizing linear assignment is . Evaluating the true ordered-pair objective gives
This supplies an incumbent of value and meets the lower bound of . Alternatively, after branching on facility two, the other leaf has row-sum bound and is pruned. The initial bounds and prune and as well, since neither can improve the incumbent. Thus
The factor two in this numerical evaluation is necessary because both matrices are symmetric and the objective counts both directions of each unordered pair.
A permutation assigns facilities to locations, and the objective combines their pairwise interactions with pairwise location costs. Ordered-pair and unordered-pair conventions differ by a factor of two for symmetric data. The decision version is NP-complete: letting record a directed cycle makes the objective exactly the length of a travelling salesman problem tour under the ordering given by the permutation. The optimization version is NP-hard.
Weighted Hamilton cycle 2026-10-14
A weighted Hamilton cycle is a Hamilton cycle in a weighted graph, with cost equal to the sum of its traversed edge weights. Here weights represent symmetric nonnegative costs, rather than conductances. Asking whether a Hamilton cycle exists is a feasibility question; asking for the cheapest one is an instance of the travelling salesman problem. A complete graph supplies every possible connection between distinct vertices, making feasibility automatic for , while choosing the cheapest visiting order remains a separate mathematical optimization problem.
Figure 1.
A fictitious weighted graph on four vertices: its three Hamilton cycles, identified under reversal and cyclic rotation, have costs 14, 19 and 21
. Details.
Assign the complete graph the symmetric edge costs , , , , and , in arbitrary units. Fix the start at and identify each Hamilton cycle with its reverse. The three possibilities are
These exhaust the possibilities: the permutations of the other three vertices give orders, paired into three reversals. Hence the perimeter tour really is optimal for this toy instance. The diagram's geometric lengths are not costs, and no triangle inequality is assumed.
The usefulness of this model is to distinguish visiting required sites from covering required connections. If tasks are assigned to vertices and the route must return after one visit to each, a weighted Hamilton cycle captures the ordering requirement. If the job instead requires each edge once, the relevant object is an Euler circuit. The shortest path problem asks only for a cheapest route between specified endpoints. A 1954 primary research paper gave a concrete motivation for the travelling salesman problem: certify that a particular tour through 49 cities has minimum road-distance cost.[ref]
These are abstract route models. If a cost stands for a whole graph path through an underlying network, travelling between consecutive task vertices can pass through intermediate network vertices more than once. One visit per task therefore does not imply one visit per physical junction. One-way connections require a directed graph; changing costs or extra timing constraints require a richer model than the fixed symmetric toy instance.