Add BFS algorithm