FindShortestTour

FindShortestTour[{e1, e2, ...}]
attempts to find an ordering of the that minimizes the total distance on a tour that visits all the once.

Details and OptionsDetails and Options

  • FindShortestTour returns a list of the form , where is the length of the tour found, and is the ordering.
  • The following options can be given:
  • DistanceFunctionthe distance function to apply to pairs of objects
    Methodthe method to use
  • The can be numbers or lists of numbers, in which case the default distance function used is EuclideanDistance.
  • If the 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.
  • Possible settings for the Method option include , , , , , , , , , , and .
  • For small numbers of points in the Euclidean space, an method is used, which is guaranteed to give the shortest tour.

ExamplesExamplesopen allclose all

Basic Examples (2)Basic Examples (2)

Find the length and ordering of the 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
New to Mathematica? Find your learning path »
Have a question? Ask support »