Ticket #13019: trac_13019.patch

File trac_13019.patch, 1.7 KB (added by ncohen, 11 years ago)
  • sage/graphs/generic_graph.py

    # HG changeset patch
    # User Nathann Cohen <nathann.cohen@gmail.com>
    # Date 1338231673 -7200
    # Node ID cd9ac622d514806b11cb836d92e5a1e4456541fc
    # Parent  5299aa8232d7acb68d37162f5bef2068c8a68d54
    Bugfix in GenericGraph.longest_path
    
    diff --git a/sage/graphs/generic_graph.py b/sage/graphs/generic_graph.py
    a b  
    48364836            ...           not lp.is_connected()):
    48374837            ...           print("Error!")
    48384838            ...           break
     4839
     4840        :trac:`13019`::
     4841
     4842            sage: g = graphs.CompleteGraph(5).to_directed()
     4843            sage: g.longest_path(s=1,t=2)
     4844            Subgraph of (Complete graph): Digraph on 5 vertices
    48394845        """
    48404846        if use_edge_labels:
    48414847            algorithm = "MILP"
     
    48704876        if (self.order() <= 1 or
    48714877            (s is not None and (
    48724878                    (s not in self) or
    4873                     (self._directed and self.degree_out(s) == 0) or
     4879                    (self._directed and self.out_degree(s) == 0) or
    48744880                    (not self._directed and self.degree(s) == 0))) or
    48754881            (t is not None and (
    48764882                    (t not in self) or
    4877                     (self._directed and self.degree_in(t) == 0) or
     4883                    (self._directed and self.in_degree(t) == 0) or
    48784884                    (not self._directed and self.degree(t) == 0))) or
    48794885            (self._directed and (s is not None) and (t is not None) and
    4880              len(self.shortest_path(s, t) == 0))):
     4886             len(self.shortest_path(s, t)) == 0)):
    48814887            if self._directed:
    48824888                from sage.graphs.all import DiGraph
    48834889                return [0, DiGraph()] if use_edge_labels else DiGraph()