Skip to content

Commit

Permalink
added note for the triangle inequality case in TSP (#6995)
Browse files Browse the repository at this point in the history
Co-authored-by: Ross Barnowski <rossbar@berkeley.edu>
  • Loading branch information
Schefflera-Arboricola and rossbar committed Nov 9, 2023
1 parent 6b3f7bb commit e962608
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion networkx/algorithms/approximation/traveling_salesman.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,10 @@ def traveling_salesman_problem(G, weight="weight", nodes=None, cycle=True, metho
the biggest weight edge is removed to make a Hamiltonian path.
Then each edge on the new complete graph used for that analysis is
replaced by the shortest_path between those nodes on the original graph.
If the input graph `G` includes edges with weights that do not adhere to
the triangle inequality, such as when `G` is not a complete graph (i.e
length of non-existent edges is infinity), then the returned path may
contain some repeating nodes (other than the starting node).
Parameters
----------
Expand Down Expand Up @@ -265,7 +269,6 @@ def traveling_salesman_problem(G, weight="weight", nodes=None, cycle=True, metho
List of nodes in `G` along a path with an approximation of the minimal
path through `nodes`.
Raises
------
NetworkXError
Expand Down

0 comments on commit e962608

Please sign in to comment.