Figure 4:
Breadth-first search.