Data Structure and Algorithms - BFS Graphs
Data Structure and Algorithms - BFS Graphs
Traversal
Breadth First Search (BFS) algorithm traverses a graph in a
breadthward motion and uses a queue to remember to get the
next vertex to start a search, when a dead end occurs in any
iteration.
We start from
visiting S (starting
2
node), and mark it as
visited.
We then see an
unvisited adjacent
node from S. In this
example, we have
3 three nodes but
alphabetically we
choose A, mark it as
visited and enqueue
it.
From A we have D as
unvisited adjacent
7 node. We mark it as
visited and enqueue
it.