Afterglowscreensavers

Traveling Salesman Heuristics Screensaver

The Traveling Salesman Heuristics screensaver builds a real nearest-neighbor tour through random cities, then improves it live with real 2-opt swaps, steadily shortening the route. It is free, runs in your browser, and ESC exits.

Live preview

Press ESC to leave fullscreen. Settings are saved in your browser only.

How the Traveling Salesman Heuristics screensaver works

The saver scatters a real random set of cities, then builds an initial tour with the real nearest-neighbor heuristic.

It then runs real 2-opt improvement, testing pairs of tour edges and reversing a segment whenever that shortens the total tour length.

Each accepted improvement is drawn live, so you watch the tour visibly untangle and shorten over time.

Once no further 2-opt improvement shortens the tour, it holds briefly, then a fresh random set of cities and tour begins.

A worked example

A crossing pair of tour edges gets uncrossed by a real 2-opt reversal, visibly shortening the route the moment the swap is applied.

Settings & tips

Frequently asked questions

Does this find the perfect shortest route?
No — the traveling salesman problem is real and famously hard; this uses real, practical heuristics that get close, not guaranteed-optimal.
What is 2-opt?
A real, classic local-search move that reverses a tour segment whenever doing so shortens the total route.
Is a key needed?
No — it is a pure local computation.
Is it free?
Yes — free, no download, in your browser.

← All Science & Research screensavers