A* Route Search
Algorithms · Sep 2025

A* Route Search

Live Demo

Watch the search

The same four algorithms from the Nashville router, running on a grid. Click and drag to draw walls or traffic (cost 5, like a slow road), drag the green and red endpoints, then pick an algorithm and press Visualize. Run several on the same map to compare them.

Dijkstra plus a Manhattan-distance heuristic, so it heads toward the goal. Optimal and weighted.

StartEndWallTraffic (cost 5)ExploredPath

Draw walls or traffic, drag the endpoints, then press Visualize.

A route planner built on raw OpenStreetMap data for downtown Nashville. The .osm XML is parsed into a directed road graph (one-way streets included) where every road class carries a speed, so edges cost travel time rather than distance. BFS, DFS, Dijkstra and A* all run on the same graph and the chosen route is exported as GPX to overlay in JOSM. The live demo above runs the same four algorithms on a grid so you can watch how each one explores.

Technical highlights

  • 01

    Parsed OpenStreetMap XML for downtown Nashville into an adjacency-list road graph of about 62,000 nodes and 80,000 directed segments, keeping only drivable highway types and honoring oneway=yes/-1.

  • 02

    Costed every edge as haversine distance divided by the road-class speed limit, and gave A* an admissible heuristic (straight-line distance at the top speed), so it returns the true fastest route.

  • 03

    On the same trip, A* found the identical 2.9-minute route as Dijkstra while expanding 2,458 nodes instead of 7,857 (about 3× fewer); BFS returned a slower fewest-segments route and DFS a 27-mile detour.

  • 04

    Wrote pytest tests that check one-way handling, unreachable targets, the haversine distance against a known city pair, and that A* matches Dijkstra's route cost on 50 random weighted graphs.

  • 05

    Built this page's interactive visualizer in React and TypeScript: draw walls and weighted traffic cells, drag the endpoints, and compare cells explored and path cost across all four algorithms on one map.