# HG changeset patch
# User Nathann Cohen <nathann.cohen@gmail.com>
# Date 1276380631 7200
# Node ID 7e3018d36e85b1b50e4424b8c07f607dbd8dd298
# Parent 556bb66e4c6dbb92a4ee37c1750d82a5c6298eeb
trac 9230  Broken docstrings in Graph.traveling_salesman_poblem
diff r 556bb66e4c6d r 7e3018d36e85 sage/graphs/generic_graph.py
a

b


3715  3715  
3716  3716  p = MixedIntegerLinearProgram(maximization = False) 
3717  3717  
3718   
3719  3718  f = p.new_variable() 
3720  3719  r = p.new_variable() 
3721  3720  
3722   
3723   
3724  3721  # If the graph has multiple edges 
3725  3722  if self.has_multiple_edges(): 
3726  3723  g = self.copy() 
… 
… 

3737  3734  # the weights of the parallel edges 
3738  3735  
3739  3736  # new value *if* ( none other *or* new==None and last > 1 *else* change nothing 
3740   e[(u,v)] = l if (not e.has_key((u,v)) or ( l is None and e[(u,v)] > 1 )) else e[(u,v)] 
 3737  e[(u,v)] = l if (not e.has_key((u,v)) or ( (l is None or l == {}) and e[(u,v)] > 1 )) else e[(u,v)] 
3741  3738  
3742  3739  g.add_edges([(u,v) for (u,v),l in e.iteritems()]) 
3743  3740  
… 
… 

3807  3804  p.add_constraint( sum([ r[(u,v)] for u in g.neighbors(v)]),max = 1eps) 
3808  3805  
3809  3806  
3810   weight = lambda u,v : g.edge_label(u,v) if g.edge_label(u,v) is not None else 1 
 3807  weight = lambda u,v : g.edge_label(u,v) if (g.edge_label(u,v) is not None and g.edge_label(u,v) != {}) else 1 
3811  3808  
3812  3809  if weighted: 
3813  3810  p.set_objective( sum([ weight(u,v)*E(u,v) for u,v in g.edges(labels=None)]) ) 