Ticket #9230: trac_9230.patch

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

    # 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  
    37153715
    37163716        p = MixedIntegerLinearProgram(maximization = False)
    37173717
    3718 
    37193718        f = p.new_variable()
    37203719        r = p.new_variable()
    37213720
    3722 
    3723 
    37243721        # If the graph has multiple edges
    37253722        if self.has_multiple_edges():
    37263723            g = self.copy()
     
    37373734                    # the weights of the parallel edges
    37383735
    37393736                    #  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)]
    37413738
    37423739                g.add_edges([(u,v) for (u,v),l in e.iteritems()])
    37433740
     
    38073804                p.add_constraint( sum([ r[(u,v)] for u in g.neighbors(v)]),max = 1-eps)
    38083805
    38093806
    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
    38113808
    38123809        if weighted:
    38133810            p.set_objective( sum([ weight(u,v)*E(u,v) for u,v in g.edges(labels=None)]) )