Before any method, the count — because three different numbers are in circulation and each is correct for something else. On n cities there are n! orderings of the cities; (n − 1)! tours from a fixed start, counting each once per direction; and (n − 1)!/2 distinct undirected tours, which is what you are choosing among when the cost from one city to another is the same both ways.
n = 7 n! = 5040 orderings of the cities
7!/2 = 2520 each ordering once per direction
(n−1)! = 720 tours from a fixed start, both ways
(n−1)!/2 = 360 DISTINCT UNDIRECTED TOURS
n = 6 (n−1)!/2 = 60 and the lab enumerates exactly 60
Those 360 at seven cities are why the lab stops at seven: 360 tours can be enumerated instantly, so an exact answer is available to check every bound against, and that is worth more at this size than another city. The cap is this lab's own and it is a consequence of (n − 1)!/2 — nothing to do with the n! orderings that Discrete Mathematics’ Hamilton lab enumerates, which is a different quantity on a different object.
The claim “the number of tours is n!” is therefore an overcount by a factor of 2n: at seven cities 5040 against 360, and 5040 ÷ 360 = 14 = 2 × 7. The factor n is the arbitrary choice of starting city and the factor 2 is the direction, neither of which changes the tour or its length.
Definition · Subtour-elimination constraintFor a proper non-empty subset S of the cities, the constraint says that the chosen arcs may not form a closed cycle inside S: at least one arc must leave S. There is one such constraint per subset, so there are exponentially many, and a formulation that wrote them all down could not be built for a moderate n.
Example · Six cities: the bound, the subtours, and the treeOn the lab's opening instance the assignment relaxation is worth 80, and it returns three two-city subtours: cities 1 and 5 shuttling between each other, 2 and 3, and 4 and 6. That is a bound and not a route. Forbid one arc of the shortest subtour and re-solve; two of the children come back with a four-city subtour and a two-city one, still not a tour; forbid an arc again and the next child is a genuine tour worth 88. Five nodes in total, and the answer 88 is the route 1 → 2 → 4 → 6 → 3 → 5 → 1.
A measured gap, and a proved ratio
Nearest neighbour from city 1 gives 1 → 5 → 3 → 4 → 6 → 2 → 1, costing 96. Against the optimum of 88 that is 8 worse, which is 8/96 = 1/12 of the tour in hand — a measured gap, on this instance, for this heuristic, which the panel shows as 8.3%. with a gap of zero. That happens, and it is worth knowing rather than assuming, which takes a bound.
A measured gap and a proved ratio are different kinds of knowledge and the difference is worth a paragraph. The Algorithms path’s “Metric TSP by MST Doubling” proves a factor of two for every metric instance there is, for ever, without solving any of them. This lesson measures 1/12 on one instance, exactly, and claims nothing about the next one. The first is a theorem about a class; the second is a fact about a case — and on your own data, the fact is often what you need and is the only one of the two you can compute.
Three results are used here and proved elsewhere. The other exact method is the dynamic programme over subsets of “DP over Subsets: Held–Karp”, which runs in n² 2ⁿ time — a different trade, since it beats (n − 1)! badly and still grows exponentially. Why the problem is hard at all is “Reductions and Their Direction”, in the same subject. And the two-approximation above is that path's as well. None of the three is derived here.
The apparent tension between “hard” and “solved exactly in five nodes” is not one. Hardness is a statement about every instance of every size; a certificate is a statement about the instance in front of you. Branch and cut solves small and structured instances routinely, and the gap it reports on the ones it cannot close is exactly the honest form of the same fact — which is what this course has been building toward since the first rounded point failed.
Every cost in the lab is an integer or a fraction, so every tour length, every bound and every gap on the page is exact. That is deliberate: the one place this problem could produce an irrational number is a Euclidean distance, and a comparison between two tours that differs in the sixth decimal place is not a comparison anybody should be making on a rounded value.