add BFS algorithm