Squared distance matrix of a weighted tree

Let $T$ be a tree with vertex set $\{1, \ldots, n\}$ such that each edge is assigned a nonzero weight. The squared distance matrix of $T,$ denoted by $\Delta,$ is the $n \times n$ matrix with $(i,j)$-element $d(i,j)^2,$ where $d(i,j)$ is the sum of the weights of the edges on the $(ij)$-path. We obtain a formula for the determinant of $\Delta.$ A formula for $\Delta^{-1}$ is also obtained, under certain conditions. The results generalize known formulas for the unweighted case.


Introduction
Let G be a connected graph with vertex set V (G) = {1, . . . , n}. The distance between vertices i, j ∈ V (G), denoted d(i, j), is the minimum length (the number of edges) of a path from i to j (or an ij-path). We set d(i, i) = 0, i = 1, . . . , n. The distance matrix D(G), or simply D, is the n × n matrix with (i, j)-element d ij = d(i, j).
A classical result of Graham and Pollak [7] asserts that if T is a tree with n vertices, then the determinant of the distance matrix D of T is (−1) n−1 (n − 1)2 n−2 . Thus the determinant depends only on the number of vertices in the tree and not on the tree itself. A formula for the inverse of the distance matrix of a tree was given by Graham and Lovász [6]. Several extensions and generalizations of these results have been proved (see, for example [1], [2], [5], [8], [9] and the references contained therein).
Let T be a tree with vertex set {1, . . . , n} and let D be the distance matrix of T. The squared distance matrix ∆ is defined to be the Hadamard product D • D, and thus has the (i, j)-element d(i, j) 2 . A formula for the determinant of ∆ was proved in [3], while the inverse and the inertia of ∆ were considered in [4].
In this paper we consider weighted trees. Let T be a tree with vertex set V (T ) = {1, . . . , n} and edge set E(T ) = {e 1 , . . . , e n−1 }. We assume that each edge is assigned a weight and let the weight assigned to e i be denoted w i , which is a nonzero real number (not necessarily positive).
For i, j ∈ V (T ), i = j, the distance d(i, j) is defined to be the sum of the weights of the edges on the (unique) ij-path. We set d(i, i) = 0, i = 1, . . . , n. Let D be the n × n distance matrix with d ij = d(i, j).
The Laplacian of T is the n × n matrix defined as follows. The rows and the columns of L are indexed by V (T ). For i = j, the (i, j)-element is 0 if i and j are not adjacent. If i and j are adjacent, and if the edge joining them is e k , then the (i, j)-element of L is set equal to −1/w k . The diagonal elements of L are defined so that L has zero row (and column) sums.
The paper is organized as follows. In this section we review some basic properties of the distance matrix of a tree such as formulas for its determinant and inverse. Some preliminary results are obtained in Section 2. Sections 3 and 4 are devoted to the determinant and the inverse of ∆, respectively.
Example Consider the tree The Laplacian of the tree is given by We let Q be the n × (n − 1) vertex-edge incidence matrix of the underlying unweighted tree, with an orientation assigned to each edge. Thus the rows and the columns of Q are indexed by V (T ) and E(T ) respectively. If i ∈ V (T ), e j ∈ E(T ), the (i, j)-element of Q is 0 if i and e j are not incident, it is 1(−1) if i and e j are incident and i is the initial (terminal) vertex of e j . It is well-known [1] that Q has rank n − 1 and any minor of Q is either 0 or ±1 (thus Q is totally unimodular).
Let F be the n × n diagonal matrix with diagonal elements w 1 , . . . , w n−1 . It can be verified that L = QF −1 Q ′ .

Lemma 1
The following assertions are true: Proof (i). The result follows from the following observation which is easily verified: If e p = {i, j} and e q = {k, ℓ} are edges of T, then equals 0 if e p and e q are distinct, and equals −2w p , if e p = e q .
(ii). We have and the proof is complete.

Theorem 2
The following assertions are true: (ii) If i w i = 0, then D is nonsingular and Proof Parts (i) and (ii) are well-known, see for example, [2]. To prove (iii), note that from (ii), It follows that Dτ = ( i w i )1 and the proof is complete.

Preliminary results
We now turn to the main results for the case of a weighted tree. Let T be a tree with vertex set V (T ) = {1, . . . , n} and edge set E(T ) = {e 1 , . . . , e n−1 }. Let w 1 , . . . , w n−1 be the edge-weights. Recall that δ i is the degree of vertex i and τ i = 2 − δ i . We write j ∼ i if vertex j is adjacent to vertex i. We letδ i be the weighted degree of i, which is defined aŝ Letδ be the n × 1 vector with componentsδ 1 , . . . ,δ n . Let ∆ be the squared distance matrix of T, which is the n × n matrix with its (i, j)-element equal to d 2 ij or equivalently, d(i, j) 2 . The next result was obtained in [4] for the unweighted case, Proof Let i ∈ {1, . . . , n} be fixed. For j = i, let γ(j) be the predecessor of j on the ij-path (in the underlying unoriented tree). Let e j be the edge {γ(j), j} and set θ j =δ j − w(e j ). We have since vertex j serves as a predecessor of δ j − 1 vertices in paths from i. Also note that We have Observe that θ j is the sum of the weights of all the edges incident to j, except the edge e j , which is on the ij-path.
, where the summation is over all vertices adjacent to j, except i. Therefore it follows that From (1)-(5) we get and the proof is complete.
Next we define the edge orientation matrix of T. We assign an orientation to each edge of T. Let e i = (p, q); e j = (r, s) be edges of T. We say that e i and e j are similarly oriented, denoted by e i ⇒ e j , if d(p, r) = d(q, s). Otherwise e i and e j are said to be oppositely oriented, denoted by e i ⇀ ↽ e j . For example, in the following diagram e i and e j are similarly oriented.
The edge orientation matrix of T is the (n − 1) × (n − 1) matrix H having the rows and the columns indexed by the edges of T. The (i, j)-element of H, denoted by h(i, j) is defined to be 1(−1) if the corresponding edges e i , e j of T are similarly (oppositely) oriented. The diagonal elements of H are set to be 1. We assume that the same orientation is used while defining the matrix H and the incidence matrix Q.
If the tree T has no vertex of degree 2, then we letτ be the diagonal matrix with diagonal elements 1/τ 1 , . . . , 1/τ n . We state some basic properties of H next, see [3].
Theorem 4 Let T be a directed tree on n vertices, let H and Q be the edge orientation matrix and the vertex-edge incidence matrix of T, respectively. Then det H = 2 n−2 n i=1 τ i . Furthermore, if T has no vertex of degree 2, then H is nonsingular and H −1 = 1 2 Q ′τ Q.
Proof For i, j ∈ {1, . . . , n − 1}, let the edge e i be from p to q and the edge e j be from r to s. Then Let d(r, s) = α. It follows from (6) that and the proof is complete.
Since the (j, j)-element of 2Dτ − 1δ ′ is −δ j , the proof is complete in this case.
Case (ii). i = j. We assume, without loss of generality, that the ij-path passes through u 1 (it is possible that which is the (i, j)-element of 2Dτ − 1δ ′ and the proof is complete.

Determinant
Our next objective is to obtain a formula for the determinant of the squared distance matrix. We first consider the case when the tree has no vertex of degree 2.
Proof We assign an orientation to the edges of the tree and let H and Q be, respectively, edge orientation matrix and the vertex-edge incidence matrix of T. Let ∆ i denote the i-th column of ∆, and let t i be the column vector with 1 at the i-th place and zeros elsewhere, i = 1, . . . , n. Then in view of Theorem 4. By Lemma 5 we have It follows from (10) and Lemma 3 that Also by Theorem 4, The proof is complete by substituting (11) and (12) in (9).
We turn to the case when there is a vertex of degree 2.
Theorem 9 Let T be a tree with vertex set V (T ) = {1, . . . , n}, edge set E(T ) = {e 1 , . . . , e n−1 }, and edge weights w 1 , . . . , w n−1 . Let q be a vertex of degree 2 and let p and r be neighbors of q. Let e i = (pq), e j = (qr). Then Proof We assume, without loss of generality, that e i is directed from p to q and e j is directed from q to r.
Let z q be the n × 1 unit vector with 1 at the q-th place and zeros elsewhere. Let ∆ q be the q-th column of ∆. We have in view of Lemma 5. It follows from (16) that Taking determinants of matrices in (17) we get Note that the i-th and the j-th columns of H are identical.
Let H(j|j) denote the submatrix obtained by deleting row j and column j , subtract column i from column j, row i from row j, and then expand the determinant along column j. Then we get Note that H(j|j) is the edge orientation matrix of the tree obtained by deleting vertex q and replacing edges e i and e j by a single edge directed from p to r in the tree. Hence by Theorem 4, It follows from (17), (18) and (19) that and the proof is complete. Proof The result follows from Theorem 9 since τ i = 0 for at least two values of i.

Inverse
We now turn to the inverse of ∆, when it exists. When the tree has no vertex of degree 2, we can give a concise formula for the inverse. We first prove some preliminary results.
For a square matrix A, we denote by cof A, the sum of the cofactors of A.
and the proof is complete.
We conclude with an example to show that the condition β = 0 is necessary in Theorem 14.
Example Consider the tree The distance matrix of the tree is given by It can be checked that det ∆ = −32γ 2 (γ 2 − 6γ − 3). Thus ∆ is singular if γ = 3 + 2