Wolfram Language

Open live version

Plan a City Tour

Find the shortest route through the largest cities in France.


code

positions = EntityValue[CityData[{Large, "France"}], "Position"]; tour = Last[FindShortestTour[positions]]; GeoGraphics[{Red, Thick, Line@positions[[tour]]}]

how it works

This example was live-coded at the Wolfram Research booth at SXSW, March 9, 2014.

Use data built in to the Wolfram Language to calculate the positions of the largest cities in France:

positions = EntityValue[CityData[{Large, "France"}], "Position"]

Find the shortest tour through those positions:

tour = Last[FindShortestTour[positions]]

Draw the tour on a map of France:

GeoGraphics[{Red, Thick, Line@positions[[tour]]}]