Shortest path
Draw walls and watch algorithms find the way.
Algorithm
StartFinishWallVisitedShortest path
Start when ready · visited 0 cellsHow it works +
Choose a tool, then click or drag to place walls, start or finish. Editing the map or changing the algorithm clears the search while preserving the map.
Moves are up, down, left or right, each costing 1. BFS searches by layers. Dijkstra searches by accumulated cost, so it behaves similarly here. A* adds Manhattan distance to prioritize promising routes.
All three find a path with the fewest steps when one exists, though explored cells and routes may differ. Random walls may block all routes. Yellow marks the final path. Playback speed is for illustration, not runtime measurement. Maps stay in your browser.