A-Level · Graph Traversal

Breadth-first search <with a queue>

Same graph, same start node, same alphabetical convention — but a queue instead of a stack. Watch the search ripple outward from A one distance level at a time. The d value under each node is its distance from A.

Ad=0 Bd=1 Ld=2 Gd=3 Kd=4 Hd=3 Dd=4 Id=2 Fd=1 Cd=2 Ed=3 Jd=4 Queue unvisited in queue current processed

Adjacency list (Python dictionary)

graph = {

The current node's entry is highlighted. BFS reads its neighbours left to right — green = processed, amber = already waiting in the queue, white = newly discovered (enqueued now).

Adjacency matrix

Same information, matrix form: read the highlighted row left to right and enqueue every 1 whose column is still white.

Ready. All nodes unvisited, queue empty.
Dequeue (visit) order: —
Distance from A: —
1 step/s
Step 0 / 13

Keyboard: ← → to step  ·  Space to play/pause  ·  R to reset