A* Search
Best-first search ordered by g + h, distance so far plus an admissible estimate of what is left; optimal and far more focused than BFS.
Expand (0,0), g = 0, f = 9. New neighbours (1,0), (0,1) get g = 1 and f = 9, 9. Frontier: 2.
What you will see
On a grid, the explored region leans toward the goal instead of growing in a circle; f = g + h shown per cell.
Cost
| Best | O(E) |
|---|---|
| Average | depends on heuristic |
| Worst | O(E log V) |
| Space | O(V) |
Worst case equals Dijkstra with a zero heuristic.
How you work with it here
play it through, step one change at a time, scrub to any step, run it on your own input, predict what happens next, try operations in any order.
Screen readers: Vertices announce name, tentative distance and parent; each step announces the relaxation and whether it improved a distance.
Reduced motion: Distance updates change the label with a crossfade instead of radiating from the edge.