SHARE
TWEET

Untitled

a guest Sep 21st, 2019 109 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.     def bfs(self, start_vert):
  2.         q = [start_vert]
  3.         visited = set()
  4.  
  5.         while q:
  6.             cur_vert = q.pop()
  7.  
  8.             if cur_vert in visited:
  9.                 continue
  10.                
  11.             visited.add(cur_vert)
  12.             print(cur_vert)
  13.  
  14.             for vertex in self.graph_dict[cur_vert]:
  15.                 q.insert(0, vertex)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top