Mathematica > Mathematics and Algorithms > Optimization >

FindShortestTour

FindShortestTour[{e1, e2, ...}]
attempts to find an ordering of the ei that minimizes the total distance on a tour that visits all the ei once.
  • The following options can be given:
DistanceFunctionthe distance function to apply to pairs of objects
Methodthe method to use
  • The ei can be numbers or lists of numbers, in which case the default distance function used is EuclideanDistance.
  • If the ei are strings, the default distance function used is EditDistance.
  • For small numbers of points, FindShortestTour will usually find the shortest possible tour. For larger numbers of points it will normally find a tour whose length is at least close to the minimum.
Find the length and ordering of a shortest tour through six points in the plane:
In[1]:=
Click for copyable input
Out[1]=
 
Specify a list of points:
In[1]:=
Click for copyable input
In[2]:=
Click for copyable input
Out[2]=
Order the points according to the tour found:
In[3]:=
Click for copyable input
Out[3]=
Plot the tour:
In[4]:=
Click for copyable input
Out[4]=
New in 6
Ask a question about this page  |  Suggest an improvement  |  Leave a message for the team