What the pathfinding visualizer shows
Draw walls on a grid, drop a start and end point, and watch BFS, DFS, Dijkstra, A*, and Greedy best-first search explore their way toward the target. The cells light up in the order each algorithm visits them, so you can literally see which ones waste effort and which head straight for the goal.
How the algorithms differ
BFS explores in rings and guarantees the shortest path on an unweighted grid. DFS plunges down one direction first — fast, but it does not guarantee the shortest route. Dijkstra generalizes BFS to weighted graphs. A* adds a heuristic (an estimate of distance to the goal) so it expands far fewer cells than Dijkstra while still finding the optimal path. Greedy trusts the heuristic alone — fast but not always optimal.
Why it matters
Pathfinding powers game AI, GPS routing, robotics, and network packet routing. A* in particular is the workhorse behind most game and map navigation. Explore the underlying structure in the graph visualizer, or see algorithm speed differences in the sorting visualizer.
Frequently asked questions
BFS vs Dijkstra vs A* — which should I use?
Unweighted grid: BFS. Weighted graph with no distance estimate: Dijkstra. Weighted graph where you can estimate distance to the goal: A* — usually the fastest optimal choice.
Why is A* faster than Dijkstra?
Dijkstra expands outward in all directions; A*'s heuristic biases the search toward the goal, so it examines far fewer cells while still returning the shortest path.
Does DFS find the shortest path?
No. DFS finds a path but not necessarily the shortest — use BFS, Dijkstra, or A* for that.