Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def bfs(self, start_vert):
- q = [start_vert]
- visited = set()
- while q:
- cur_vert = q.pop()
- if cur_vert in visited:
- continue
- visited.add(cur_vert)
- print(cur_vert)
- for vertex in self.graph_dict[cur_vert]:
- q.insert(0, vertex)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement