# 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 return g def traveling_salesman_problem(self, use_edge_labels = True, solver = None, constraint_generation = None, verbose = 0, verbose_constraints = False): def traveling_salesman_problem(self, use_edge_labels = False, solver = None, constraint_generation = None, verbose = 0, verbose_constraints = False): r""" Solves the traveling salesman problem (TSP) `1` - If set to ``True``, the weights are taken into account, and the circuit returned is the one minimizing the sum of the weights. - ``solver`` -- (default: ``None``) Specify a Linear Program (LP) solver to be used. If set to ``None``, the default one is used. For One easy way to change is is obviously to add to this graph the edges corresponding to a Hamiltonian cycle. If we do this by setting the cost of these new edges to `2`, while the others are set to `1`, we notice that not all the edges we added are used in the optimal solution :: ...       for u,v in graphs.CycleGraph(n).edges(labels = False): ...            if not g.has_edge(u,v): ...                g.add_edge(u,v,round(random(),5)) ...       v1 = g.traveling_salesman_problem(constraint_generation = False) ...       v2 = g.traveling_salesman_problem() ...       v1 = g.traveling_salesman_problem(constraint_generation = False, use_edge_labels = True) ...       v2 = g.traveling_salesman_problem(use_edge_labels = True) ...       c1 = sum(map(itemgetter(2), v1.edges())) ...       c2 = sum(map(itemgetter(2), v2.edges())) ...       if c1 != c2: ...       for u,v in digraphs.Circuit(n).edges(labels = False): ...            if not g.has_edge(u,v): ...                g.add_edge(u,v,round(random(),5)) ...       v2 = g.traveling_salesman_problem() ...       v1 = g.traveling_salesman_problem(constraint_generation = False) ...       v2 = g.traveling_salesman_problem(use_edge_labels = True) ...       v1 = g.traveling_salesman_problem(constraint_generation = False, use_edge_labels = True) ...       c1 = sum(map(itemgetter(2), v1.edges())) ...       c2 = sum(map(itemgetter(2), v2.edges())) ...       if c1 != c2: