Ticket #12944: trac_12944.patch

File trac_12944.patch, 2.9 KB (added by ncohen, 9 years ago)
  • sage/graphs/generic_graph.py

    # HG changeset patch
    # User Nathann Cohen <nathann.cohen@gmail.com>
    # Date 1336937880 -7200
    # Node ID 0edc05691270126760fea01d3d1e43871aa265dd
    # Parent  006283a0ed0c5793ce38580ec278d88b55228d0f
    Inconcistencies in the documentation of traveling_salesman_problem
    
    diff --git a/sage/graphs/generic_graph.py b/sage/graphs/generic_graph.py
    a b  
    50395039            return g
    50405040
    50415041
    5042     def traveling_salesman_problem(self, use_edge_labels = True, solver = None, constraint_generation = None, verbose = 0, verbose_constraints = False):
     5042    def traveling_salesman_problem(self, use_edge_labels = False, solver = None, constraint_generation = None, verbose = 0, verbose_constraints = False):
    50435043        r"""
    50445044        Solves the traveling salesman problem (TSP)
    50455045
     
    50595059                `1`
    50605060
    50615061              - If set to ``True``, the weights are taken into account, and the
     5062                circuit returned is the one minimizing the sum of the weights.
    50625063
    50635064        - ``solver`` -- (default: ``None``) Specify a Linear Program (LP)
    50645065          solver to be used. If set to ``None``, the default one is used. For
     
    51315132
    51325133        One easy way to change is is obviously to add to this graph the edges
    51335134        corresponding to a Hamiltonian cycle.
    5134      
     5135
    51355136        If we do this by setting the cost of these new edges to `2`, while the
    51365137        others are set to `1`, we notice that not all the edges we added are
    51375138        used in the optimal solution ::
     
    51745175            ...       for u,v in graphs.CycleGraph(n).edges(labels = False):
    51755176            ...            if not g.has_edge(u,v):
    51765177            ...                g.add_edge(u,v,round(random(),5))
    5177             ...       v1 = g.traveling_salesman_problem(constraint_generation = False)
    5178             ...       v2 = g.traveling_salesman_problem()
     5178            ...       v1 = g.traveling_salesman_problem(constraint_generation = False, use_edge_labels = True)
     5179            ...       v2 = g.traveling_salesman_problem(use_edge_labels = True)
    51795180            ...       c1 = sum(map(itemgetter(2), v1.edges()))
    51805181            ...       c2 = sum(map(itemgetter(2), v2.edges()))
    51815182            ...       if c1 != c2:
     
    51955196            ...       for u,v in digraphs.Circuit(n).edges(labels = False):
    51965197            ...            if not g.has_edge(u,v):
    51975198            ...                g.add_edge(u,v,round(random(),5))
    5198             ...       v2 = g.traveling_salesman_problem()
    5199             ...       v1 = g.traveling_salesman_problem(constraint_generation = False)
     5199            ...       v2 = g.traveling_salesman_problem(use_edge_labels = True)
     5200            ...       v1 = g.traveling_salesman_problem(constraint_generation = False, use_edge_labels = True)
    52005201            ...       c1 = sum(map(itemgetter(2), v1.edges()))
    52015202            ...       c2 = sum(map(itemgetter(2), v2.edges()))
    52025203            ...       if c1 != c2: