Application of BFS