Download as pdf or txt
Download as pdf or txt
You are on page 1of 12

On the Relation between the Traveling-Salesman and the Longest-Path Problems

Author(s): William W. Hardgrave and George L. Nemhauser


Source: Operations Research, Vol. 10, No. 5 (Sep. - Oct., 1962), pp. 647-657
Published by: INFORMS
Stable URL: https://www.jstor.org/stable/167886
Accessed: 12-04-2019 03:57 UTC

REFERENCES
Linked references are available on JSTOR for this article:
https://www.jstor.org/stable/167886?seq=1&cid=pdf-reference#references_tab_contents
You may need to log in to JSTOR to access the linked references.

JSTOR is a not-for-profit service that helps scholars, researchers, and students discover, use, and build upon a wide
range of content in a trusted digital archive. We use information technology and tools to increase productivity and
facilitate new forms of scholarship. For more information about JSTOR, please contact support@jstor.org.

Your use of the JSTOR archive indicates your acceptance of the Terms & Conditions of Use, available at
https://about.jstor.org/terms

INFORMS is collaborating with JSTOR to digitize, preserve and extend access to Operations
Research

This content downloaded from 130.85.244.152 on Fri, 12 Apr 2019 03:57:09 UTC
All use subject to https://about.jstor.org/terms
ON THE RELATION BETWEEN THE TRAVELING-
SALESMAN AND THE LONGEST-PATH PROBLEMS

William W. Hardgrave

Bell Telephone Laboratories, Inc., Holmdel, N. J.

and

George L. Nemhauser
T'he Johns Hopkins University, Baltimore, Md.

(Received April 13, 1962)

The main result of this paper is that the traveling-salesman problem


is a special case of the longest-path problem. Two formulations of the
traveling-salesman problem are considered; the version in which the
salesman visits each city exactly once and the more general formulation
in which each city may be visited more than once. Both cases are re-
duced to the problem of finding the longest path between two nodes in a
finite, connected graph. The remainder of the paper is then devoted to
possible algorithms for the longest-path problem, since none presently
exist.

N0 GENERAL efficient algorithm has yet been found to solve the


traveling-salesman problem, although a great deal of effort has been
expended for such purposes.111 This paper presents a different approach to
its solution. The main result is that the traveling-salesman problem is a
special case of the longest-path problem; unfortunately no efficient compu-
tational scheme presently exists for the general longest-path problem
either. Tt is hoped that the longest-path problem will prove to be easier
than the traveling-salesman problem has been and consequently that this
approach will lead to an efficient algorithm for the traveling-salesman
problem.
The traveling-salesman problem can be formulated in the following
manner: Given a finite set {1, 2, ***, i, *, n} of nodes and the 'distances'
d(i,j) between every ordered pair (i,j), find a sequence of nodes
(i1, i2, * - *, in) such that:
1. every node appears in the sequence exactly once;
2. the total length E=nI? d(ik, ik+1) +d(i., i1) of the sequence is minimized .[2"41

Note that these requirements imply that the sequence is a cycle. A cycle
satisfying I whose length is finite will be called a feasible solution or a
feasible cycle, and a feasible cycle satisfying 2 will be called an optimal solu-
647

This content downloaded from 130.85.244.152 on Fri, 12 Apr 2019 03:57:09 UTC
All use subject to https://about.jstor.org/terms
648 William W. Hardgrave and George L. Nemhauser

tion or an optimal cycle. Alternatively one may relax 1 and only require
a tour solution. A feasible tour is such that its length is finite and each
node appears at least once in the sequence (i1, i2, ** *, im); a feasible tour
which minimizes the total length of the sequence will be called an optimal
tour. It will be shown that the tour version causes no conceptual diffi-
culty since it may be reduced to the problem of finding an optimal cycle,
although at the expense of possibly increasing the number of arcs in the
graph. However, it should be noted that the tour version, being a less re-
strictive problem, can in certain situations lead to a shorter length solution
(e.g., in Fig. 1 the optimal cycle in G has length 22, while the optimal tour
is of length 20).
The longest-path problem is similar to the well-known and frequently
solved shortest-route problem;E"0 the problem is to construct an efficient
algorithm for finding the longest path (i.e., a route containing no loops)
between two specified nodes of an arbitrary finite connected graph. For-
mally, given a finite set { 1, 2, ..*. *, i * *, n} of nodes, the distances d(i,j)
between every ordered pair (i,j), and two distinguished nodes, say nodes
1 and n, find a sequence (i1= 1, i2, * *, in=n) such that:
1. no node appears in the sequence more than once, i.e., the sequence is a path;
2. the total lengthEkI8-I d(ik, ik+l) of the path is maximized.
In both problems it is assumed that the distances satisfy d(i,j) ? 0 with
d(i,j) = 0 if i = j for all i and j, and that some of the d(i,j) may be arbi-
trarily large. The longest-path problem appears to be much more difficult
than the shortest-route problem but possibly easier than the traveling-
salesman problem.

RELATION BETWEEN THE LONGEST-PATH AND


TRAVELING-SALESMAN PROBLEMS

Cycle Solution
Suppose that we wish to solve the cycle version of the traveling-salesman
problem for a graph G that has the following properties: G is finite, con-
nected (but not necessarily complete), and has n nodes I 1, 2, ..., , ... , nl};
arcs will be denoted by ordered pairs of node indices and associated with
each arc (i,j) is a 'distance' d(i,j) such that d(i,j) >0 and d(i,j) =0 if i-=j.
For convenience, we shall specify one node, say node 1, as a starting point
and furthermore shall assume that at least one feasible cycle exists in G.
The result that the traveling-salesman problem can be embedded in the
longest-path problem will be established by showing that for every such
graph G there exists a corresponding graph L(G) such that any longest
path in L(G) corresponds to an optimal cycle in G. L(G) is constructed
directly from G in the following manner:

This content downloaded from 130.85.244.152 on Fri, 12 Apr 2019 03:57:09 UTC
All use subject to https://about.jstor.org/terms
The Longest-Path Problem 649

1. the nodes of L(G) are the nodes of G plus one additioiial node, denoted by 1';
2. the arcs of L(G) are the arcs of G except for arcs of the form (j,1),
plus (directed) arcs (j,i') if and only if there is an arc (j,I) in G;
3. the distances D(i,j) in L(G) are defined by

(0 if i =j,
D(i,j) =K-d (i,j) if i j and jH 1',
K -d(i,j) if i j and j = 1',

iLG) 2s (12423222521'.L(G)

3 ~~~~~~31

37~~~~~3
4 4 2335 35
8 31
37 37

8 44

31
6 8 3

Fig.l1. The construction of L(G) fromGC,with S=8+8+8+8+6~=38 and


K taken to be 39; the optimal cycle in G is (1,4,3,2,5) and the longest path
in L(G) is (1,4,3,2,5,1').

with K being a constant strictly greater than S, where S is the sum of the n greatest
d(i,j). From now on, path in L(G) will mean path between nodes 1 and 1' in L(G).

An example of the construction of L(G) from a particular graph G and of


the correspondence between the optimal cycle and the longest path is
shown in Fig. 1.
A formal proof of this relation follows.
LEMMA 1. Any longest path in L(G) contains n arcs. [Note that this im-
plies that such a path contains every node of L(G).]
Proof. Let Lk be the length of any path containing kc arcs, and let
m ? n-1. Then by the definition of K we have

max Lm,?mK _ (n-1)K=nK-K<nK-S? min L


so that any path with n arcs is longer than any path with m<n arcs. In
particular, any longest path has n arcs.

This content downloaded from 130.85.244.152 on Fri, 12 Apr 2019 03:57:09 UTC
All use subject to https://about.jstor.org/terms
650 William W. Hardgrave and George L. Nemhauser

It should be noted that if K < S the lemma is not necessarily true.


Figure 2 gives an example in which K = S permits a path with fewer than n
arcs to be a longest path. However in some cases K may be chosen
smaller than S, in particular when any subset of the n longest arcs form a
subeycle.
LEMMA 2. There is a one-to-one correspondence between feasible cycles in G
and paths containing n arcs in L(G).

K- / ~~-0 v

Fig. 2. An example of a graph l(G) for which Lemma 1 is false when


K is chosen so that K=5. In this graph, S=6; if we take K=~6 then the
length of the path P1= (1,2,3,4,5,1') is 30, and the length of P2=
(1,4,2,6,5,3,1') is also 30, contradicting the lemma..

Proof. Let (i1 = 1, i2, * ** in) be a feasible cycle in G; then the sequence
(i1==1,i2, **.,in,inl= 1') in L(G) is clearly a path containing n arcs.
Similarly, if (i1 = 1, i2, , in,i n= 1' ) iS a path in L(G) with n arcs, then
(i1= 1, i2, ***, in) iS a feasible cycle in G. This correspondence is clearly
one-to-one.
THEOREM 1. A path in L(G) is a longest path if and only if the correspondfing
cycle in G is an optimal cycle.
Proof. Let P1 be a longest path in L(G) and P2 any path containing
n arcs (but not a longest path), let L1 and L2 be the lengths of P1 and P2
respectively. By Lemma 1, Pi has n arcs and hence by Lemma 2 there
are two distinct feasible cycles C1 and C2 in G corresponding respectivr

This content downloaded from 130.85.244.152 on Fri, 12 Apr 2019 03:57:09 UTC
All use subject to https://about.jstor.org/terms
The Longest-Path Problem 651

P1 and P2. Then


Lk =nK- Jk d(i,j) (k= 1,2)
and so O<L1-L2= C2 d (i,j)-ZEl d (i,j).
Hence C1 is an optimal cycle.
Conversely, let C1 be an optimal cycle and C2 be any feasible cycle (but
not an optimal cycle), let P1 and P2 be respectively the corresponding paths
in L(G), and let L1 and L2 be the lengths of P1 and P2 respectively. Then

4~~~~~

I ~~~4 2

Fig. 3. The construction of GI for the graph G of Fig. 1; in this instance,


G' is symmetric so that are orientations are not shown. There are twelve
optimal cycles in G' and four optimal tours in G; the relation between
them is summarized in Table 1.

by Lemma 2 both P1 and P2 contain n arcs and by hypothesis Ecl d(i,j) <
ZC2 d(i,j) so that

Li=nK- Zcl d(i,j) >nK- C2 d(i,j) =L2,


and by Lemma 1, the longest path in L(G) contains n arcs. Hence Pi is
the longest path.
By virtue of Theorem 1, an algorithm for the longest-path problem will
solve the cycle version of the traveling-salesman problem since to find an
optimal cycle in G, we need only find a longest path in L(G).

Tour Solution

The tour formulation of the traveling-salesman problem will be reduced


to the cycle formulation in much the same way that the cycle formulation
was reduced to the longest-path problem. To solve the tour version for a
graph G, we will define another graph G' with the property that an optimal
tour in G corresponds to an optimal cycle in G'. The graph G' is con-

This content downloaded from 130.85.244.152 on Fri, 12 Apr 2019 03:57:09 UTC
All use subject to https://about.jstor.org/terms
652 William W. Hardgrave and George L. Nemnhauser

structed from G as follows:

1. the nodes of G' are the nodes of G;


2. in G', nodes i and j are joined by a (directed) arc (i,j) if and only if there is
in G a (directed) path { (i, k1), (k1, kQ), , (km,j) } between nodes i and j;
3. the lengths d'(i,j) in G' are the lengths of a shortest path in G between nodes
i and j.
It should be noted that if G contains a feasible tour, then G' contains a
feasible cycle so that in order to have a meaningful cycle version of the
traveling-salesman problem for G' it is sufficient to require only that G have
a feasible tour instead of the stronger condition that G have a feasible cycle.

TABLE I

OPTIMAL CYCLES IN G' AND THE CORRESPONDING OPTIMAL TOURS IN G (see Figs. i and 3).

Optimal cycles in G' Corresponding (optimal) tours in G

(I, 2, 5, 4, 3) (I, 3, 2, 5, 4, 3, I)
(IX 3, 2, 5, 4)

(I, 2, 5, 3, 4) (1, 3, 2, 5, 2, 3, 4, 3, I)
(I, 3, 5, 2, 4)
(I, 5, 2, 3, 4)
(I, 5, 2, 4, 3)

(I, 3, 4, 2, 5) (IX 3, 4, 3, 2, 5, I)
(I, 4, 3, 2, 5)

(I, 3, 4, 5, 2) (I, 3, 4, 3, 2, 5, 2, 3, I)
(I, 4, 2, 5, 3)
(I, 4, 3, 5, 2)
(I, 4, 5, 2, 3)

An example of the construction of G' for the graph G of Fig. 1 is given in


Fig. 3, and the relation between optimal cycles in G' and optimal tours in
G is summarized in Table I.
LEMMA 3. To any feasible cycle C in G' there corresponds a feasible tour T
in G such that the lengths of T and of C are equal.
Proof. Suppose that C== (i1 = 1, i2, *., in) is a cycle in G'; then the
corresponding tour in G is T= (i1= 1, Pl, i2, *.* * Pny i1+= 1) where
(ij, Pj, ij+1) is a shortest directed path in G between ij and ij+i. T is
clearly feasible and by the defiiition of lengths in G', the lengths of T and
C are equal.
Since the Pj may not be unique, T may not be unique. If, however,
we use some arbitrary rule for 'breaking ties,' we can consider this corre-

This content downloaded from 130.85.244.152 on Fri, 12 Apr 2019 03:57:09 UTC
All use subject to https://about.jstor.org/terms
The Longest-Path Problem 653

spondence as a function t from the set of cycles of G' into the set of tours
of G. To be explicit we shall assume in the remainder of this section that
the shortest path between any two nodes of G is unique.
LEMMA 4. If T is an optimal tour in G, then there exists a cycle C in G' such
that T=t(C).
Proof. As in the preceding lemma, write T as (il= 1, PI, i2, ,in
Pn, in+1- 1) where now ij is the first appearance of that node in the to
and Pj is the sequence of nodes between the first passage through ij and
first passage through ij+1. Note that P1 is empty, that P2 contains at m
ii, and that Pn may contain every node of G. Then Pj is a shortest pat
between nodes ij and ij+l since otherwise T would not be optimal. Hence
if C= (il = 1, i2, ** *, in), clearly T= t(C) by the definition of t. C may n
be unique, but this is unimportant for our purposes.
THEOREM 2. A cycle C in G' is optimal if and only if the tour T= t(C) is
optimal in G.
Proof. Let C be an optimal cycle in G' and let L be its length. Suppose
that t(C) is not optimal; then there exists another tour T* such that T* is
optimal and is of length L* <L. Then by Lemma 4 there is a cycle C*
such that t(C*) = T*. The length of C* is also L* and so C is not optimal,
which is a contradition.
Conversely, let T be an optimal tour, the length of which is L. Then
by Lemma 4 there exists a cycle C such that t(C) = T and by Lemma 3 the
length of C is also L. Suppose now that C is not optimal so that there
exists another cycle C* that is optimal and whose length is L*<L. Then
the length of t(C*) is L* and hence T is not optimal, which is again a
contradiction.
Theorem 2 implies that the tour problem for G is contained in the cycle
problem for G' and therefore is solvable by a longest-path algorithm. To
summarize, we now have established that to solve the cycle version of the
traveling-salesman problem, find the longest path in L(G); to solve the
tour version of the traveling-salesman problem, find the longest path in
L(G'). Of course, the practicality of these results rests upon an efficient
longest-path algorithm.

DISCUSSION OF SOLUTION PROCEDURES

THE REMAINDER of this paper will be concerned with several approaches


that have been taken to derive an efficient algorithm for the general longest-
path problem. These have all proved to be either inefficient or unsuccess-
ful, and are reported here in the hopes that this either will forestall future
work leading to the same dead-ends or will suggest some new approaches.
A case in which a rather restricted longest path can be found in an
arbitrary, finite, connected graph is the following: if the minimum number

This content downloaded from 130.85.244.152 on Fri, 12 Apr 2019 03:57:09 UTC
All use subject to https://about.jstor.org/terms
654 William W. Hardgrave and George L. Nemhauser

of arcs in any path between nodes 1 and 1' is n', then we can find the longest
of those paths containing exactly n' arcs. The procedure is to replace the
lengths d(i,j) by new lengths K-d(i,j) where K is a sufficiently large con-
stant, and apply a shortest-path algorithm to the new graph. The diffi-
culty here is that in general the longest path will contain more than n' arcs
and there appears to be no way of proceeding from the longest path with
n' arcs to a path with more arcs. In fact this method may only be used to
find the general longest path when every path between nodes 1 and 1' con-
tains exactly the same number of arcs. However, it is interesting to note
that a duality exists between this method and our procedure for embedding
the traveling-salesman problem in the longest-path problem. Our interpre-
tation of the traveling-salesman problem was essentially to find the shortest
path between two specified nodes which contained the maximal number of
arcs (or equivalently the shortest path which passed through every node).
It was shown that one could replace the lengths d(i,j) by new lengths
K-d(i,j) and then apply a longest-path algorithm which, in a sense, is
the dual of the above procedure for finding the longest path containing the
minimal number of arcs.
There is also a special case in which the general longest-path problem
can be solved efficiently. If the graph is directed and contains no directed
cycles, its distance matrix D = [d(i,j)] is triangular (after permuting its
rows and columns suitably) and essentially the same algorithm that finds
the shortest path can be used to find the longest path also. [7] Graphs of
this type arise naturally in critical-path scheduling, which, prior to this
work, was the only other application of the longest-path problem in the
operations research literature known to the authors. t
Since it is always possible to construct a graph with a triangular distance
matrix from any given graph in such a way that there is a one-to-one
length-preserving correspondence between paths in the two graphs such a
'triangularization' theoretically would solve the general longest-path prob-
lem. However, triangularization greatly enlarges the graph and appears
to be a tedious process, hardly more efficient than enumeration of all possi-
ble paths. A rapid triangularization procedure that would ensure minimal
enlargement of the graph would be of great interest.
One possible approach to the general longest-path problem is to devise
an algorithm that determines one arc that is not in the longest path; then
this arc would be removed and the algorithm reapplied to the remaining
graph. Repetition of this process, until the removal of one more arc would
t Occasionally, in the Sunday newspaper there appear puzzle contests which
consist of finding the longest path through a finite connected graph. This rather
trivial, but potentially profitable, application stimulated our original interest in
the longest-path problem.

This content downloaded from 130.85.244.152 on Fri, 12 Apr 2019 03:57:09 UTC
All use subject to https://about.jstor.org/terms
The Longest-Path Problem 655

disconnect the remaining graph, would yield the longest path. In particu-
lar, if we could find one of the end arcs of the longest path, say (1,j), we
could eliminate all other arcs incident to node 1 and apply the procedure
to the remainder, using node j as a new end node. Alternatively, we know
that at least one arc of the shortest path is not in the longest path. If we
could find such an arc, repeated application in turn of such a procedure
and of a shortest-path algorithm would eventually yield the longest path.
This is similar to a proposal of POLLACK'S9' for finding the kth shortest
path and may suffer from the same limitations that Pollack recognizes in
his proposal.

.. . ........

Fig. 4. The mechanical analogue.

There is a mechanical analogue of the longest-path problem that might


be helpful in approaches based on the removal of arcs. In the ideal me-
chanical model, arcs are represented by elastic bands of uniform elasticity
with an infinite elastic limit; the lengths of the bands when just barely taut
are proportional to the lengths of the corresponding arcs in the graph. The
elastic bands are joined together, of course, in such a way as to preserve
the incidence relation of the graph. In practice, workable models have
been constructed by using thin washers as nodes and ordinary elastic bands
as arcs (See Fig. 4). It is conjectured that as one grasps the washers corre-
sponding to nodes 1 and 1' and pulls them apart, the last elastic band to
become taut corresponds to an arc that is in a longest path. Unfortunately,
it is not clear how to proceed from here, unless that arc is an end arc; several

This content downloaded from 130.85.244.152 on Fri, 12 Apr 2019 03:57:09 UTC
All use subject to https://about.jstor.org/terms
656 William W. Hardgrave and George L. Nemnhauser

suggestions, such as identifying the end nodes of the last arc to go taut and
repeating the stretching process, have fallen victim to counter-examples.t
A second type of approach has been analogous to finding the shortest-
path tree. Every graph of the type we are considering certainly possesses
a spanning tree that contains the longest path between nodes 1 and 1' and
such that, for instance, these nodes are also end-nodes of the tree. We
could attempt to construct an algorithm, then, which would move from one
spanning tree to another, increasing the length of the path between node 1
and node 1' at each step and terminating in, say, a spanning tree of the
type described above. This proposal, of course, is analogous to DANTZIG'S
algorithm for the shortest-path problem based on the simplex algorithm.t31

? - f3 62(p
,1-'' ~6 8 \

10 I .

I0
Fig. 5. A 'locally optimal' spanning tree that does not contain the longest
path, which is (1,2,5,6,3,4,7,8).

The example of Fig. 5 points out at least one of the difficulties here, namely
that great care must apparently be exercised in the choice of an initial
spanning tree. The spanning tree in the example, which also happens to
be a path, does not contain the longest path, but by any sort of reasonable
criterion does seem to be 'locally' optimal. HOFFMAN AND PAVLEY 561
describe a similar method for finding Kth shortest paths, but as pointed out
by POLLACK18] their procedure suffers from the paramount difficulty of the
longest-path problem in that their solutions can contain loops.

REFERENCES

1. R. L. ACKOFF, Ed., Progress in Operations Research, Vol. T, Wiley, New York,


1961.

t The authors are indebted to P. T. McLENDON of the Southern Bell Telephone


and Telegraph Company for suggestions concerning the construction of the me-
chanical analogue and to MRS. NANCY SHRIMPTON of the Bell Telephone Laboratories
for suggestions concerning its interpretation.

This content downloaded from 130.85.244.152 on Fri, 12 Apr 2019 03:57:09 UTC
All use subject to https://about.jstor.org/terms
The Longest-Path Problem 657

2. G. A. CROES, "A Method for Solving Traveling-Salesman Problems," Opns.


Res. 6, 791-812 (1958).
3. G. B. DANTZIG, "Discrete-Variable Extremum Problems," Opns. Res. 5,
266-276 (1957).
4. ,D. R. FULKERSON, AND S. M. JOHNSON, "On a Linear-Programming
Combinatorial Approach to the Traveling-Salesman Problem," Opns. Res.
7, 58-66 (1959).
5. W. HOFFMAN AND R. PAVLEY, "Applications of Digital Computers to Prob-
lems in the Study of Vehicular Traffic," Proc. Western Joint Computer Conf.,
159 (1958).
6. , , "A Method for the Solution of the Nth Best Path Problem,"
J. Assoc. Computing Machines 6, 506 (1959).
7. R. M. PEART, P. H. RANDOLPH, AND T. E. BARTLETT, "The Shortest-Route
Problem," Opns. Res. 8, 866-867 (1960).
8. M. POLLACK, "Solutions of the kth Best Route Through a Network-A Re-
view," J. Math. Analysis and Applications 3, 547 (1961).
9. X "The kth Best Route Through a Network," Opns. Res. 9, 578-579
(1961).
10. AND W. WIEBENSON, "Solutions of the Shortest-Route Problem-A
Review," Opns. Res. 8, 224-330 (1960).

This content downloaded from 130.85.244.152 on Fri, 12 Apr 2019 03:57:09 UTC
All use subject to https://about.jstor.org/terms

You might also like