Skip to content

BFS enhancement with collections.deque (fix: #12857) #12882

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
fix: import location
  • Loading branch information
riokuma committed Aug 4, 2025
commit b1b970b510af83ce4600d0ac502e3c2e9f8637da
4 changes: 2 additions & 2 deletions graphs/breadth_first_search_shortest_path_2.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
python bfs_shortest_path.py
"""

from collections import deque

demo_graph = {
"A": ["B", "C", "E"],
"B": ["A", "D", "E"],
Expand All @@ -15,8 +17,6 @@
"G": ["C"],
}

from collections import deque


def bfs_shortest_path(graph: dict, start, goal) -> list[str]:
"""Find shortest path between `start` and `goal` nodes.
Expand Down