Special cases of the quadratic shortest path problem

The quadratic shortest path problem (QSPP) is the problem of finding a path in a digraph such that the sum of weights of arcs and the sum of interaction costs over all pairs of arcs on the path is minimized. We first consider a variant of the QSPP known as the adjacent QSPP. It was recently proven that the adjacent QSPP on cyclic digraphs cannot be approximated unless P=NP. Here, we give a simple proof for the same result. We also show that if the quadratic cost matrix is a symmetric weak sum matrix or a symmetric product matrix, then an optimal solution for the QSPP can be obtained by solving the corresponding instance of the shortest path problem. Similarly, it is shown that the QSPP on a directed cycle is solvable in polynomial time. Further, we provide sufficient and necessary conditions for a QSPP instance on a complete symmetric digraph with four vertices to be linearizable. We also characterize linearizable QSPP instances on complete symmetric digraphs with more than four vertices. Finally, we derive an algorithm that examines whether a QSPP instance on the directed grid graph $G_{pq}$ ($p,q\geq 2$) is linearizable. The complexity of this algorithm is ${\mathcal{O}(p^{3}q^{2}+p^{2}q^{3})}$.


Introduction
The shortest path problem (SPP) is the problem of finding a path between two vertices in a directed graph such that the total weight of the arcs on the path is minimized. The quadratic shortest path problem (QSPP) is the problem of finding a path between two vertices in a directed graph such that the total weight of the arcs and the sum of interaction costs over all pairs of arcs on the path is minimized.
The SPP is a well-studied combinatorial optimization problem, that can be solved in polynomial time if there do not exist negative cycles in the considered graph. There Main results and outline. In Section 2, we formulate the quadratic shortest path problem as an integer programming problem. Complexity results for the general and adjacent QSPP are given in Section 3. In particular, in Section 3.1 we derive a new polynomial-time reduction from the well known quadratic assignment problem (QAP) to the QSPP. Our reduction differs from the one given by Rostami et al. [15]. Namely, our approach results in an instance for the QSPP with n 2 arcs, while the reduction from [15] derives an instance with O(n 3 ) arcs. Here, n is the order of the data matrices in the quadratic assignment problem. The here presented polynomial-time reduction from the QAP, in combination with the library of the QAP [3], provides a source of difficult QSPP test instances.
In Section 3.2, we describe the polynomial-time algorithm for solving the adjacent QSPP from [15]. We also show that the algorithm fails for the adjacent QSPP considered on directed cyclic graphs, while it performs well on directed acyclic graphs (DAGs). Further, we provide a polynomial-time reduction from the 2-arc-disjoint paths problem, that is known to be NP-hard, to the adjacent QSPP considered on a directed cyclic graph. Our proof of inapproximability is considerable simpler than the proof from [14].
In Section 4, we consider special cases of the QSPP. In particular, we prove that the QSPP considered on a directed cycle is linearizable i.e., an optimal solution for a QSPP instance on a directed cycle can be found by solving the corresponding instance of the SPP. Here, we also show that a QSPP instance on a digraph for which every s-t path has the same length and whose quadratic cost matrix is a symmetric weak sum matrix is linearizable. Finally, we prove that a solution of the QSPP whose quadratic cost matrix is a nonnegative symmetric product matrix can be obtained by solving the corresponding SPP.
We provide sufficient and necessary conditions for an instance of the QSPP on a complete digraph with four nodes to be linearizable in Section 5. In the same section we give several properties of linearizable QSPP instance on complete digraphs with more than four nodes.
In Section 6, we present an algorithm that examines whether a QSPP instance on the directed grid graph G p,q (p, q ≥ 2) is linearizable. If the instance is linearizable, then our algorithm provides the corresponding linearization vector. The complexity of the algorithm is O(p 3 q 2 + p 2 q 3 ).

Problem formulation
Let G = (V, A) be a directed graph with vertex set V (|V | = n) and arc set A (|A| = m). A walk is defined as an ordered set of vertices (v 1 , . . . , v k ), k > 1 such that (v i , v i+1 ) ∈ A for i = 1, . . . , k − 1. The length of a walk equals to the number of visited arcs. A walk is called a path if it does not contain repeated vertices. Given a source vertex s ∈ V and a target vertex t ∈ V , a s-t path is a path P = (v 1 , v 2 , . . . , v k ) such that v 1 = s and v k = t.
The quadratic cost of a s-t path P is calculated as follows. We are given a nonnegative vector c ∈ R m + indexed by the arc set A, and a nonnegative symmetric matrix of order m Q = (q e,f ) with zero-diagonal whose rows and columns are indexed by the arc set. An arc e ∈ P has the linear cost (weight) c e , and a pair of arcs e, f ∈ P the interaction cost 2q ef . The total cost of the s-t path P is given by If Q is a zero-matrix, then the cost of a s-t path P is denoted by C(P, c). We assume that the graph G does not contain a directed cycle of cost zero.
Let us introduce the quadratic shortest path problem in a formal way. Let P be a s-t path, and x a binary vector of length m such that x ij is one if the arc (i, j) ∈ A is on the s-t path P and zero otherwise. Now, the quadratic cost of the s-t path P with the characteristic vector x, is given by Given a vertex i ∈ V , the set of predecessor and successor vertices of i are denoted by δ − (i) := {j ∈ V | (j, i) ∈ A} and δ + (i) := {j ∈ V | (i, j) ∈ A}, respectively. The path polyhedron is defined as follows: where b is a vector of length n such t}. Now the QSPP can be modeled as the following quadratic integer programming problem: If Q is a zero-matrix, then the problem reduces to the shortest path problem. Due to the flow conservation law, one can remove one of the equations in P st (G).
A QSPP instance I (resp. SPP instance I ′ ) can be specified by the tuple I = (G, s, t, c, Q) (resp. I ′ = (G, s, t, c)). Note that we use both, e and (i, j), to denote an arc e = (i, j). Sometimes one is more convenient than another.

Complexity results for the general and adjacent QSPP
In Section 3.1 we present a polynomial-time reduction from the quadratic assignment problem to the QSPP. Our reduction results in a significantly smaller number of arcs in the constructed QSPP instance, than the number of the arcs in the QSPP instance provided by the reduction from [15]. Section 3.2 and 3.3 consider the adjacent QSPP. In Section 3.2 we review the algorithm from [15] on solving the AQSPP on directed graphs, and show that it fails when the digraph under consideration contains a cycle. Further, we provide a proof showing that the AQSPP on cyclic digraphs cannot be approximated unless P=NP, see Section 3.3. Our proof is simpler than the proof from [14].

The general QSPP
In [15] it is proven that the QSPP is NP-hard by providing a polynomial-time reduction from the QAP. The size of so constructed QSPP instance in [15] is considerably larger than the size of the input QAP instance. In particular, if a QAP instance consists of n facilities and n locations, then the constructed QSPP instance as described in [15] has n 2 +2 vertices and n 3 − 2n 2 + 3n arcs.
We present here another polynomial-time reduction from the QAP to the QSPP. Our reduction yields a QSPP instance with n + 1 vertices and n 2 arcs, where n is the order of the data matrices in the QAP. This enables us to derive QSPP test instances of reasonable sizes, from the QAP instances given in the QAP library [3]. Note that the QAP library contains solutions and/or bounds for many QAP instances, and is therefore a source of test instances for the QSPP.
The quadratic assignment problem is the following optimization problem: where A = (a ik ), B = (b jl ) are given symmetric n × n matrices, C = (c ij ) ∈ R n×n , and Π n is the set of n × n permutation matrices.
The quadratic assignment problem has the following interpretation. Suppose that there are n facilities and n locations. The flow between each pair of facilities, say i, k, and the distance between each pair of locations, say j, l, are given by a ik and b jl , respectively. The cost of placing a facility i to location j is c ij . The QAP problem is to find an assignment of facilities to locations such that the sum of the distances multiplied by the corresponding flows together with the total cost is minimized.
Let us now allow a directed multigraph in the definition of the QSPP problem. A multigraph is a graph which is permitted to have multiple arcs from one to another vertex. We can now prove the following theorem. Proof. Suppose we are given a QAP instance with n×n input matrices A, B, C and that the diagonal entries of A, B are zero. We construct a QSPP instance on the graph G = (V, A) whose vertex and arc sets are defined as follows: V := {w j : j = 1, . . . , n + 1}, where the superscript i indicates the ith arc between vertices w j and w j+1 . The starting and ending vertices are s = w 1 and t = w n+1 , respectively.
The linear cost of the arc e is defined as The interaction cost between the pair of arcs e = (w j , w j+1 ) i and f = (w l , w l+1 ) k is defined: where M is a big number. All the other pairs of arcs have zero interaction costs.
If we have a feasible QAP instance, say facility i is mapped into location π(i), then we take the feasible QSPP instance with arcs (w π(i) , w π(i)+1 ) i (i = 1, . . . , n). By construction, those two instances have the same objective value. Conversely, a s-t path in G corresponds to the assignment for the QAP with the same objective value.
It follows from the above construction that for a given input instance of the QAP with n × n data matrices, one can construct a QSPP instance with n + 1 vertices and n 2 arcs.

The adjacent QSPP restricted to DAGs
The adjacent QSPP is a variant of the QSPP, where interaction costs of all non-adjacent pairs of arcs are equal to zero. In other words, only the interaction cost of the form q ij,kl with j = k and i = l, or with i = l and j = k can have nonzero value. A polynomial time algorithm that solves instances of the adjacent QSPP on directed acyclic graphs is presented in [15]. It is actually stated in [15] that the proposed algorithm finds an optimal solution for the AQSPP on any digraph in polynomial time, which turns to be true only for directed acyclic graphs.
In this section we first describe the approach from [15], and then provide an example to show that the algorithm fails if the graph under consideration is not acyclic.
Let G be a directed acyclic graph and I = (G, s, t, c, Q) an instance of the AQSPP. We construct the graph G ′ = (V ′ , A ′ ) from G = (V, A) in the following way: where V (s,s) and V (t,t) represent vertices s and t, respectively. The costs of the arcs in the graph G ′ are given as follows Now, the linearized instance of I is the following SPP instance I ′ = (G ′ , V (s,s) , V (t,t) , c ′ ).
The following theorem shows that the optimal s-t path for the AQSPP instance I on a directed acyclic graph can be obtained by solving the SPP instance I ′ .
Theorem 3.2. Let G be a directed acyclic graph, I = (G, s, t, c, Q) an AQSPP instance, and I ′ = (G ′ , V (s,s) , V (t,t) , c ′ ) the linearized instance of I. Then, an optimal solution of I can be obtained by solving the SPP for I ′ .
Proof. (See also [15].) We first show that any s-t path in G corresponds to a V (s,s) -V (t,t) path in G ′ , and vice-versa. For ease of notation we set v 1 := s and v k := t. Let Then it is not difficult to verify that , which is exactly the cost of the path P .
Take the ordered set of vertices P = (v 1 , v 2 , . . . , v k ). Let us verify that P is a walk that does not contain repeated vertices. From the definition of V ′ and A ′ , see (4) It remains now to verify that there do not exist k, l (k = l) for which v k = v l . Indeed, since G is acyclic this is not possible. Thus P is a s-t path in G whose total cost equals to the linear cost of P ′ .
Note that if G is not acyclic, then there may exist a V (s,s) -V (t,t) path in the linearized graph for which does not exist a corresponding s-t path in G. Let us give an example. Example 3.3. Consider a QSPP instance on the directed graph G from Figure 1. The costs are given as follows. Set c (4,3) = ǫ for some 0 < ǫ < 1 and q (1,2),(2,5) = 1. All other linear and interaction costs are zero. Set for the source and target vertex s = 1 and t = 5, respectively. Clearly, we have a well defined AQSPP instance. Moreover, P = (1, 2, 5) is the unique s-t path in G, whose cost is two. We construct the graph G ′ from G, see Figure 2. It is not difficult to verify that (V (1,1) , V (1,2) , V (2,3) , V (3,4) , V (4,2) , V (2,5) , V (5,5) ) is a V (1,1) -V (5,5) path in G ′ , whose cost is ǫ. However this V (1,1) -V (5,5) path does not correspond to a path in G.

The general adjacent QSPPs
In this section, we prove that the adjacent QSPP that is not restricted to DAGs cannot be approximated unless P=NP. In particular, we show that the 2-arc-disjoint paths problem polynomially transforms to the AQSPP. Rostamin et al. [14] provide a polynomial-time reduction from 3SAT to the AQSPP. Our reduction is considerably shorter (and simpler) than the reduction from [14].
The k-arc-disjoint paths problem is defined as follows: Let G = (V, A) be a directed graph and (s 1 , t 1 ), . . . , (s k , t k ) pairs of vertices in G. The k-arc-disjoint paths problem asks for pairwise arc-disjoint paths P 1 , . . . , P k where P i is a s i -t i path (i = 1, . . . , k).
An instance of the k-arc-disjoint paths problem can be specified via the tuple I = (G, (s 1 , t 1 ), . . . , (s k , t k )). Fortune et al. [9] prove that the k-arcs-disjoint paths problem is NP-complete even for k = 2. We use this to prove the main result in this section. Proof. We provide a polynomial-time reduction from the 2-arc-disjoint paths problem to the adjacent QSPP. Let I = (G, (s, t), (s,t)) such that s =s and t =t be an instance of the 2-arc-disjoint paths problem on the graph G = (V, A).
We construct a directed graph G ′ = (V ′ , A ′ ), where the vertex set is given as follows In particular, for each vertex v ∈ V there are two vertices v 1 , v 2 in V ′ , and for each arc i.e., for each arc (u, v) ∈ A there are two pairs of arcs (u i , N uv ), (N uv , v i ) (i = 1, 2), and additionally the arc (t 1 ,s 2 ). Now we define the cost functions c ′ : ef ) as follows. The linear cost of each arc in A ′ is zero, i.e., c ′ (e) = 0 for every e ∈ A ′ . For every two pairs of arcs (u i , N uv ) and (N uv , v i ), (i = 1, 2) the interaction cost is: The interaction costs of all other pairs of arcs are zero. Clearly, the non-adjacent arcs have zero interaction costs. Now, the constructed AQSPP instance is It remains to show that I is a yes-instance of the 2-arc-disjoint paths problem on G if and only if I ′ has a s 1 -t 2 path of cost zero. Now if I is a yes-instance, then there exists a s-t path P 1 = (v 1 , v 2 , . . . , v k ) of length, say, k − 1 with v 1 := s and v k := t, and as-t path P 2 = (u 1 , u 2 , . . . , u l ) of length, say, l − 1 with u 1 :=s and u l :=t, such that P 1 and P 2 are arc-disjoint. Clearly, the following ordered set of vertices is a v 1 1 -u 2 l path of cost zero. Conversely, a s 1 -t 2 path P ′ in G ′ of cost zero is given by (5). We take the following ordered sets of vertices P 1 = (v 1 , v 2 , . . . , v k ) and P 2 = (u 1 , u 2 , . . . , u l ) in G. It is not difficult to verify that P 1 and P 2 are two paths. It remains to show that P 1 and P 2 are arc-disjoint. Let us assume this is not the case. Then there exists an arc (q, w) ∈ A visited by both paths P 1 and P 2 . From the construction of P ′ , it follows that the arcs (q 1 , N q,w ), (N q,w , w 1 ), (q 2 , N q,w ) and (N q,w , w 2 ) are visited by the path P ′ . This means that the vertex N q,w is visited twice in the s 1 -t 2 path P ′ in G ′ , which contradicts to the fact that P ′ is a walk that does not contain repeated vertices.
Finally, the inapproximability result follows since the objective value of any feasible solution of the constructed AQSPP is either zero or at least two.

Easy cases of the QSPP
In this section we investigate easy cases of the quadratic shortest path problem. Here we prove, among other things, that all QSPP instances on a directed cycle can be solved by solving an appropriate instance of the SPP. In Section 4.1 we consider special cost matrices such as sum and product matrix.
An instance of the QSPP is said to be linearizable if there exists a corresponding instance of the SPP such that associated costs are equal i.e., for every s-t path P in G. We call c ′ the linearization vector of the QSPP instance. Linearizable instances for the quadratic assignment problem were considered in e.g., [1,6], and linearizable instances for the quadratic minimum spanning tree problem in [2].
We start this section by proving several basic results.
for every s-t path P . Thus I ′ is also linearizable.
Proof. Similar to the proof of Lemma 4.1.
An instance of the QSPP may be linearizable if the underlying graph has special structure and/or the corresponding quadratic cost matrix has special properties. Let us give a class of the QSPP instances that is linearizable for any pair of cost matrices (Q, c).
The directed cycle C * n of order n is a graph with the vertex set {v 1 , . . . , v n } and arc set . . , n} where addition is modulo n. We show below that any QSPP instance on C * n is linearizable. Proposition 4.3. Let C * n be the directed cycle of order n with vertex set {v 1 , . . . , v n }, . . , n}) is linearizable, for any two distinct vertices v i , v j , and any pair of cost matrices (Q, c).
Proof. The case n = 2 is trivial. Assume without loss of generality that i = 1 and j > i and n ≥ 3. There is only one v 1 -v j path, namely P 1 = {v 1 , v 2 , . . . , v j−1 , v j }. The cost of this path is given by Let us define the linear cost vector c ′ ∈ R n + as follows Then C(P, c, Q) = C(P, c ′ ) for every v 1 -v j path in C * n .
Directed cycles are not the only digraphs on which QSPP instances are linearizable. However, they seem to be easiest cases. In the following sections we show under which conditions a QSPP instance on a directed complete graph, tournament, and grid graph is linearizable.

Special cost matrices
If the interaction cost matrix has a special structure, then the associated QSPP instance may be solved efficiently. We consider here two types of cost matrices for which QSPP instances are linearizable.
We say that a matrix M ∈ R m×n is a sum matrix generated by vectors a ∈ R m and b ∈ R n if M i,j = a i + b j for every i = 1, . . . , m and j = 1, . . . , n. A matrix is called a weak sum matrix if the condition above is not required for the diagonal entries. It is not difficult to show that if a sum matrix M of order n is symmetric, then there exists a vector a ∈ R n such that M i,j = a i + a j for all i, j = 1, . . . , n. Similarly, if the weak sum matrix M of order n is symmetric, then there exists a vector a ∈ R n such that M i,j = a i + a j for all i, j = 1, . . . , n, i = j. Recognition of a (weak) sum matrix can be done efficiently. Sum matrices are also considered in the context of the QAP [6], and the quadratic minimum spanning tree problem [2].
The following result shows that symmetric weak sum matrices provide linearizable QSPP instances under a certain condition. Proof. Suppose that every s-t path in G has length L. Since Q is a symmetric weak sum matrix, there exists a vector a ∈ R m such that q e,f = a e + a f for all e, f = 1, . . . , m, e = f . Let P be a s-t path in G with the arc set {e i : i = 1, . . . , L}. Then the cost of P is: Let us give two examples of graphs whose all s-t paths have constant length.
Example 4.5. The directed grid graph G p,q = (V, A) is defined as follows. The set of vertices and the set of arcs are given as follows: Note that |V | = pq and |A| = 2pq − p − q. If s = (1, 1) and t = (p, q), then every s-t path has length p + q − 2.
Example 4.6. The directed hypercube graph H n is defined as follows. There is a vertex for each binary string of length n, there is an arc (u, v) if the vertices u and v differ in exactly one bit position and the binary value of u is less than the binary value of v. Note that H n has 2 n vertices, 2 n−1 n arcs. If s is an all-zeros string and t is an all-ones string, then every s-t path has length n.
Let us consider another special cost matrix. A matrix M ∈ R m×m is called a symmetric product matrix if M = aa T for some vector a ∈ R m . A nonnegative product matrix with integer values plays a role in the Wiener maximum QAP, see [5].
If Q + Diag(c) is a positive semidefinite matrix, then the tuple (G, s, t, c, Q) is a convex QSPP instance. Here, the 'Diag' operator maps a m-vector to the diagonal matrix, by placing the vector on the diagonal of the m × m matrix. In [14], it is shown that the convex QSPP is APX-hard, but can be approximated within a factor of |V |. The following result shows that one can solve the QSPP efficiently whenever Q + Diag(c) is a symmetric product matrix, thus positive semidefinite matrix of rank one. Proof. Since Q + Diag(c) is a nonnegative symmetric product matrix, there exists a vector a ∈ R m + such that Q + Diag(c) = aa T . Let x ∈ {0, 1} m be the characteristic vector of a s-t path P in G. The cost of this path satisfies C(P, c, Q) = x T (Q + Diag(c))x = x T aa T x = (x T a) 2 .
Let us define the linear cost vector c ′ ∈ R m + by taking c ′ e = a e for every e. Thus, we have C(P, c, Q) = C(P, c ′ ) 2 for every s-t path P in G, and the complexity of solving the shortest path problem by Dijkstra's algorithm is O(m + n log n).

The QSPP on complete digraphs
In this section we analyze the QSPP on the complete symmetric digraph K * n , that is a digraph in which every pair of vertices is connected by a bidirectional edge. It is trivial to solve the QSPP on K * n for n ≤ 3. Here, we provide sufficient and necessary conditions for a QSPP instance on K * 4 to be linearizable. We also derive necessary conditions for linearizable QSPP instances on K * n with n ≥ 5. Assumptions. In this section we assume w.l.o.g. that the following trivial arcs are removed from K * n : the incoming arcs to s, outgoing arcs from t, and the arc (s, t). For example, the removal of these arcs from K * 4 results in the simplified graph, see Figure 3. Further, we assume that the cost vector c is all-zero vector (see Lemma 4.1), and that interaction costs of pairs of arcs that can not be together included in any s-t path is zero. For example, the interaction cost of arcs (v 1 , v 2 ) and (v 3 , v 2 ) in graph from Figure 3 is zero. Let I = (K * n , s, t, c, Q) (n ≥ 4) be an instance of the QSPP. We classify s-t paths by their lengths for that instance. This classification leads us to necessary and/or sufficient conditions for a QSPP instance to be linearizable.
Let P k denotes the set of s-t paths of length k for k ∈ {2, . . . , n − 1}. The total cost of all s-t paths of length k is CP k = P ∈P k C(P, c, Q). The number of s-t paths of the length k is |P k | = n−2 k−1 · (k − 1)!. In what follows, we show that CP k is bounded from above by CP k+1 for k = 3, . . . , n − 2, and several other related results.
Proposition 5.1. Let I = (K * n , s, t, c, Q) be a QSPP instance and n ≥ 4. Then the average cost of all s-t paths of the length k is not greater than the average cost of all s-t paths of the length k + 1, i.e., Proof. We will derive an expression for 1 |P k | CP k (k ≥ 2) in terms of the interaction costs. Then, the claim follows from the fact that the expression is an increasing function for k ≥ 3.
Given an arc e = (i, j), we define h(e) = i to be the head vertex i, and t(e) = j to be the tail vertex j. Let be the set of arcs either leaving s or entering t. Let S = {{e, f } | t(e) = h(f ) or h(e) = t(f )} be the set of distinct unordered pairs of adjacent arcs. Based on the sets H and S, we define the following sets of distinct unordered pairs of arcs: Clearly, H and its complement partition the arc set, and T 1 , . . . , T 6 partition the arc pairs in K * n . The sum of interaction costs over the pairs of arcs in T i is where u is the vector of all-ones.
It holds that every pair of arcs {e, f } ∈ T i (i ∈ {1, . . . , 6}), which is included in at least one s-t path, is contained in the same number, denoted by t i,k , of s-t paths of length k. In particular we have For k ≥ 2, the average cost of all s-t paths of length k can be written as: Here, ½ A is the indicator function defined as ½ x = 1 if condition x is true, and zero otherwise. It is clear that 1 |P k | CP k is an increasing function in k ≥ 3 and this finishes the proof.
Note that from (8) it follows that one can easily compute CP k for k ≥ 2. As direct consequences of the previous proposition, we have the following two results.

Corollary 5.2.
a) Let I = (K * n , s, t, c, Q) be a QSPP instance and n ≥ 4. Then b) Let I = (K * n , s, t, c, Q) be a QSPP instance and n ≥ 7. Then Proof. The first part follows directly from Proposition 5.1. To show the second part, note that t i,k in the proof of Proposition 5.1 satisfy From Corollary 5.2, it follows that CP 2 is not bounded by CP k for k ≥ 3. This is due to the fact that the interaction costs of arc pairs in T 1 only contribute to CP 2 . The second inequality in Corollary 5.2 shows that CP k for k = 4, 5 can be arbitrarily bigger than CP k−1 . This is because the interaction costs of pairs in T 4 and T 5 (respectively T 6 ) only contribute to the costs of paths of length greater or equal to four (respectively five).
In what follows, we show that linearizability imposes stricter conditions on interaction costs than those given above. In particular, CP 2 has to be upper bounded by CP 3 , and CP k by CP k−1 for k ≥ 4 with a constant that is tighter than the one from Corollary 5.2.
Let us first introduce the path matrix. Given a QSPP instance I = (G, s, t, c, Q), the s-t path matrix B is a matrix whose rows are the characteristic vectors of the s-t paths in G. Thus, the rows and columns of B are indexed by the paths and the arcs of G, respectively. The cost vector b is defined as b i := C(P i , c, Q).
For example, let I = (K * 4 , s, t, c, Q) be a QSPP instance such that s = v 1 and t = v 4 , see Figure 3. The s-t path matrix and cost vector are given as follows: Note that a QSPP instance on G is linearizable if and only if the linear system Bc ′ = b, c ′ ≥ 0 with variable c ′ ∈ R m has a solution.
Example 5.3. Let us consider a QSPP instance I = (K * 4 , s, t, c, Q), see Figure 3. Let s = v 1 and t = v 4 , and and q e,f = 0 for all other pairs of arcs (e, f ). Then the costs satisfy C(P 1 , c, Q) = C(P 2 , c, Q) = 2 and C(P 3 , c, Q) = C(P 4 , c, Q) = 0. Thus, the sum of the costs of paths of length two is greater than the sum of the costs of paths of length three. Now, for y = (−1, −1, 1, 1) T we have that B T y ≥ 0 and b T y = −4 < 0, and from the Farkas' lemma it follows that the QSPP instance I is not linearizable.
In the following proposition we derive necessary conditions that should satisfy a linearizable QSPP instance on complete digraph. The following conditions require that CP 2 is bounded by CP 3 , and also CP k by CP k−1 for k = 4, 5. Note that those constraints are not imposed in general, see Corollary 5.2.
Proof. Let us first show the first claim. Define g(k) := n−3 k−2 (k − 2)! for k ≥ 2, and Let H be the arc set defined in (7). It is not difficult to see that for every arc e ∈ H (resp. e / ∈ H), there are g(k) (resp. g ′ (k)) s-t paths of length k containing e. Note that g(k + 1) = (n − k − 1) · g(k) and g ′ (k + 1) ≥ (n − k − 1) · g ′ (k) for every k ≥ 2, as g ′ (k + 1) = (n − k − 1) · k−1 k−2 · g ′ (k) for k ≥ 3. Take the vector y such that Now, for the path matrix B of K * n it follows that B T y ≥ 0, and for the cost vector b T y = −(n − k − 1)CP k + CP k+1 . If I is linearizable, then b T y ≥ 0 from where it follows the first claim.
In a similar fashion, we prove the second claim by taking The results from Proposition 5.4 indicate that appropriate restrictions on CP k might lead to sufficient conditions for a QSPP instance to be linearizable. Indeed, the next proposition provides characterization of linearizable QSPP instances on K * 4 . Proposition 5.5. Let I = (K * 4 , s, t, c, Q) be a QSPP instance. I is linearizable if and only if C(P 1 , c, Q) + C(P 2 , c, Q) ≤ C(P 3 , c, Q) + C(P 4 , c, Q), where P 1 , P 2 (resp. P 3 , P 4 ) are paths of length two (resp. three).
Conversely, it follows from Proposition 5.4.
Note that one can easily verify the inequality from Proposition 5.5. The following example shows that conditions from Proposition 5.4 are not sufficient already for K * 5 .
Example 5.6. The inequalities in Proposition 5.4 are not sufficient for a QSPP instance on K * 5 to be linearizable. Take Let us assume now that a complete directed graph under consideration is a tournament, which is a graph in which every pair of vertices is connected by a single uniquely directed edge. Then, all instances of a tournament with four vertices are linearizable. There exist QSPP instances on a tournament with five vertices that are not linearizable. 6 The QSPP on directed grid graphs Directed grid graphs are introduced in Section 4.1. The directed grid graph G pq (p, q ≥ 2) has pq vertices and 2pq − p − q arcs, given as in (6). Every s-t path in G pq has the same length. In Section 4.1 we prove that an instance of the QSPP on G p,q , whose quadratic cost matrix is a symmetric weak sum matrix or a nonnegative symmetric product matrix can be solved by solving the corresponding SPP.
In this section we present an algorithm that verifies whether a QSPP instance on a directed grid graph is linearizable, and if it is linearizable the algorithm returns the corresponding linearization vector. The complexity of our algorithm is O(p 3 q 2 + p 2 q 3 ). Kabadi and Punnen [11] present an O(n 4 ) algorithm for the QAP linearization problem, where n is the size of the QAP.
In this section we assume that s = v 1,1 and t = v p,q , unless otherwise specified. The number of s-t paths in G p,q is large for p, q ≥ 13. In particular, the following result holds.
Lemma 6.1. The number of s-t paths in the directed grid graph G p,q is p+q−2 p−1 .
Let us consider for now only linear costs associated with arcs in G p,q . We say that the linear cost vectors c and d are equivalent if C(P, c) = C(P, d) for every s-t path in the graph. Given a linear cost vector c associated with arcs in G p,q and a vertex v i,j / ∈ {s, t}, we describe how to construct a new linear cost vector d, see (11), that is equivalent to c and whose associated cost of an outgoing arc from v i,j equals zero. In particular, let H = ∅ be the set of incoming arcs to v i,j , and F the set of outgoing arcs from v i,j . Let arc f ∈ F be an outgoing arc from v i,j defined as follows: The new linear cost vector d is given by In the other words, we redistributed weights of the arcs such that the outgoing arc from v i,j that is of the form (10) has zero weight. One can easily verify that c is equivalent to d. Note that the shortest path problem on a directed acyclic graph with negative weights remains polynomial-time solvable.
The depth of a vertex v i,j (i = 1, . . . , p, j = 1, . . . , q) is defined as i + j. If we apply the above procedure to a linear cost vector c repeatedly for each node v i,j / ∈ {s, t} starting with the node whose depth is p + q − 1 until the node with depth three. (The order of applying the procedure for the nodes with the same depth is arbitrary.) Then we obtain a linear cost vector, denoted by c, such that c f = 0 for all f given in (10). We say that c is the reduced from of c, or c is a linear cost vector in reduced form. As an example, the constructed linear cost vector in Lemma 6.6 is in reduced form. The following result shows that there exists unique linear cost vector in reduced form. Proof. For any linear cost vector c, its reduced form c satisfies that c e = 0 whenever e does not belong to the set of arcs Note that |J| = (p − 1)(q − 1) + 1. To every arc e from J we assign the path in the following way: We call those (p − 1)(q − 1) + 1 paths the critical paths. It is not difficult to see that the cost of the critical path P e for e ∈ J i.e., C(P e , c) uniquely determines the value of c e for e ∈ J. However, the reduced form c has c e = 0 for e / ∈ J.
Now if d is a linear cost vector that is equivalent to c, then C(P, d) = C(P, c) for every s-t path P in the graph. In particular, this equality holds for the critical paths. This implies that c e = d e for every arc e ∈ J. Since c e = d e = 0 for e / ∈ J, we have c = d.
If an instance I = (G p,q , s, t, c, Q) of the QSPP is linearizable, then all linearizations of I are equivalent to each other. Suppose that the vector c ′ is a linearization vector of I, then the proof of Lemma 6.3 gives a recipe to calculate c ′ , which is the unique linearization vector in reduced form. This recipe uses only the costs of the critical paths to determine c ′ . Indeed, the cost of the critical path P e (e ∈ J) satisfies C(P e , c ′ ) = C(P e , c, Q), where c ′ is the linearization vector of I. The costs C(P e , c, Q) for e ∈ J can be easily obtained from the input instance.
In fact, the above calculation of the unique linear cost vector in reduced form can be implemented even the linearizability of I is not known. We call the resulting vector the pseudo-linearization vector of I, denoted by pc. It is not hard to verify that I is linearizable if and only if the pseudo-linearization vector pc is a linearization vector of I.
Let us assume from now on that the linear cost vector equals the all-zero vector, i.e., c = 0. Lemma 6.4. Let I = (G p,q , s, t, c, Q) be an instance of the QSPP. The pseudo-linearization vector pc for I can be computed in O(p 2 q + pq 2 ) time.
The following result relates linearizable instances on a directed acyclic graph having the same quadratic costs and source vertices, but different target vertices. if e = (u, w) and u = s , is a linearization vector of the instance I v = (G, s, v, c, Q) for every vertex v such that (v, t) ∈ A.
Proof. Let us assume that there is a vector c ′ such that the vector c v defined in (12) is a linearization vector of I v for v such that (v, t) ∈ A. Let P = (e 1 , e 2 , . . . , e k ) be a s-t path, where e k = (v, t). Then P v = (e 1 , e 2 , . . . , e k−1 ) is a s-v path. We have that (c v e i + 2 · q e k ,e i ) + c v e k + 2 · q e k ,e k q e k ,e i + (−c ′ e k + c v e k + 2 · q e k ,e k ) = C(P v , c, Q) + 2 · k−1 i=1 q e k ,e i = C(P, c, Q).
The fourth equation exploits that q e k ,e k = 0 and c v e k = c ′ e k . This shows that c ′ is a linearization vector of I.
Conversely, in a similar way.
Note that the above lemma is proven for any directed acyclic graph. Therefore, it is also valid for the directed grid graphs. For the directed grid graphs, we simplify notation and write I i,j for the instance I v i,j , and c i,j for the associated linear cost vector c v i,j . We also use I p,q = I and c p,q = c ′ . In what follows, we exploit the previous lemma to derive our linearization algorithm.
We first prove that any instance of the QSPP on G 2,q (q ≥ 2) is linearizable.
(i) c 2,q is a linearization vector of the instance I 2,q = (G, s, v 2,q , c, Q), (ii) c i,j = pc i,j for i = 2, . . . , p − 1 and j = 1, . . . , q − 1, where c p−1,j is the reduced form of the vector derived as in (12), and pc p−1,j is the pseudolinearization vector of I p−1,j .
By exploiting Proposition 6.8, we derive an algorithm that verifies if a QSPP instance on the directed grid graph G p,q is linearizable, see Algorithm 1. Moreover our algorithm returns the linearization vector in reduced form, if such exists. Theorem 6.9. The algorithm Linearize-grid-QSPP determines if a QSPP instance on the directed grid graph G p,q is linearizable, and if so it constructs its linearization vector in O(p 3 q 2 + p 2 q 3 ) time.
Proof. Recall that a QSPP instance is linearizable if and only if the pseudo-linearization vector is a linearization vector. Therefore, the algorithm Linearize-grid-QSPP iteratively applies Proposition 6.8 to the pseudo-linearization vector in order to check linearizability of the instance.
The algorithm involves computation of roughly p · q vectors c ij , their reduced forms c i,j , and the pseudo-linearization vectors pc ij . It follows from Lemma 6.5, that computing all the vectors c ij can be done iteratively. From Lemma 6.2 we have that the reduced form vectors c i,j obtained from the vectors c ij (i = 2, . . . , p−1, j = 1, . . . , q−1 ) can be computed in O(p 2 q 2 ). From Lemma 6.4 it follows that the calculation of all the pseudo-linearization vectors pc ij requires O(p 3 q 2 + p 2 q 3 ). The costs of all other calculations are small. Thus, the complexity of the algorithm is O(p 3 q 2 + p 2 q 3 ).
To derive Algorithm 1, we assume that the linear cost vector is equal to the all-zero vector. Clearly, our algorithm also works if the linear cost vector is not equal to zero, see Lemma 4.1. The interested reader can download Linearize-grid-QSPP and/or isLinearizable algorithm from the following link and test linearizability of any QSPP instance on G pq (p, q ≥ 2).
https://sites.google.com/site/orhuhao/home a QSPP instance on a directed grid graph is linearizable, see Theorem 6.9. The interested reader can download and test our algorithm.