BFS implementation on graph