← all animations

SHORTEST PATH — DIJKSTRA & A*

Find the shortest path from A to H on a random weighted graph. Each step locks in the unvisited node with the lowest tentative cost; the table shows how distances and predecessors update.

Step: 0  ·  Status: ready  ·  Path: –  ·  Cost: –
start (A) goal (H) just locked-in visited shortest path
Each row shows the state after picking one node. The picked cell is green; previously-visited cells are blue. Cells read cost (predecessor); ∞ means unreachable so far. For A*, the heading also shows h (straight-line distance) for each node and an f = g + h column.