The Routing Problem

Given a graph, perhaps derived from a map of roads or walkways, a natural problem is to find the shortest cycle in the graph that visits all vertices. This is called the routing problem. A closely related problem is to find the shortest Hamiltonian cycle, where the path visits all vertices but does not repeat any edges. These two problems sound identical, but they are not, since it can happen that backtracking along an edge can lead to a shorter overall route. All distances here are Euclidean distances; the blue cycle is the shortest Hamiltonian tour, and the yellow cycle is the shortest solution to the routing problem.


  • [Snapshot]
  • [Snapshot]
  • [Snapshot]


The cases of 30 and 35 vertices show situations where the routing problem has a solution that is better than the shortest Hamiltonian tour. The optimal tours were found by combining integer linear programming with some cycle-breaking, as described in [1] and the Demonstraton "Finding the Shortest Traveling Salesman Tour". A nonedge is an edge in the complement of the graph. For the routing problem, the distance function for nonedges is defined by the shortest-path distance in the graph; any nonedge appearing in the optimal solution is replaced by the corresponding shortest path along edges. It is this replacement that leads to repeated traversal of the same edges.
[1] S. Wagon, Mathematica in Action, New York: Springer-Verlag, 2010 Chapter 13.
    • Share:

Embed Interactive Demonstration New!

Just copy and paste this snippet of JavaScript code into your website or blog to put the live Demonstration on your site. More details »

Files require Wolfram CDF Player or Mathematica.

Mathematica »
The #1 tool for creating Demonstrations
and anything technical.
Wolfram|Alpha »
Explore anything with the first
computational knowledge engine.
MathWorld »
The web's most extensive
mathematics resource.
Course Assistant Apps »
An app for every course—
right in the palm of your hand.
Wolfram Blog »
Read our views on math,
science, and technology.
Computable Document Format »
The format that makes Demonstrations
(and any information) easy to share and interact with.
STEM Initiative »
Programs & resources for
educators, schools & students.
Computerbasedmath.org »
Join the initiative for modernizing
math education.
Powered by Wolfram Mathematica © 2014 Wolfram Demonstrations Project & Contributors  |  Terms of Use  |  Privacy Policy  |  RSS Give us your feedback
Note: To run this Demonstration you need Mathematica 7+ or the free Mathematica Player 7EX
Download or upgrade to Mathematica Player 7EX
I already have Mathematica Player or Mathematica 7+