New in Wolfram
Mathematica
8: Graph & Network Analysis
◄
previous
|
next
►
Application Areas
Trip Planning
Plan a trip in the London Underground.
In[1]:=
X
h = subwayLineChangeGraph[g, FindShortestPath[g, "Arsenal", "Alperton"]]
In[2]:=
X
presentTrip[p_List] := Join[{"Take " <> p[[2, 2]] <> " from " <> p[[2, 1]] <> "."}, Table["Change from " <> uv[[1, 2]] <> " to " <> uv[[2, 2]] <> " at " <> uv[[1, 1]] <> ".", {uv, Select[{p[[2 ;; -3]], p[[3 ;; -2]]}\[Transpose], #[[1, 1]] == #[[2, 1]] &]}], {"Get off " <> p[[-2, 2]] <> " at " <> p[[-2, 1]] <> "."}] // TableForm // Style[#, FontFamily -> "Verdana"] & presentTrip[FindShortestPath[h, "Arsenal", "Alperton"]]
Out[2]=