def iterative_bfs(graph, start, path=[]):
  '''iterative breadth first search from start'''
  q=[start]
  while q:
    v=q.pop(0)
    if not v in path:
      path=path+[v]
      q=q+graph[v]
  return path
iterative breadth first search from start
recipes/Python/576723_dfs_and_bfs_graph_traversal/recipe-576723.py