def bfs_tree(G, source, reverse=False):
 T = nx.DiGraph()
 T.add_node(source)
 T.add_edges_from(bfs_edges(G, source, reverse=reverse))
 return T

def bfs_tree ( G , source , reverse = False ) : T = nx . DiGraph ( ) T . add_node ( source ) T . add_edges_from ( bfs_edges ( G , source , reverse = reverse ) ) return T
return an oriented tree constructed from of a breadth-first-search starting at source .