# 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


4836  4836  ... not lp.is_connected()): 
4837  4837  ... print("Error!") 
4838  4838  ... 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 
4839  4845  """ 
4840  4846  if use_edge_labels: 
4841  4847  algorithm = "MILP" 
… 
… 

4870  4876  if (self.order() <= 1 or 
4871  4877  (s is not None and ( 
4872  4878  (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 
4874  4880  (not self._directed and self.degree(s) == 0))) or 
4875  4881  (t is not None and ( 
4876  4882  (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 
4878  4884  (not self._directed and self.degree(t) == 0))) or 
4879  4885  (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)): 
4881  4887  if self._directed: 
4882  4888  from sage.graphs.all import DiGraph 
4883  4889  return [0, DiGraph()] if use_edge_labels else DiGraph() 