Skip to main content
Examonaut

Topic 3 · Lesson 1 of 3

Route inspection

Why odd vertices matter

A closed route that uses every arc exactly once exists only if every vertex has even degree (the network is Eulerian): each visit to a vertex uses one arc in and one arc out. If some vertices are odd, some arcs must be travelled twice. The route inspection algorithm finds the cheapest set of arcs to repeat.

The route inspection algorithm

  1. Find the vertices of odd degree. (There is always an even number of them.)
  2. List every way of pairing them up. Two odd vertices make one pairing; four odd vertices, say P, Q, R and S, make three: PQ + RS, PR + QS and PS + QR.
  3. For each pairing, find the shortest path between the vertices in each pair (by inspection or by Dijkstra's algorithm) and add the lengths.
  4. Choose the pairing with the smallest total. The arcs on those shortest paths are the ones repeated.
  5. The length of the shortest route is the total weight of the network plus the smallest total from step 4.

Repeating the arcs makes every vertex even, so a route exists that uses every arc (repeated ones twice) and returns to the start. Any start vertex gives the same length.

68597456ABCDEF

Worked example

Route inspection

The network above has total weight 50. Find the shortest closed route that travels every arc.

Show solution
  1. Degrees: A 2, B 3, C 3, D 3, E 3, F 2. The odd vertices are B, C, D and E.
  2. Pairings and shortest paths:
  • BC + DE =5+4=9= 5 + 4 = 9;
  • BD + CE =9+7=16= 9 + 7 = 16;
  • BE + CD =12+11=23= 12 + 11 = 23 (BE by B C E, CD by C E D).
  1. The smallest is 9: repeat BC and DE.
  2. Shortest route: 50+9=5950 + 9 = 59. One such route from A is A B C B D E D F E C A.

Try it: step through the route inspection algorithm on this network and others, including routes that start and finish at different vertices. The second part finds upper and lower bounds for the travelling salesperson problem.

Try it: simulation

Route inspection and the travelling salesperson

Loading the simulation…

Starting and finishing at different vertices

If the route may start and finish at different vertices, two odd vertices can be left odd: the route starts at one and finishes at the other. So you only repeat the shortest path between one pair of the odd vertices: the other two become the start and finish.

In the example, the six shortest paths between odd vertices are BC 5, BD 9, BE 12, CD 11, CE 7, DE 4. The shortest is DE =4= 4, so repeat DE, and start at B and finish at C (or the other way round). The length is 50+4=5450 + 4 = 54.

If the start is fixed at an odd vertex, the finish must be another odd vertex, chosen so that the path between the remaining two is as short as possible.

Counting visits

In the final route, the number of times the route passes through a vertex is half its degree after the repeated arcs are added (for the start and finish vertex of a closed route, count the start and end as one visit).

Practise this topic

Both are part of Premium.