Why Starting Points and Ties Matter
The nearest-neighbor method builds a traveling-salesperson tour by repeatedly going to a closest vertex that has not yet been visited, then returning to the starting vertex after all vertices have been visited. The local choice is simple, but it can steer the route toward a costly final return. Different starting vertices can therefore produce different tours. If two unvisited vertices are equally close, different tie-breaking choices can also change the result.
Throughout, a TSP instance is a finite complete undirected graph \(G=(V,E)\), with \(n=|V|\ge 3\), and a positive cost \(w(uv)=w(vu)\) assigned to each edge \(uv\). A tour is a cycle that visits every vertex exactly once before returning to its start. Its cost is the sum of the costs of its edges, including the return edge. We compare the tours produced by nearest-neighbor runs; choosing the cheapest among them does not by itself prove that this tour is globally optimal.
There are two ways to compare runs. With a fixed deterministic tie-breaking rule, perform one run from each start vertex and compare the \(n\) resulting tours. If ties are to be explored rather than settled by one rule, consider all permitted choices at tied steps, from each start, and compare every resulting tour. The second procedure can produce more candidates; in either case, “best” means least cost among the candidates actually considered.
Why a Run Produces a Tour
Proof. Fix a start vertex \(s\). Initially, \(s\) has been visited. Suppose the run has visited \(k\) distinct vertices, where \(1\le k<n\). At least one vertex remains unvisited. Completeness means that the current vertex is adjacent to every unvisited vertex, so the run can choose an edge to one of them. Its next vertex is unvisited, so the number of distinct visited vertices increases from \(k\) to \(k+1\). Repeating this step visits \(n\) distinct vertices. The graph is complete, so an edge joins the last vertex to \(s\); taking it closes the route. The route visits every vertex exactly once before this return and has at least three vertices, so it is a tour. \(\square\)
This proposition justifies the construction, not its quality: nearest-neighbor choices are locally cheapest among the currently available edges, but the proposition gives no guarantee that the resulting tour has minimum possible cost.
Worked Example: Changing the Starting Vertex
Let \(V=\{A,B,C,D\}\), and assign the following costs to the edges of the complete graph:
| Edge | Cost | Edge | Cost |
|---|---|---|---|
| \(AB\) | 1 | \(AC\) | 3 |
| \(AD\) | 5 | \(BC\) | 2 |
| \(BD\) | 6 | \(CD\) | 3 |
There are no ties in these runs. Starting at \(A\), the cheapest edge to an unvisited vertex is \(AB\), of cost \(1\). From \(B\), the remaining choices have costs \(BC=2\) and \(BD=6\), so the run takes \(BC\). It then takes \(CD=3\) and returns from \(D\) to \(A\) along \(DA=5\). The tour is \(A,B,C,D,A\), with cost \(1+2+3+5=11\).
Starting at \(B\), the run takes \(BA=1\). From \(A\), it chooses \(AC=3\) rather than \(AD=5\); from \(C\), it must take \(CD=3\), then return along \(DB=6\). The tour is \(B,A,C,D,B\), with cost \(1+3+3+6=13\).
Starting at \(C\), the run takes \(CB=2\), then \(BA=1\) rather than \(BD=6\). It next takes \(AD=5\) and returns along \(DC=3\). The cost is \(2+1+5+3=11\).
Starting at \(D\), the run takes \(DC=3\). At \(C\), the choices to \(A\) and \(B\) have costs \(3\) and \(2\), so it takes \(CB=2\), then \(BA=1\), and returns along \(AD=5\). The cost is \(3+2+1+5=11\).
Check: The four completed tour costs are \(11,13,11,11\), respectively. Each sum includes four edges, including the return edge. Among these four runs, the least cost is \(11\), achieved by three starts; the run from \(B\) costs \(13\).
Tie-Breaking Can Change the Tour
A tie is local to a particular step: two or more unvisited vertices have the same minimum edge cost from the current vertex. A rule that always chooses the lowest-labelled vertex, for instance, makes a run reproducible, but it does not compare the other choices that were tied. To see the effect of exploring a tie, compare the possible continuations explicitly.
Worked Example: Two Choices from the Same Start
Let \(V=\{A,B,C,D\}\) and let the complete graph have edge costs \(AB=1\), \(AC=1\), \(AD=4\), \(BC=2\), \(BD=3\), and \(CD=8\). Start at \(A\). The two nearest unvisited vertices, \(B\) and \(C\), are tied, each at cost \(1\).
If the run chooses \(B\), the unvisited choices from \(B\) are \(C\) at cost \(2\) and \(D\) at cost \(3\), so it takes \(C\). From \(C\), it takes the only remaining unvisited vertex \(D\), at cost \(8\), then returns to \(A\) at cost \(4\). The tour is \(A,B,C,D,A\), and its cost is \(1+2+8+4=15\).
If instead the run chooses \(C\), then from \(C\) it takes \(B\) at cost \(2\) rather than \(D\) at cost \(8\). From \(B\), it takes \(D\) at cost \(3\), then returns to \(A\) at cost \(4\). This tour is \(A,C,B,D,A\), and its cost is \(1+2+3+4=10\).
Check: Both runs begin with a minimum-cost edge of \(1\) from \(A\), and both then choose a minimum-cost available edge at every step. Their completed costs differ by \(15-10=5\). Thus a tie-breaking choice can affect tour cost even when the start vertex is held fixed.
When a run has several tied steps, a choice at one step can change which vertices are available at the next step. To examine every outcome, branch at each tied step and continue each branch until it completes a tour. If a single deterministic tie-breaking rule is used instead, the result is one tour per starting vertex, not an evaluation of all possible tie resolutions.
Restarting at Every Vertex
Proof. Let \(C(v)\) be the cost of the tour produced by the fixed-rule run from vertex \(v\), and let \(M=\min_{v\in V} C(v)\). By the definition of a minimum, \(M\le C(v)\) for every \(v\in V\); this proves the first statement. Every fixed-rule run uses tie-breaking choices that are permitted when all tie outcomes are explored. Therefore each fixed-rule tour belongs to the expanded candidate set. The minimum over a set cannot exceed the minimum over a subset, which proves the second statement. This compares the runs performed; it does not compare their minimum with the cost of an optimal TSP tour. \(\square\)
The proposition explains exactly what restarting accomplishes: the cheapest result from the runs cannot be worse than any individual result in those runs. It does not say that restarting finds the best possible Hamiltonian cycle. The set of tours found by nearest neighbor may omit tours that do not follow its local-choice rule.
Worked Example: Selecting the Cheapest Restarted Run
Let \(V=\{A,B,C,D,E\}\), with the following edge costs in the complete undirected graph:
| Edge | Cost | Edge | Cost | Edge | Cost |
|---|---|---|---|---|---|
| \(AB\) | 2 | \(AC\) | 9 | \(AD\) | 8 |
| \(AE\) | 7 | \(BC\) | 3 | \(BD\) | 6 |
| \(BE\) | 8 | \(CD\) | 2 | \(CE\) | 5 |
| \(DE\) | 1 |
There are no ties in the runs. From \(A\), the successive choices are \(B\) (cost \(2\)), \(C\) (cost \(3\)), \(D\) (cost \(2\)), and \(E\) (cost \(1\)); the return \(EA\) costs \(7\). The total is \(2+3+2+1+7=15\), giving \(A,B,C,D,E,A\).
From \(B\), the run takes \(A\) at cost \(2\), then \(E\) at cost \(7\) rather than \(C\) at \(9\) or \(D\) at \(8\). It takes \(D\) at cost \(1\), then \(C\) at cost \(2\), and returns to \(B\) at cost \(3\). Its tour cost is \(2+7+1+2+3=15\).
From \(C\), the run takes \(D\) at cost \(2\), then \(E\) at cost \(1\), then \(A\) at cost \(7\) rather than \(B\) at \(8\). It takes \(B\) at cost \(2\) and returns to \(C\) at cost \(3\). Its tour cost is \(2+1+7+2+3=15\).
From \(D\), the run takes \(E\) at cost \(1\), then \(C\) at cost \(5\) rather than \(A\) at \(8\) or \(B\) at \(6\). It takes \(B\) at cost \(3\), then \(A\) at cost \(2\), and returns to \(D\) at cost \(8\). Its tour cost is \(1+5+3+2+8=19\).
From \(E\), the run takes \(D\) at cost \(1\), then \(C\) at cost \(2\), then \(B\) at cost \(3\), then \(A\) at cost \(2\), and returns to \(E\) at cost \(7\). Its tour cost is \(1+2+3+2+7=15\).
Check: The five computed costs, in start order \(A,B,C,D,E\), are \(15,15,15,19,15\). The least is \(15\), and one corresponding tour is \(A,B,C,D,E,A\), whose edge costs sum to \(2+3+2+1+7=15\). Restarting avoids selecting the more expensive \(D\)-start result, but this calculation establishes only the least cost among these five nearest-neighbor runs.
Common Pitfall: Forgetting the Return Edge
Nearest neighbor makes its greedy choices before the final return, but the return edge is still part of the tour. In the first worked example, the run from \(B\) visits \(B,A,C,D\). Adding only the three selection costs gives \(1+3+3=7\), but \(7\) is the cost of the open route \(B,A,C,D\), not of a tour. The required return \(DB\) costs \(6\), so the completed tour costs \(7+6=13\). Comparing incomplete route costs can therefore select the wrong starting vertex.
A second distinction is equally important: the best tour found is not automatically an optimal tour. The restarting procedure compares a defined collection of nearest-neighbor outputs. It gives no certificate that every possible tour has been considered. Any optimality claim would need an additional argument beyond the fact that one candidate is cheapest among the runs.
Check Your Understanding
For each question, include every return edge when calculating a tour cost.
- In the first worked example, what tour and cost result from starting at \(C\)? Which edge is used to return to the start?
- In the tie example, list the two tied choices from \(A\) and explain how the resulting tour costs differ.
- For the five-vertex example, which starting vertex produces the largest computed tour cost, and what is that cost?
- Why does the proposition about restarting not establish that the selected tour is globally optimal?
- Describe how you would compare every possible outcome if a run has two tied choices at one step and another tie later in that run.