next up previous
Next: October 16 Up: October 11 Previous: Depth-first search (DFS)


Breadth-first search

Breadth-first search means we visit all of vertex $ v$'s neighbours before we visit the neighbours' neighbours. One way to achieve this is to add all of $ v$'s neighbours to a queue, and then visit each element of the queue(adding that element's neighbours to the tail of the queue) in FIFO order. There is pseudocode for this algorithm in the Course readings that numbers each vertex with a unique number according to when it is visited (as does the Readings' DFS algorithm).



Danny Heap 2002-12-16