Ticket #10899: trac_10899_lex_BFS_repair.2.patch

File trac_10899_lex_BFS_repair.2.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 1326227673 0
    # Node ID 28d292c873c766a96215045ac4ff930c1d717852
    # 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        TESTS:
     11782
     11783        There were some problems with the following call in the past (trac 10899) -- now
     11784        it should be fine::
     11785
     11786            sage: Graph(1).lex_BFS(tree=True)
     11787            ([0], Digraph on 1 vertex)
     11788
    1178111789        """
    1178211790        id_inv = dict([(i,v) for (v,i) in zip(self.vertices(),range(self.order()))])
    1178311791        code = [[] for i in range(self.order())]
     
    1181411822        if tree:
    1181511823            from sage.graphs.digraph import DiGraph
    1181611824            g = DiGraph(sparse=True)
     11825            g.add_vertices(self.vertices())
    1181711826            edges = [(id_inv[i], id_inv[pred[i]]) for i in range(self.order()) if pred[i]!=-1]
    1181811827            g.add_edges(edges)
    1181911828            return value, g