Ticket #10899: trac_10899_lex_BFS_repair.patch

File trac_10899_lex_BFS_repair.patch, 1.2 KB (added by brunellus, 9 years ago)
  • sage/graphs/generic_graph.py

    # 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  
    1177811778            sage: all([g.subgraph(g.neighbors(v)).is_clique() for v in leaves])
    1177911779            True
    1178011780
     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
    1178111787        """
    1178211788        id_inv = dict([(i,v) for (v,i) in zip(self.vertices(),range(self.order()))])
    1178311789        code = [[] for i in range(self.order())]
     
    1181411820        if tree:
    1181511821            from sage.graphs.digraph import DiGraph
    1181611822            g = DiGraph(sparse=True)
     11823            g.add_vertices(self.vertices())
    1181711824            edges = [(id_inv[i], id_inv[pred[i]]) for i in range(self.order()) if pred[i]!=-1]
    1181811825            g.add_edges(edges)
    1181911826            return value, g