frontier = Queue()frontier.put(start)visited = {}visited[start] = Truewhile not frontier.empty(): current = frontier.get() for next in graph.neighbors(current): if next not in visited: frontier.put(next) visited[next] = True
frontier = Queue()frontier.put(start)came_from = {}came_from[start] = Nonewhile not frontier.empty(): current = frontier.get() for next in graph.neighbors(current): if next not in came_from: frontier.put(next) came_from[next] = current
frontier = Queue()frontier.put(start)distance = {}distance[start] = 0while not frontier.empty(): current = frontier.get() for next in graph.neighbors(current): if next not in distance: frontier.put(next) distance[next] = 1 + distance[current]