# HG changeset patch
# User Lukas Lansky <lansky@kam.mff.cuni.cz>
# Date 1323300509 0
# Node ID ab8257bf70c393d8eb46da8473257e0a0008dd58
# Parent 9e29a3d84c48c399daaf3920bcb8b17273a0e876
Trac 10899: lex_BFS returns the correct tree for a trivial graph
diff git a/sage/graphs/generic_graph.py b/sage/graphs/generic_graph.py
a

b


11778  11778  sage: all([g.subgraph(g.neighbors(v)).is_clique() for v in leaves]) 
11779  11779  True 
11780  11780  
 11781  There were some problems with the following call in the past  now 
 11782  it should be fine: 
 11783  
 11784  sage: Graph(1).lex_BFS(tree=True) 
 11785  ([0], Digraph on 1 vertex) 
 11786  
11781  11787  """ 
11782  11788  id_inv = dict([(i,v) for (v,i) in zip(self.vertices(),range(self.order()))]) 
11783  11789  code = [[] for i in range(self.order())] 
… 
… 

11814  11820  if tree: 
11815  11821  from sage.graphs.digraph import DiGraph 
11816  11822  g = DiGraph(sparse=True) 
 11823  g.add_vertices(self.vertices()) 
11817  11824  edges = [(id_inv[i], id_inv[pred[i]]) for i in range(self.order()) if pred[i]!=1] 
11818  11825  g.add_edges(edges) 
11819  11826  return value, g 