[prev] 22 [next]

Breadth-first Search

Basic approach to breadth-first search (BFS):
  • visit and mark current vertex
  • visit all neighbours of current vertex
  • then consider neighbours of neighbours
Notes:
  • tricky to describe recursively
  • a minor variation on non-recursive DFS search works
    ⇒ switch the stack for a queue