Shortest City Tours
|
Run the code to get a list of the capitals of Africa. Try other regions, like “northern europe” or “the caribbean”:
1.
In[]:=
Get the geographic positions of the capitals. Try getting other properties, like "Population" or "Elevation":
2.
positions=EntityValue,"Position"
In[]:=
Find the order of capitals that gives the shortest route:
Note: run the code in the previous step first.
3.
tour=Last[FindShortestTour[positions]]
In[]:=
Show the order of the capitals along the shortest route:
Note: run the code in the previous step first.
4.
In[]:=
Make a map of the shortest tour:
5.
GeoGraphics[{Thick,Red,Line[positions[[tour]]]}]
In[]:=
Share It—Make a website that shows the shortest route through cities that you specify:
6.