Travelling Salesman Visualizer
Compare a nearest-neighbor tour with an exact shortest closed tour for 3–10 planar points, entirely in your browser.
A QUICK WALKTHROUGH
How to use this tool
- Enter one city per line as name, x, y.
- Calculate the nearest-neighbor and exact closed tours.
- Compare route order, distance, and the plotted paths.
What is compared
The nearest-neighbor route repeatedly visits the closest unvisited point. The exact result uses bounded dynamic programming and returns the shortest closed loop that starts and ends at the first city.
Small planar problems only
Enter 3 to 10 unique city names with finite x/y coordinates from −1,000,000,000 to 1,000,000,000. Distances are straight-line coordinate units, not roads, fares, or travel times.
GOOD TO KNOW
Common questions
Is nearest neighbor always optimal?
No. It is a fast heuristic. The exact route provides the comparison for the entered points.
Why is the tool limited to 10 cities?
Exact traveling-salesman work grows quickly. The small limit keeps local computation and drawing responsive.