No—the Traveling Salesman Solver does not follow roads or traffic; it measures straight-line Euclidean distance between named points on a flat two-dimensional coordinate plane. The solver creates an approximate closed tour that visits each entered point once and returns to the first point, but it has no road graph, map data, one-way streets, traffic conditions, travel-time estimates, obstacles, appointments, vehicle-capacity rules, or multiple-driver constraints. That means a straight segment from A to B is a mathematical distance, not a claim that a vehicle can drive from A to B. It is suited to coordinate-based exercises, local layouts, spatial-order exploration, and reproducible planning fixtures where straight-line distance is the intended cost. It is not an operational navigation or dispatch tool. The Traveling Salesman Solver accepts 3–50 distinct named x,y locations, fixes the first row as the start, builds a nearest-neighbor tour, and then applies deterministic 2-opt improvement. Its distance and route are therefore appropriate only when the x and y axes form a meaningful flat plane and direct point-to-point movement is an acceptable assumption. No external map or routing API is called, so the tool neither retrieves live road conditions nor sends location data out of the browser.

What the solver actually calculates
The solver treats each location as a point on a flat plane. It calculates the distance between points with the Euclidean formula, sqrt((x2−x1)² + (y2−y1)²), sums the legs of the tour, and includes the final leg back to the starting location. The reported total is therefore a coordinate-plane distance rather than a driving distance.
For example, the distance from A at (0,0) to B at (3,4) is calculated as sqrt((3−0)² + (4−0)²) = sqrt(9 + 16) = sqrt(25) = 5 coordinate units.
Coordinates can represent meters on a local drawing, pixels in a layout, or unitless classroom positions. For the result to be meaningful, both axes should use the same scale. If one axis represents meters and another represents kilometers, for example, adding their squared differences would not produce a coherent distance. The route also does not know whether a line crosses a wall, water, restricted land, or any other obstacle.
Roads, traffic, and geographic coordinates
Road-aware route planning and Euclidean tour calculation solve related ordering problems with different underlying costs. The distinction matters because the shortest geometric loop may be impossible or impractical to drive, while a realistic road route may be much longer.
| Consideration | Traveling Salesman Solver | Real-world route planning |
|---|---|---|
| Distance measure | Straight-line Euclidean distance | Road-network distance or a supplied distance or time matrix |
| Traffic and travel time | Not modeled | Must be represented in the routing data and model |
| Route constraints | One visit per point, a closed tour, and a fixed first point | Relevant constraints such as one-way streets, obstacles, appointments, capacity, and drivers |
| Result | Approximate geometric tour with total coordinate distance | Network-constrained itinerary intended for travel |
Do not enter latitude and longitude as raw degrees and treat the result as reliable Earth distance. Degrees distort geometric distance, particularly across large regions and near the antimeridian. For geographic work, convert the points to an appropriate local projection or use a routing service designed for geodesic distance. The related guide Can You Enter Latitude and Longitude in a TSP Solver? explains that limitation in more detail.
Build a closed tour from your coordinates
- Prepare 3–50 distinct coordinate pairs. Write one location per line in the format name, x, y. Names cannot contain commas, and coordinate values must be finite and within the tool’s accepted bounds. Duplicate coordinate pairs are rejected because two separately named points at exactly the same position would make the route display ambiguous.
- Put the required start in the first row. The first input point becomes the fixed starting location, and the completed route returns there at the end. Put the same first location first on each repeated run when you want reproducible results.
- Build the approximate tour. The tool first constructs a closed route with nearest neighbor. It then attempts local improvements with 2-opt and displays both the nearest-neighbor starting distance and the improved distance so you can see how much the second stage changed.
- Inspect the full result. Check that the displayed name sequence visits every point once and closes at the first location. Review the total straight-line distance, the initial nearest-neighbor distance, and the number of 2-opt passes.
- Decide whether the geometric assumption fits. Confirm that direct lines between the points are meaningful for your task. If roads, traffic, obstacles, travel time, schedules, or vehicle constraints matter, treat the route as a spatial ordering exercise rather than a usable travel plan.
- Copy the result only if it is suitable. The copied output contains the complete closed name sequence and calculated distance. When solution quality matters, repeat the calculation with several locations in the first row and compare the resulting tours, because a different start can lead to a different local minimum.
How nearest neighbor and 2-opt work
Construction begins at the first input point. At each step, nearest neighbor selects the closest unvisited point according to Euclidean distance. If two candidates are exactly the same distance away, the solver keeps the earlier point in the original input order. Once every point has been selected, the route is closed by connecting the final point back to the start.
After that initial route exists, 2-opt examines two edges in the tour. It considers reversing the segment between them and reconnects the edges in the alternative order. The exchange is applied only when it strictly shortens the total distance, after which scanning restarts. Improvement continues until no further exchange helps or the solver reaches its defensive processing limit. The result is therefore locally improved under two-edge exchanges, but that does not make it a guaranteed global optimum.
Google’s OR-Tools guide to the Traveling Salesperson Problem describes the same shortest-closed-route objective and cautions that practical solvers may return non-optimal results because routing problems are computationally difficult. If the distinction between a local optimum and a guaranteed optimum matters, see Does a Traveling Salesman Solver Find the Shortest Route? for a fuller explanation.
Where the coordinate tour is useful
The tool is most valuable when straight-line geometry is exactly what you want to study. Appropriate uses include:
- learning how nearest-neighbor construction and 2-opt affect a tour;
- exploring how point order affects spatial sequencing;
- planning an approximate inspection sequence on a local coordinate system;
- creating reproducible test fixtures for algorithm comparisons; and
- studying route geometry when no road network or travel-time information is needed.
The output can also reveal a compact point order on a simple plane, but its total distance remains a coordinate measure. It should not be used to set dispatch commitments, estimate arrival times, guide a vehicle around physical barriers, or support safety-critical decisions. For those tasks, use a validated routing workflow based on real network data and independently verify the result.
Checks to make before copying the result
A careful review helps prevent a valid geometric calculation from being mistaken for a road-ready instruction. Before using the copied sequence:
- Confirm that every named point appears once and that the route closes at the first row.
- Check that the x and y axes share a consistent scale and that the units match the quantity you intend to compare.
- Compare the nearest-neighbor distance with the improved distance to see whether 2-opt found a meaningful reduction.
- Inspect each straight segment rather than assuming it is physically traversable.
- Try more than one starting location when route quality matters, then compare both distance and sequence.
- Remember that the displayed pass count makes the heuristic visible but does not certify global optimality.
If those checks expose a mismatch between the route and real travel conditions, preserve the coordinate calculation as an educational result and move the operational task to a system that accepts an actual road distance or travel-time matrix together with the necessary constraints.
Choose a road-aware workflow for real travel
Real route planning needs information the coordinate solver does not have: usable connections, legal direction, travel speeds, current or forecast traffic, obstacles, time windows, vehicle limits, and assignments for each driver. A straight segment may cross an unmapped barrier, a one-way restriction may invalidate the suggested order, and the geometrically shortest loop may create an unnecessarily long road journey. When those factors affect the outcome, use a validated routing service or solver and independently check the route. The Traveling Salesman Solver is most accurate as what it explicitly is: an inspectable, deterministic approximation of a closed Euclidean tour through a flat set of named points.