MCPcopy Index your code
hub / github.com/BeeBombshell/Python-DSA / bfs

Function bfs

Tree Data Structure/bfs.py:14–25  ·  view source on GitHub ↗
(visited, graph, node)

Source from the content-addressed store, hash-verified

12queue = [] #Initialize a queue
13
14def bfs(visited, graph, node):
15 visited.append(node)
16 queue.append(node)
17
18 while queue:
19 s = queue.pop(0)
20 print(s, end=" ")
21
22 for neighbour in graph[s]:
23 if neighbour not in visited:
24 visited.append(neighbour)
25 queue.append(neighbour)
26
27# Driver Code
28bfs(visited, graph, 'A')

Callers 1

bfs.pyFile · 0.85

Calls 2

appendMethod · 0.80
popMethod · 0.80

Tested by

no test coverage detected