Adding algorithm for solving BFS.