Travelling salesman paths on Demidenko matrices

In the path version of the Travelling Salesman Problem (Path-TSP), a salesman is looking for the shortest Hamiltonian path through a set of n cities. The salesman has to start his journey at a given city s, visit every city exactly once, and finally end his trip at another given city t. In this paper we identify a new polynomially solvable case of the Path-TSP where the distance matrix of the cities is a so-called Demidenko matrix. We identify a number of crucial combinatorial properties of the optimal solution, and we design a dynamic program with time complexity $O(n^6)$.


Introduction
The travelling salesman problem (TSP) is one of the best studied problems in operational research. This is not only due to the numerous appearances of the TSP in various practical applications, but also due to its pivotal role in developing and testing new research methods. We refer the reader to the books by Applegate, Bixby, Chvátal & Cook [2], Gutin & Punnen [14], and Lawler, Lenstra, Rinnooy Kan & Shmoys [18] for a wealth of information on these issues. We also emphasize the role of the TSP in education and in the popularization of science. There is hardly any text book on operational research where the TSP would not be mentioned. The book [4] of Cook is an excellent example of how the TSP is used in the popularization of science.
An instance of the TSP consists of n cities together with an n × n symmetric distance matrix C = (c ij ) that specifies the distance c ij between any pair i and j of cities. The objective in the TSP is to find a shortest closed route which visits each city exactly once; such a closed route is called a TSP tour. In the Path-TSP the instance also specifies two cities s and t (with s = t), and the goal is to find a shortest route starting at city s, ending at city t, and visiting all the other cities exactly once. Both the TSP and the Path-TSP are NP-hard to solve exactly (see for instance Garey & Johnson [11]), and both problems are APX-hard to approximate (Papadimitriou & Yannakakis [20]; Zenklusen [21]). These intractability results hold even in the metric case, where the distances between the cities are non-negative and satisfy the triangle inequality. Given the intractability of TSP and Path-TSP, the characterization of tractable special cases is of obvious interest and forms a well-established and vivid branch of research.
Polynomially solvable cases of the TSP. The literature contains an impressive number of polynomially solvable cases for the classical TSP, as certified by the surveys of Burkard & al [3], Deineko, Klinz, Tiskin & Woeginger [5], Gilmore, Lawler & Shmoys [12], and Kabadi [15], and the references therein. We now briefly discuss three tractable cases of the TSP that are relevant for the current paper.
In the so-called Convex-Euclidean TSP, the cities are points in the Euclidean plane which are all located on the boundary of their convex hull. A folklore result says that the optimal tour in the Convex-Euclidean TSP is the cyclic walk along the convex hull, taken either in clockwise or in counter-clockwise direction. If we number the cities as 1, 2, . . . , n in clockwise order along the convex hull, then the cities satisfy the so-called quadrangle inequalities: These quadrangle inequalities state the fact that in a convex quadrangle, the total length of two opposing sides is less or equal to the total length of the two diagonals. Kalmanson [16] observed that whenever a TSP instance satisfies these quadrangle inequalities (1)-(2), the tour 1, 2, . . . , n is a shortest TSP tour. This extends the tractability of the Convex-Euclidean TSP to the tractability of the TSP on so-called Kalmanson matrices, where the distances satisfy (1)- (2). We stress that the class of Kalmanson distance matrices is large and goes far beyond the Convex-Euclidean case: Consider for instance a rooted ordered tree with non-negative edge lengths, place a city in each of the leaves, and number the cities from left to right. Then the shortest path distances c ij between cities i and j determine a Kalmanson matrix, as the inequalities (1) and (2) can easily be verified for any quadruple of leaves. Finally, we mention the TSP on Demidenko matrices, where the distances satisfy Note that condition (3) Figure 1: The Path-TSP in the Convex-Euclidean case: (a) An illustrating example from [9]; (b) An optimal (1,11)-path for the set of points listed in the table.
techniques to improve the time complexity to linear time O(n). Figure 1 provides an example for the Convex-Euclidean Path-TSP, which is taken from Figure 3 in [9]; this example illustrates the diverse and manifold shapes of TSP-paths under Convex-Euclidean distances. Now by looking deeper into the papers [9,10] and by carefully analyzing the flow of arguments, one realizes that the approach does not exploit any geometric property of the Convex-Euclidean case that would go beyond the quadrangle inequalities (1)- (2). In other words, the arguments in [9,10] do not only settle the Path-TSP on Convex-Euclidean distance matrices, but they do also yield (without additional effort, and without changing a single letter) a polynomial time solution for the Path-TSP on Kalmanson matrices. Note that this step from Convex-Euclidean matrices to Kalmanson matrices for the Path-TSP runs perfectly in parallel with the step from Convex-Euclidean matrices to Kalmanson matrices for the classical TSP.
Contribution and organization of the paper. In this paper we take the logically next step in this line of research and show that the Path-TSP is polynomially solvable on Demidenko matrices. This substantially generalizes and extends the results in [9,10] for the Path-TSP on Convex-Euclidean matrices and Kalmanson matrices. We first analyze the combinatorial structure of an optimal TSP-path on Demidenko matrices, and prove that there always exists an optimal solution of a certain strongly restricted and nicely structured form. Then we show that we can optimize in polynomial time over the TSP-paths of that nicely structured form. By combining these results, we get our polynomial time result for Demidenko matrices.
The remainder of the paper is organized as follows. In Section 2 we summarize definitions and notations related to paths and tours as well as concrete matrix classes of relevance in this paper. In Section 3 we introduce the concept of forbidden pairs of arcs and show that for arbitrary cities s and t there always exists an optimal (s, t)-TSP-path which does not contain forbidden pairs of arcs. Then we show some implications of this result in terms of the solution of the Path-TSP for s = 1 and t = n, and of structural properties of the optimal solution of the problem in the more general case with s = 1 and arbitrary t. Section 4 shows how to exploit the findings presented in Section 3 to efficiently solve the Path-TSP for s = 1 and for arbitrary t by dynamic programming. Finally, Section 5 shows how to efficiently solve the Path-TSP in the most general case, where there are no restrictions on s and t. Section 6 concludes the paper with some final remarks.

Definitions, notations and preliminaries
In this section we summarize various definitions and notations that will be used throughout the rest of the paper.

Paths and tours
We consider a set of n cities with a symmetric n × n distance matrix C = (c ij ). We use the notation a, b for the set {a, a + 1, . . . , b} of all integers between a and b, for any two integers a, and b with a ≤ b.
Next we introduce the four quantities E m (i, j), D w (i, j), Λ m (i, p), and V w (j, q) for integers i, j, m, w, p, q ∈ 1, n, which represent the lengths of certain λ-pyramidal paths or ν-pyramidal paths in the following way: For i, j, m ∈ 1, n with i < j ≤ m denote by E m (i, j) the length of a shortest λ-pyramidal (i, j)-path τ visiting the cities {i} ∪ j, m. Notice that due to the symmetry of the distance matrix E m (i, j) is also the length of a shortest λ-pyramidal (j, i)-path τ visiting the above set of cities. Clearly in a λ-pyramidal (i, j)-path as above city j +1 is either the successor of i or the predecessor of j. Analogously in a pyramidal TSP-tour city 1 is visited right before or right after city 2. Thus the optimal length of a pyramidal tour equals E(1, 2) + c 21 . If j = m, then E m (i, m) = c im and the corresponding path consists just of the arc (i, m).
For w, j, i ∈ 1, n, w ≤ j < i, let D w (i, j) be the length of a shortest ν-pyramidal (i, j)-path which visits the cities w, j ∪ {i} (and also the length of a shortest ν-pyramidal (j, i)-path visiting the above set of cities). Clearly in a ν-pyramidal (i, j)-path as above city j − 1 is either the successor of i or the predecessor of j. If j = w, then D w (i, j) = c iw and the corresponding path consists just of the arc (i, w).
Next we introduce notations for the length of shortest λ-pyramidal paths and shortest ν-pyramidal paths which visit contiguous sets of cities, i.e. sets of cities which consist of all cities k between i and j for some pair of cities i, j ∈ 1, n, i < j.
For i, p, m ∈ 1, n, i < p ≤ m, let Λ m (i, p) be the length of the shortest λ-pyramidal (i, p)-path which visits the cities i, m. Due to the symmetry of the distance matrix Λ m (i, p) is also the length of a shortest λ-pyramidal (p, i)-path which visits the set of cities as above. In the special case p = m, Λ m (i, p) is the length of the monotone increasing path through the cities i, m.
For w, j, q ∈ 1, n, w ≤ j < q, let V w (j, q) be the length of a shortest ν-pyramidal (j, q)-path visiting the cities w, q (and also the length of a shortest ν-pyramidal (q, j)-path visiting the above set of cities). In the special case w = j, V w (j, q) is the length of the monotone increasing path through the cities j, q.
If m = n or w = 1 we omit the subscript m or w in E m (i, j), Λ m (i, p), D w (i, j), V w (j, q), and use simply E(i, j), Λ(i, p) and D(i, j), V (j, q), respectively.
Observe that for every m ∈ 2, n, the quantities E m (i, j) with i, j ∈ 1, m, i < j, can be computed in O(m 2 ) time by the dynamic programming recursions (4)-(5). Analogously for every w ∈ 1, n − 1, the quantities D w (i, j) with j, i ∈ w, n, j < i, can be computed in O((n − w) 2 ) time by the recursions (6)- (7).
for j ∈ w + 1, n − 1, i ∈ j + 1, n, and In particular the entries E(i, j) and the entries D(j, i), i, j ∈ 1, n, i < j, can be computed in O(n 2 ) time.
Summarizing we get the following result: Since, as mentioned above, the optimal length of a pyramidal tour equals E(1, 2) + c 21 Observation 2.1 implies the following result known already in the 1970's. The quantities Λ m (i, p), with i, p, m ∈ 1, n, i < p ≤ m, and V w (j, q), with w, j, q ∈ 1, n, w ≤ j < q, can also be computed efficiently by dynamic programming as shown in the following simple observation. We set Λ m (i, p) Proof. For the quantities Λ m (i, p) the claim follows directly from Observation 2.1 and the following equalities which hold for any triple (i, p, m) in the given range of indices: Analogously, for the quantities V w (j, q) the claim follows directly from Observation 2.1 and the following equalities which hold for any triple (w, j, q) in the corresponding range of indices: Clearly the quantities c i,i+1 + c i+1,i+2 + ... + c p−2,p−1 can be computed in a preprocessing step in O(n 3 ) time for all pairs (i, p) with i, p ∈ 1, n and i < p.
In what follows we assume that all quantities E m (i, j), D w (i, j), Λ m (i, p), V w (j, q) with indices in their corresponding ranges are computed in a preprocessing step. Moreover we use the straightforward relationships Finally let us notice that we will use a schematic representation of paths to illustrate their combinatorial properties. An (s, t)-TSP-path τ = τ 1 = s, . . . , τ k = t , s < t, visiting the n cities τ i ∈ 1, n for i ∈ 1, n, is visualized on an n × n grid by placing city τ i in the grid node with coordinates (i, τ i ). For example, Figure 2(a) shows the shortest (5, 7)-TSP-path τ , τ = 5, 6, 4, 2, 1, 3,8,9,11,12,10,7 , for the set of 12 points in Figure 3. The schematic representation of τ is shown in Figure 2

Classes of matrices
The example in Figure 3 shows that the Demidenko matrices form proper superset of the Kalmanson matrices. It can be checked that the distance matrix C of the Euclidean distances of these 12 points in the Euclidean plane is a Demidenko matrix but not a Kalmanson matrix. Indeed, some points lie far from the boundary of the convex hull of all points and the matrix of their Euclidean distances is not even a permuted Kalmanson matrix. We refer the reader to Deineko, Rudolf, Van der Veen & Woeginger [6] for an explicit characterization of Euclidean sets of points that satisfy the Kalmanson conditions   Back in 1979, Demidenko [8] proved that an optimal TSP tour on a set of cities with a Demidenko distance matrix can be found among the pyramidal TSP-tours. Together with Theorem 2.2 this implies the following result: For an n-city TSP instance with a Demidenko distance matrix, an optimal TSP tour can be found among the pyramidal TSP tours; hence it can be determined in O(n 2 ) time.
Throughout this paper, we will assume that all considered distance matrices have nonnegative entries. This assumption can be made without loss of generality, as Demidenko matrices can be transformed into non-negative Demidenko matrices by simply adding a sufficiently large constant to each entry. Clearly the Path-TSP with a distance matrix C = (c ij ) and the Path-TSP with a distance matrixC = (c ij + K) for some K ∈ R are equivalent, in the sense that the sets of their optimal solutions coincide.
3 Forbidden pairs of arcs and structural properties of optimal TSP-paths starting at city 1 In this section we investigate the combinatorial structure of optimal (s, t)-TSP-paths in the case where the distance matrix of the cities is a Demidenko matrix. An essential concept used in our investigations is that of a forbidden pair of arcs. We show first that there always exists an optimal (s, t)-TSP-path which does not contain forbidden pairs of arcs. As implications of this fact we obtain the solution of the (1, n)-Path-TSP and further structural properties of the optimal (1, t)-TSP-path for t = 1.

Lemma 3.2 Consider a Path-TSP instance with a Demidenko distance matrix (c ij ).
There exists an optimal (s, t)-TSP-path which does not contain forbidden pairs of arcs.
Proof. Let τ = τ 1 = s, τ 2 , . . . , τ n = t be an optimal (i.e. shortest) (s, t)-TSP-path with some forbidden pair of arcs (i, τ (i)) and (j, τ (j)). Assume without loss of generality that i < j < τ (i) < τ (j) and that city i is reached earlier than city j in τ . Apply a standard transformation technique (see for instance Burkard & al [3]) to construct an optimal (s, t)-TSP-path which does not contain the pair (i, τ (i)) and (j, τ (j)) of forbidden arcs: invert the (τ (i), j)-subpath of τ into j, . . . , τ (i) , and replace the forbidden pair of arcs by the new pair of arcs (i, j) and (τ (i), τ (j)). Clearly the resulting path τ is an (s, t)-TSP-path. Moreover the Demidenko conditions (3) imply that c iτ (i) + c jτ (j) ≥ c ij + c τ (i)τ (j) , and therefore the length of τ does not exceed the length of τ . So τ is an optimal (s, t)-TSP-path which does not contain the pair (i, τ (i)) and (j, τ (j)) of forbidden arcs. If this path still contains a forbidden pair of arcs we apply the above transformation again and repeat this process as long as the current optimal (s, t)-TSP-path contains a forbidden pair of arcs.
In order to see that this transformation process terminates after a final number of steps consider a potential function K which maps any (s, t)-TSP-path π to a non-negative integer K(π) := n i=1, i =t |i − π(i)|. It can easily be seen that the transformation described above reduces the value of the potential function, i.e. K(τ ) < K(τ ). Since the potential function takes only non-negative integer values the process stops after a final number of steps.  Proof. We show that any (1, n)-TSP-path with a non-trivial peak, i.e. a peak different form n, contains a forbidden pair of arcs. The proof of the lemma is then completed by observing that 1, 2, . . . , n is the unique (1, n)-TSP-path without a non-trivial peak.
Let m be the first peak in a (1, n)-TSP-path τ . Since m is a peak, there is an arc (i, j) in a (m, n)-subpath of τ such that i < m < j. If τ −1 (m) < i, then (τ −1 (m), m) and (i, j) build a forbidden pair of arcs. If τ −1 (m) > i, then on the monotone increasing (1, m)-subpath of τ there exists an arc (k, l) such that k < i < l ≤ τ −1 (m). By observing that τ −1 (m) < m < j we conclude that the pair (k, l) and (i, j) is a forbidden pair of arcs in this case.
The following corollary is a statement about the monotonicity of peaks and valleys in optimal (1, t)-TSP-paths. Corollary 3.4 Consider a Path-TSP on n cities with a Demidenko distance matrix. For any t ∈ 1, n, t = 1, there exists an optimal (1, t)-TSP-path with peaks decreasing and valleys increasing from the left to the right in the path, i.e. if peak p (valley v) is reached earlier than peak p (valley v ) in the path, than p > p (v < v ) holds.
Proof. The proof is done by induction on the number n of cities. The statement is trivially true for n = 2. So assume that n > 2.
The correctness of the statement for t = n follows immediately from Theorem 3.3: the (1, n)-TSP-path 1, 2, . . . , n contains just the (trivial) valley 1 and the (trivial) peak n. Thus we assume without loss of generality that t = n and let τ be an optimal (1, t)-TSPpath. Let τ = τ 1 = 1, τ 2 , . . . , τ k = n , with k ∈ 1, n, k < n, be the (1, n)-subpath of τ . Since a principal submatrix of a Demidenko matrix is a Demidenko matrix, as mentioned in Subsection 2.2, by applying Theorem 3.3 we can reorder the cities of τ increasingly and obtain a (1, n)-path of the same length which visits the same cities as τ . So we can assume without loss of generality that there is no peak in the (1, n)-subpath τ but n, and hence n is also the first peak in (1, t)-TSP-Path τ . Now we distinguish two cases: (a) the last city t is the smallest city in the (n, t)-subpath of τ and (b) there is a city j with j < t in the (n, t)-subpath of τ . In Case (a) we can assume without loss of generality that there are no other peaks but n in the (n, t)-subpath of τ (by applying similar arguments to the one mentioned above for the (1, n)-subpath τ of τ ); this assumption is justified by Theorem 3.3 and by the fact that a reversed Demidenko matrix is a Demidenko matrix. So. we assume w.l.o.og. that the (n, t)-subpath of τ is monotone deareasing the statement of the corollary holds in this case. (Notice, that in this case we can find an optimal (1, t)-TSP-path which is λ-pyramidal.) In Case (b) the (n, t)-subpath from n to t contains at least one valley which is smaller than t. Let v = τ l < t be the smallest valley in the (n, t)-subpath of τ , for k < l < n. Analogously as for the (1, n)-subpath and for Case (a) we can assume without loss of generality that the (n, v)-subpath of τ contains no peaks, but n. Denote byτ the (v, t)subpath of τ , 1 < v < t < n. Since the distance matrix of the cities visited byτ is a Demidenko matrix (as a principal submatrix of a Demidenko matrix), the induction hypothesis applies and this completes the proof. Lemma 3.5 Consider a Path-TSP with a Demidenko distance matrix and an optimal (1, t)-TSP-path τ which contains no forbidden pairs of arcs and such that its peaks decrease and its valleys increase from the left to the right in the path. Let m 1 and m 2 , m 1 > m 2 , be two consecutive peaks in τ . Let w 1 be the valley that precedes peak m 1 . let w 2 be the valley that follows m 1 and precedes m 2 , and let w 3 be the valley that follows m 2 . Then the following statements hold: (i) The (w 1 , m 1 )-subpath of τ contains no city i for which w 2 < i < m 2 holds.
(ii) The (m 1 , w 2 )-subpath of τ contains no city j for which w 3 < j < m 2 holds.
Proof. Figure 4 illustrates the structure of a path with the properties described in the lemma. We prove here only statement (i), statement (ii) can be proved by using similar arguments.
In particular, the statements in the above lemma imply that the cities m 2 + 1, m 1 are placed on consecutive positions in path τ and form a λ-pyramidal subpath of it.

Efficient solution of the Path-TSP with a Demidenko dis-
tance matrix: the case s = 1 In this section we first derive recursive equations for the length H n (1, t) of an optimal (1, t)-TSP-path through the cities 1, n. These equations yield an O(n 2 ) dynamic programming algorithm for the solution of the Path-TSP with a Demidenko distance matrix where the starting city is 1 and the destination city arbitrary. The recursive equations for H n (1, t). Due to Lemma 3.2, Corollary 3.4 and Lemma 3.5, we consider without loss of generality an optimal (1, t)-TSP-paths τ which contains no forbidden pairs of arcs, has decreasing peaks and increasing valleys from the left to the right and fulfills the statements of Lemma 3.5. We distinguish two cases: (1) the optimal (1, t)-TSP-path contains no valleys but 1 and t, and (2) the optimal (1, t)-TSP-path contains at least one valley w with 1 < w < t. In the first case the optimal (1, t)-TSP-path is λ-pyramidal and thus H n (1, t) = Λ n (1, t). In the second case let w = j + 1, j ≥ 1, w < t be the left-most (and the smallest) non-trivial valley in τ .
Since n is the first peak, valley w is reached after n in τ . According to Lemma 3.5 (see also Figure 4 where the role of w is played by w 2 ), τ starts with a monotone increasing (1, w − 1)-subpath visiting the cities 1, j, followed first by a λ-pyramidal path with the peak m = n, then by a µ-pyramidal path with valley w = j + 1, and so on, until the final city t is reached. For cities j, m, w such that j < w < m and w ≤ t < m denote by Γ(j, m, w) be the length of an optimal (j, t)-path starting at j and then visiting the cities of the set {j}∪w, m with the first peak in this path being m, and the valley that follows m being w > j. Here w could also coincide with t, in which case t would be reached along a decreasing sequence of cities from m to t. Then the length H n (1, t) of the optimal (1, t)-TSP-path is given as follows H n (1, t) = min Λ n (1, t), min{V 1 (1, j) + Γ(j, n, j + 1) : j = 1, . . . , t − 2} .
where V 1 (1, j) is defined as in Subsection 2.1.
Next we give a recursive equation for the computation of the quantities Γ above. To this end denote by L(k, w, p) the length of an optimal (k, t)-path visiting the cities of the set w, p ∪ {k} with first valley w and first peak p such that w precedes p, for cities w, p, k such that w < p < k and w < t ≤ p. Here p could also coincide with t in which case t would be reached along an increasing sequence of cities from w to t.
The above recursions (9) cover the following cases which are also illustrated in Figure 5.
Case w = t. The (j, w)-path has only one peak m (since w = t), starts at j, ends at t and goes through the cities t + 1, m. The optimal length of the pyramidal path on these cities equals E m (j, t) (see the definition before Observation 2.1). This case corresponds to the first line in (9) and is illustrated in Figure 5(a).
Case w = t. In this case there will be another peak (different from m) to the right of the valley w. Let this peak be p, with p ≤ m − 1 according to Corollary 3.4. We again distinguish two subcases: p = m − 1 and p < m − 1. If p = m − 1, then according to Lemma 3.5 the path starts with the arc (j, m) followed by (m, t)-subpath which starts at m and goes through the cities w, m − 1, with the first valley in this path being w and peak m − 1 reached after valley w. The optimal length of such a path is given by L(m, w, m − 1) and in this case Γ(j, m, w) is calculated as shown in the second line of (9) and illustrated in Figure 5(b).
If p < m − 1, then the (j, t)-path starts with an arc connecting j to the left-most city of a λ-pyramidal path with peak m containing the cities p + 1, m and either starting or ending at city p + 1. Let the other end-city of this λ-pyramidal path be k ∈ p + 2, m. Then the length of the (j, t)-path is calculated as shown in the third line of (9) and illustrated in Figures 5(c) and 5(d). These pictures correspond to the cases where above mentioned λ-pyramidal path starts or ends at p + 1, respectively.
The values L(k, w, p), for w, k, p ∈ 1, n with 1 < w < t ≤ p < k ≤ n, can be computed recursively in a similar way: where Based on equations (8)-(10) we obtain the following result about the computation of the optimal (1, t)-TSP path in the case of a Demidenko distance matrix. Proof. Recall that all values Λ m (i, p), for i, p, m ∈ 1, n with i < p ≤ m, and V w (j, q), for w, j, q ∈ 1, n, with w ≤ j < q, can be calculated in O(n 3 ) time in a preprocessing step, see Observation 2.3. Further, according to equation (8) the computation of the length H n (1, t) of the optimal (1, t)-TSP-path (for t ≥ 3) involves the quantities Γ(j, n, j + 1), for j ∈ 1, t − 2. The quantities Γ(j, m, w), for j, w, m ∈ 1, n with j < w ≤ t < m, are computed recursively together with the quantities L(k, w, p), for w, p, k ∈ 2, n with w < t ≤ p < k.
Observe that the computation of Γ(j, m, w), for some (j, m, v) in the corresponding range, just involves quantities L(x, y, z) for which the difference z − y between the specified peak z and valley y is strictly smaller than the difference m − w between the specified peak m and the specified valley w in Γ(j, m, w). Analogously, the computation of L(k, w, p), for some (k, w, p) in the corresponding range, involves quantities Γ(x, y, z) for which the difference y − z between the specified peak y and valley z is strictly smaller than the difference p − w between the specified peak p and the specified valley w in L(k, w, p). So the recursion would start with the trivial values Γ(j, t + 1, t) := c j,t+1 + c t+1,t for j, t ∈ 1, n with j < t, and L(k, t − 1, t) := c k,t−1 + c t−1,t for k, t ∈ 1, n with k > t.

Efficient solution of the Path-TSP with a Demidenko distance matrix: the general case
In this section deals with the polynomial time computation of an optimal (s, t)-TSP-path in the most general case where s, t ∈ 1, n, and none of the conditions s = 1 and t = n is necessarily fulfilled. The results is stated in Theorem 5.4 and the rest of the section is dedicated to its proof. The following assumprions hold throughout the rest of this section. Due to the symmetry of the distance matrix we can assume that s < t holds. Moreover, we assume that s > 1 because the case s = 1 has already been handled in Theorem 4.1. The case t = n can be handled analogously to the case s = 1, since a reversed Demidenko matrix is again a Demidenko matrix, as pointed out in Section 2. Summerizing we assume without loss of generality that 1 < s < t < n holds. Further, by Lemma 3.2 we only consider (s, t)-TSPpaths without forbidden pairs of arcs. The following three claims state some particular structural properties of such paths which will be useful for the proof of Theorem 4.1.
Claim 5.1 There is an optimal (s, t)-TSP-path τ with 1 < s < t < n, where city 1 precedes city n.
Proof. To prove the claim we show that any (s, t)-TSP-path τ in which n precedes 1 contains a forbidden pair of arcs. Indeed, the (s, n)-subpath of τ contains an arc (u, v) with u < p < v, where p is the first peak in the subpath from 1 to t. (If the subpath from 1 to t is monotone we have p = t.) If τ −1 (p) < u, then the arcs (u, v) and (τ −1 (p), p) build a forbidden pair of arcs. Otherwise consider an arc (x, y) in the (monotone) subpath from 1 to p such that x < u < y. The arcs (u, v), (x, y) build a forbidden pair of arcs in this case.

Claim 5.2
There is an optimal (s, t)-TSP-path in which 1 precedes n and each city of the (s, 1)-subpath is smaller than each city of the (n, t)-subpath.
Proof. To prove the claim we consider an arbitrary (s, t)-TSP-path τ in which city 1 precedes city n and show that the existence of a city in the (s, 1)-subpath which is larger than some city in the (n, t)-subpath implies the existence of a forbidden pair of arcs. In particular if i is a city in the (s, 1)-subpath of τ and j is a city in the (n, t)-subpath of τ such that i > j, it can be shown by arguments similar to those in the proof of Claim 5.1 that the (i, j)-subpath of τ contains a forbidden pair of arcs.

Claim 5.3
There exists an optimal (s, t)-TSP-path τ which is a concatenation of two paths τ p 1 and τ p 2 such that τ p 1 starts at s and visits all cities from the set 1, p − 1, and τ p 2 starts at the last city of τ p 1 , then visits all cities from the set p, n and ends at t, for some p ∈ s + 1, t.
Proof. To prove the claim we consider an (s, t)-TSP-path τ in which city 1 precedes city n and such that each city of the (s, 1)-subpath of τ is smaller than each city of the (n, t)subpath of τ . Claim 5.2 guarantees the existence of such a path. Observe that due to Theorem 3.3 and the fact that a principal submatrix of a Demidenko matrix is a Demidenko matrix, the (1, n)-subpath of τ is monotone increasing. Now let p be the smallest city on the (n, t)-subpath of τ and let x be the last city with x < p, x = s, in the (1, n)-subpath of τ . Then the cities in 1, p − 1 are exactly the cities visited by the (s, x)-subpath of τ . Hence we can set τ p 1 and τ p 2 as the (s, x)-subpath and the (x, t)-subpath of τ , respectively.
Theorem 5.4 Consider a Path-TSP on n cities 1, n with a Demidenko distance matrix and a given pair of cities (s, t). An optimal (s, t)-TSP-path can be found in O(|t − s|n 5 ) time.
Proof. Due to Claims 5.1-5.3 we minimize over (s, t)-TSP-paths τ in which city 1 precedes city n, each city in the (s, 1)-subpath has a smaller index than each city in the (n, t)subpath, and for which an index p ∈ s + 1, t exists such that τ is the concatenation of τ p 1 and τ p 2 as described in Claim 5.3. We refer to τ p 1 and τ p 2 as the prefix and the postfix of τ and denote by x the last city of the prefix (and the first city of the postfix). Next we show how to efficiently determine the length of a shortest prefix and a shortest postfix for each p ∈ s + 1, t and each x, x < p, x = s.
By using the fact that a principal submatrix of a Demidenko matrix is a Demidenko matrix and by considering that the postfix starts at x, x < p, and then visits all cities in {x}∪p, n, the shortest length T (x, p) of the postfix can be determined in O(n 5 ) as described in Theorem 4.1, for every p ∈ s + 1, t and for every x < p. Now let us virtually shrink the postfix to its second city τ (x). To distinguish τ (x) from the shrunk city let us denote the later by V p x . We set the distance between V p x and x equal to T (x, p). Observe that the index of city τ (x) is larger than the indices of all cities in the prefix (with indices lying in 1, p − 1), hence the dummy city V p x can be considered to have index p. Consider now the pathτ p 1 obtained by extending the prefix along the edge (x, V p x ); since τ contains no forbidden pairs of arcs alsoτ p 1 contains no forbidden pairs of arcs. Notice that a shortest (t, n)-TSP-path without a forbidden pair of arcs can be determined in the same way as a shortest (1, t)-TSP-path without a forbidden pair of arcs (after renumbering the rows and columns of the distance matrix from the right to the left prior to the calculations). Thus the lengthT (x, p) ofτ p 1 which starts at s, visits all cities from 1, p − 1 and then ends at V p x which has index p, can be computed in O(n 5 ) time as described in Theorem 4.1 (recall that the proof of Theorem 4.1 relies exclusively on the properties of paths without forbidden pairs of arcs). Clearly,T (x, p) equals the sum of the lengths of the prefix and the postfix, given p ∈ s + 1, t and x < p, x = s. Consequently, the required length of the shortest (s, t)-TSP-path equals min{T (x, p) : p ∈ s + 1, t , x < p , x = s}. It is straightforward to compute this minimum in O((t − s)n 6 ) time after having computedT (x, p) in O(n 5 ) time for each pair of indices x and p as above. A closer look at the recursions (8) and equations (9)-(10) involved in the computation ofT (x, p) and T (x, p) according to Theorem 4.1, reveals that for each fixed p all computations use the same quantities Γ and L, independently on the value of x, where x < p and x = s. Thus for any p ∈ s + 1, t all values ofT (x, p) (and also T (x, p)) for x < p, x = s, can be computed in O(n 5 ) time leading to an overall time complexity of O((t − s)n 5 ) and completing the proof.

Final remarks
We have analyzed the Path-TSP on Demidenko matrices, and we have derived a sophisticated algorithm with a polynomial time complexity of roughly O(n 6 ). An obvious open problem is to get an improvement to some more civilized time complexity like O(n 2 ), or at least O(n 3 ). The polynomially solvable special case for Demidenko matrices can be used in local search approaches for the Path-TSP, as it yields an exponential neighborhood over which we can optimize in polynomial time. We refer to Ahuja, Ergun, Orlin & Punnen [1], Deineko & Woeginger [7], Gutin, Yeo & Zverovich [13], and Orlin & Sharma [19] for a discussion of similar approaches in the case of the classical TSP.