MCPcopy Index your code
hub / github.com/subbarayudu-j/TheAlgorithms-Python / bfs

Function bfs

Graphs/BFS.py:20–29  ·  view source on GitHub ↗
(graph, start)

Source from the content-addressed store, hash-verified

18
19
20def bfs(graph, start):
21 explored, queue = set(), [start] # collections.deque([start])
22 explored.add(start)
23 while queue:
24 v = queue.pop(0) # queue.popleft()
25 for w in graph[v]:
26 if w not in explored:
27 explored.add(w)
28 queue.append(w)
29 return explored
30
31
32G = {'A': ['B', 'C'],

Callers 1

BFS.pyFile · 0.70

Calls 2

addMethod · 0.80
popMethod · 0.45

Tested by

no test coverage detected