def bfs_edges(G, source, reverse=False):
 if (reverse and G.is_directed()):
  successors = G.predecessors
 else:
  successors = G.neighbors
 for e in generic_bfs_edges(G, source, successors):
  (yield e)

def bfs_edges ( G , source , reverse = False ) : if ( reverse and G . is_directed ( ) ) : successors = G . predecessors else : successors = G . neighbors for e in generic_bfs_edges ( G , source , successors ) : ( yield e )
produce edges in a breadth-first-search starting at source .