Graph Theory37 sections · 1633 units
Open in Course

The Ripple Effect

BFS Intuition

Drop a stone in water and watch the ripples spread. The water closest to the stone moves first. Then the next ring moves, then the next. Each ring is the same distance from the center. BFS works exactly like this. Start at node 11. First, visit all nodes that are 11 step away.

Then visit all nodes that are 22 steps away. Then 33 steps, and so on. By the time you reach a node, you have already visited all closer nodes. This guarantees the first path you find is the shortest path. The ripple pattern is the core observation behind BFS.