Ticket #10899: trac_10899_lex_BFS_repair.3.patch

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

    # HG changeset patch
    # User Lukas Lansky <lansky@kam.mff.cuni.cz>
    # Date 1326300449 0
    # Node ID 12897d8f8bada5f120d8ca7b846bc08d3081bb80
    # 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  
    96569656            Subgraph of (Petersen graph): Graph on 5 vertices
    96579657            sage: hole.is_isomorphic(graphs.CycleGraph(5))
    96589658            True
     9659
     9660        TESTS:
     9661
     9662        This shouldn't fail (trac 10899)::
     9663
     9664            sage: Graph(1).is_chordal()
     9665            True
     9666            sage: for g in graphs(5):
     9667            ...     try:
     9668            ...         forget = g.is_chordal()
     9669            ...     except:
     9670            ...         print("Oh no.")
    96599671   
    96609672        REFERENCES:
    96619673   
     
    1177811790            sage: all([g.subgraph(g.neighbors(v)).is_clique() for v in leaves])
    1177911791            True
    1178011792
     11793        TESTS:
     11794
     11795        There were some problems with the following call in the past (trac 10899) -- now
     11796        it should be fine::
     11797
     11798            sage: Graph(1).lex_BFS(tree=True)
     11799            ([0], Digraph on 1 vertex)
     11800
    1178111801        """
    1178211802        id_inv = dict([(i,v) for (v,i) in zip(self.vertices(),range(self.order()))])
    1178311803        code = [[] for i in range(self.order())]
     
    1181411834        if tree:
    1181511835            from sage.graphs.digraph import DiGraph
    1181611836            g = DiGraph(sparse=True)
     11837            g.add_vertices(self.vertices())
    1181711838            edges = [(id_inv[i], id_inv[pred[i]]) for i in range(self.order()) if pred[i]!=-1]
    1181811839            g.add_edges(edges)
    1181911840            return value, g