Be the first user to complete this post

Add to List 
BreadthFirst Search/Traversal in a Graph.
BreadthFirst Search ( or Traversal) in a Graph is quite similar to Binary Tree. Click here to read about BFS in Binary Tree.
Example:
What is BreadthFirst Search:
Breadthfirst search (BFS) is an algorithm for traversing or searching tree or graph data structures. It starts at the tree root and explores the neighbor nodes first, before moving to the next level neighbors. (Reference — Wiki)
MIT Open Courseware session on Breadthfirst search
Approach:
 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 trees during traversal we might keep moving into the circles by visiting the same nodes repeatedly.
 In our example, we are using an adjacency List for the Graph Representation.
Code:
Output:
Output: 0 2 1 3 4 5
Also Read: