Use matrix(matrix representation of graphs) and queue(BFS), will be a better option..
1st by using matrix and queue get the proper sequence of displaying the nodes and then display the value......