Pathfinding Visualizer

Draw walls and watch A*, Dijkstra, BFS and more find a path, or race two.

Result

Examples

Algorithms

Questions

What is the difference between A* and Dijkstra?

Both find the cheapest path. Dijkstra spreads out evenly by cost in every direction. A* adds a guess of the distance left to the end, so it leans towards the goal and usually explores far fewer cells. Race them to see it.

Why does breadth-first search pick an expensive path?

BFS counts steps, not cost, so it finds the path with the fewest moves even if it crosses costly cells. Dijkstra and A* add up the costs instead.

Why is greedy best-first so fast but sometimes wrong?

It always moves to the cell that looks closest to the end and never reconsiders. That is quick in open space, but a wall in the way can send it on a long detour.

How do I draw?

Click or drag to draw walls, and drag S or E to move them. Pick "Cost 5" as the brush to paint expensive cells. Or press Edit as text and type the grid: S start, E end, # wall, . open, 2-9 cost.

Can I share a maze?

Yes. Share copies a link with the grid in it, and the page opens with that grid.