← Back to NN docs

teeline · algorithms/nn

Nearest Neighbor Construction

The simplest constructive TSP heuristic: start from a chosen city, repeatedly move to the closest unvisited city, then close the tour back to the start. Each step is a single greedy decision — easy to follow, but the final tour can be far from optimal.

01123456789
visited path last edge candidate edge nearest candidate current city
Click Step to start — NN picks the closest unvisited city
visited
1/10
remaining
9
distance
0
step
0
cities: 10partial: 0greedy nearest neighbor