Loading algorithms…
Loading visualizer…
Best-first shortest path on a grid using f = g + h. Click cells to draw walls, set start/end, or change the heuristic.
A* Search is a best-first graph search algorithm that finds the shortest path from a start node to a goal node using a heuristic to guide which node to expand next. It is often faster than Dijkstra because it uses the heuristic to look "in the right direction."
g = 0 and compute f = g + h where h is the heuristic estimate to the goal.g via the current node. If it's better than any known g, update parent and f, then push to the open set.g(n) — exact cost paid so far from the start (like Dijkstra).h(n) — heuristic guess of remaining cost to the goal.f(n) = g(n) + h(n) — estimated total cost through n. A* always expands the node with the smallest f.💡 Optimality: A* returns the optimal (shortest) path when the heuristic is admissible — i.e., it never overestimates the true cost. All three heuristics on this page (Manhattan, Euclidean, Chebyshev) are admissible on a grid with unit-cost moves.
Cells discovered but not yet expanded. Ordered by f-score via a min-heap. Think of it as the "candidate" nodes.
Cells already dequeued and expanded. Their optimal g-score is final. A node moves from open → closed exactly once.
Click cells to draw walls, set start/goal, or change the heuristic · Use Random Walls to generate a maze · Step through to see how A* expands