Breadth-First Search ( or Tra­ver­sal) in a Graph is quite similar to Binary Tree. Click here to read about BFS in Binary Tree.
For Graph as well we will use the Queue for performing the BFS.
We will use the boolean to keep a track of the nodes because unlike tree during traversal we might keep moving into the circles by visiting same nodes repeatedly.
In our example we are using adjacency List for the Graph Representation.