def bfs(graph, start) visited = set() queue = dequeue(start) while queue: node = queue.popleft() if node is not in visited: visited.add(node) queue.extend(graph[node])