Free tool · no sign-up
Drop points, press Solve, and watch a short round trip through all of them take shape: first the nearest-neighbour guess, then 2-opt untangling it one swap at a time.
Runs in your browser. Nothing you paste is uploaded or stored.
Updated
In the order the points were added. Press Solve.
14 pointsUnsolved
In short
The traveling salesman problem asks for the shortest route that visits every point once and returns to the start. Checking every order is impossible beyond a handful of stops: 15 stops have over 43 billion distinct round trips. Practical solvers build a good route fast and improve it. This one uses nearest neighbour, then 2-opt swaps that uncross legs until no single swap helps.
Click the canvas to drop points, or press Random points. The first point (S) is the start.
Nearest neighbour builds a first route, then 2-opt swaps shorten it step by step.
The badge shows how much shorter the result is than the order the points were added.
Turn off Round trip to find a short path that doesn't return to the start.
Because the number of possible orders explodes. With a fixed start, n stops can be visited in (n − 1)! orders, and a round trip and its reverse are the same length, so there are (n − 1)! ÷ 2 distinct loops.
| Stops | Distinct round trips |
|---|---|
| 5 | 12 |
| 8 | 2,520 |
| 10 | 181,440 |
| 15 | 43,589,145,600 |
| 20 | about 60 quadrillion |
| 30 | about 4 × 10³⁰ |
Mathematically it's NP-hard: no one knows a method that's guaranteed to find the best route quickly for every case. Real route planners therefore use heuristics: fast methods that find very good routes, usually within a few percent of the best possible.
Start at the base and always drive to the closest stop you haven't visited. It's fast and usually decent, but it paints itself into corners: the last few stops are often far apart, and the route crosses itself.
Take any two legs of the route. If reversing the stretch between them makes the trip shorter, which is exactly what happens when two legs cross, do it. Repeat until no swap helps. The result has no crossings.
EZRoutePlanner's Optimize Route works the same way, nearest neighbour followed by 2-opt improvement, with your start kept in place and the end either back at the start or pinned to a last stop. Then it draws the route on real roads and measures every leg. Read how route optimization works.
Real routes add roads. Two stops that look close can be on opposite sides of a river or a highway. A route planner looks each address up, orders the stops, then follows the road network for the actual driving distance and time. The bigger the list, the bigger the gap between the order a list happens to be in and a good one.
It's the problem of finding the shortest route that visits each of a set of locations exactly once and returns to the start. It's the core of route optimization for deliveries, service calls and sales visits.
Small cases, yes: specialised solvers prove the optimum for thousands of points with heavy computation. Everyday route planners use heuristics like nearest neighbour and 2-opt because they're fast and land very close to the optimum.
The traveling salesman problem has one vehicle. The vehicle routing problem (VRP) has several vehicles, and often adds capacities and time windows, so it also decides which stops go to which vehicle. See the glossary.
Paste the addresses into EZRoutePlanner and press Optimize Route. It runs the same kind of method on your real stops and draws the result on real roads.
EZRoutePlanner puts your stops in the shortest order with one click, keeps every address on a map, and sends the route to your phone. Free to start.
Free plan. No credit card. Works in any browser.