EXAMPLE 5 Applying the Sorted-Edges Algorithm

Applying the sorted-edges algorithm to the TSP in Figure 2.3 works as follows: First, the six weights on the edges listed in increasing order would be 300, 349, 425, 541, 562, and 774. Because the cheapest edge in this sorted list is 300, this is the first edge we select for the tour we are building. Next we add the edge with weight 349 to the tour. The next-cheapest edge would be 425, but using this edge together with those already selected would result in having three edges at a vertex (Figure 2.11a), which is not consistent with having a Hamiltonian circuit. Hence, we do not use this edge. The next-cheapest edge, 541, used together with the edges already selected, would create a circuit (see Figure 2.11b) that does not include all the vertices. Thus, this edge, too, would be skipped over. However, we are able to add the edges 562 and 774 without either creating a circuit shorter than one including all the vertices or having three edges at a vertex. Hence, the tour we arrive at is Chicago, St. Louis, Minneapolis, Cleveland, and Chicago. Again, this solution is not optimal because its length is 1985. Note that this algorithm, like the nearest-neighbor, is greedy.

image
Figure 2.11: Figure 2.11 (a) When three shortest edges are added in order of increasing distance, three edges at a vertex are selected, which is not allowed as part of a Hamiltonian circuit. (b) When the edges of distances 300, 349, and 541 are selected, a circuit that does not include all vertices results.