Learn · Pathfinding Visualizer

Watch pathfinding algorithms search a real city.

Most pathfinding demos run on a grid of squares. This one runs on a street network – one-way streets, bridges, a river in the way – in a full 3D city. Pick an algorithm, pick a trip, and watch every decision it makes.

Pathfinding Visualizer on a procedurally generated 3D city (seed 99)
Free · in your browser AlgorithmsA*BFSDFSDijkstraGreedyBeamInteractive

From a question to a route

  1. Pick a situation

    A taxi to the station, an ambulance across town, a tourist wandering to a landmark – each is a real trip between real places in the city.

  2. Pick an algorithm

    A*, Dijkstra, two-way Dijkstra, greedy best-first, BFS, DFS, weighted A* or beam search – or click any two junctions for your own trip.

  3. Step through it

    Play, pause and scrub the timeline. Every checked junction lights up, and the inspector shows its g, h and f costs and why it was chosen next.

  4. Race them

    Compare runs several algorithms side by side in their own lanes on the same streets, then sums up who checked the fewest junctions for the shortest route.

Why A* beats Dijkstra – and when it doesn't

Dijkstra expands evenly in every direction until it reaches the goal, so it always finds the shortest route but checks a lot of the city. A* adds a straight-line estimate of the remaining distance and heads for the goal – the same shortest route with far fewer checks. Greedy best-first trusts the estimate alone and is fast but can be fooled by a river with no bridge.

BFS finds the route with the fewest streets, not the shortest distance; DFS finds a route, often a ridiculous one. Weighted A* trades a little length for speed, beam search keeps only the three best candidates and can give up. The panel shows the real search code next to the animation, so you can read exactly what each step does.

Pathfinding Visualizer at a glance

Algorithms
A*, Dijkstra, two-way Dijkstra, greedy, BFS, DFS, weighted A*, beam
Graph
The real street network of a generated city, one-way streets included
Share
Links open the same situation, algorithm and comparison