Code
Hub
Workspaces
Following
Trending
Connect
MCP
copy
Create free account
hub
/
github.com/subbarayudu-j/TheAlgorithms-Python
/ bfs
Function
bfs
Graphs/basic_graphs.py:89–98 ·
view source on GitHub ↗
(G, s)
Source
from the content-addressed store, hash-verified
87
88
89
def
bfs(G, s):
90
vis, Q = set([s]), deque([s])
91
print(s)
92
while
Q:
93
u = Q.popleft()
94
for
v in G[u]:
95
if
v not in vis:
96
vis.add(v)
97
Q.append(v)
98
print(v)
99
100
101
""
"
Callers
nothing calls this directly
Calls
1
add
Method · 0.80
Tested by
no test coverage detected