function bfs(graph, start):

   visited = {start}     # without this set, cycles cause infinite loo
 ps
   queue = [start]
   while queue:
      node = queue.remove_first()
      for neighbor in graph[node]:
        if neighbor not in visited:
           visited.add(neighbor)

           queue.append(neighbor)
