Checkpoint 1
Which node is settled next?
The start node has already been settled. These are the current tentative distances:
Search algorithms
The visualiser takes most of the page so you can focus on the network. Step through the algorithm, watch tentative distances update, and see why the nearest unsettled node becomes fixed.
Think first
Checkpoint 1
The start node has already been settled. These are the current tentative distances:
Checkpoint 2
Current node has distance 5. An edge of weight 3 leads to a node whose current tentative distance is 9.
Weighted graph
Start A to target G
Complexity and scale
The algorithm is not just drawing a path. It repeatedly chooses the next unsettled vertex and checks edges. As the number of vertices and edges grows, the amount of bookkeeping grows too.
This is where algorithmic thinking matters: the same mathematical idea can feel quick on a classroom graph and painfully expensive on a road network, game map or web-scale graph.
Edges
569
Simple scan
6.4k
Priority queue
4.1k
This simplified graph compares two common implementation models as the graph grows.
It is reliable when all edge weights are non-negative. It gives the shortest distance from one start node to every reachable node, not just one target, and the logic is beautifully inspectable.
It explores outward without knowing where the target is. On large networks this can waste effort, especially if you only care about one destination. It also cannot handle negative edge weights.
In many real pathfinding problems, we use a goal-directed method instead. A* adds a heuristic: an estimate of the remaining distance to the target.
Investigate A*Use a priority queue so the smallest tentative distance is found more efficiently.
Stop early when the target has been settled if you only need one route.
Use A* when you have a useful estimate of distance to the goal.
Use specialised routing methods on huge road networks where preprocessing is worthwhile.