Skip to content
Prev Previous commit
Next Next commit
Update graphs/bfs.py
Co-authored-by: Christian Clauss <cclauss@me.com>
  • Loading branch information
wuyudi and cclauss authored Jun 25, 2020
commit 76e680ff2080b0e29735cce118dd226a8bf2eee0
3 changes: 2 additions & 1 deletion graphs/bfs.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ def breadth_first_search(graph: Dict, start: str) -> Set[int]:
>>> ''.join(sorted(bfs(G, 'A')))
'ABCDEF'
"""
explored, queue = set(start), [start] # collections.deque([start])
explored = {start}
queue = [start]
while queue:
v = queue.pop(0) # queue.popleft()
for w in graph[v]:
Expand Down