<<

Malaya Journal of Matematik, Vol. 8, No. 3, 877-881, 2020

https://doi.org/10.26637/MJM0803/0024

Distance from using Hadamard product

P.A. Asharaf1* and Bindhu K. Thomas2

Abstract matrix of a graph has important applications in the field of , phylogenetic analysis, , telecommunication etc. There are nice research works on determinant, characteristic polynomial and eigen values of distance matrices. This paper describes a formula for finding the distance matrix of a simple connected undirected graph from the powers of the adjacency matrix using Hadamard product on matrices. Keywords Adjacency matrix, Distance matrix, Binary matrix , Diameter, Hadamard product, m-distance matrix. AMS Subject Classification 05C12, 05C40, 05C50, 05C62, 05B20.

1,2Mathematics Research Centre, Mary Matha Arts and Science College, Affiliated to Kannur University, Mananthavady-670645, Kerala, India. *Corresponding author: 1 [email protected]; 2 [email protected] Article History:Received 21 February 2020; Accepted 14 May 2020 ©2020 MJM.

th Contents entry of AG(m power of AG), represent the number of walks of length m between the vertices vi and v j of G. 1 Introduction...... 877 Definition 2.1. [4] The distance matrix D = (di j), of G is 2 Preliminaries...... 877 defined as,  3 Main Results...... 878 d(vi,v j), if i 6= j di j = 4 Illustration...... 879 0 , if i = j 5 Conclusion...... 880 where, d(vi,v j) is the distance between the vertices vi and v j. References...... 880 Definition 2.2. [5] The diameter of a graph G is the maximum distance between any two vertices of G and it is denote by Diam(G). 1. Introduction Definition 2.3. (Hadamard product [6]) Consider the vector The earlier study on distance matrix started by L. Graham, space Rm×n over the field R. For C,F ∈ Rm×n, the Hadamard H. O. Pollak and L. Lovasz. Now there are nice research product ◦ is a binary operation on Rm×n defined by, works on determinant, characteristic polynomial [1] and eigen values [2] of distance matrices. But so far, there are not so (C ◦ F)i j := (C)i j(F)i j, ∀i, j. much significant study on how to find distance matrix from Properties: adjacency matrix. Here we define the m-distance matrix and m×n developing a formula for finding this matrix in terms of adja- (i) (R ,◦) and (Bm×n,◦) are commutative Monoids, cency matrix. Then distance matrix can be easily calculated where Bm×n denote the set of all m × n binary matrices from these m-distance matrices. of Rm×n. We are considering a simple, connected, undirected graph (ii) C, F, E ∈ Rm×n, E ◦ (C + F) = E ◦C + E ◦ F. G = (V,E) of order n with vertex set V and edge set E through- out this paper unless otherwise specified. (iii) C, F ∈ Rm×n, k ∈ R, (kC) ◦ F = C ◦ (kF) = k(C ◦ F) (iv) For C, F ∈ Rm×n 2. Preliminaries  1, if ci j and fi j = 1 th (C ◦ F)i j = Let AG be the n × n adjacency matrix [3] of G. Then i j 0, otherwise Distance matrix from adjacency matrix using Hadamard product — 878/881

Since the first two powers of the adjacency matrix AG of By property (iv), we have 0 1 G, (AG = In,AG = AG) are binary matrices, it will be more 2 3 0 + 0 + ··· + c jD j ◦ D j + 0 + ... + 0 = 0, convenient that its other powers AG,AG,... are also be treated as binary matrices. Since, D j 6= 0, then

Definition 2.4. Let us define a function δ : R → B = {0,1} c jD j = 0 ⇒ c j = 0, ∀ j. as follows. Therefore, {D0,D1,...,Dd} is a linearly independent subset Rn×n.  0,a ≤ 0,a ∈ R of δ(a) = 1, otherwise. Theorem 3.2. Let D be the distance matrix of G = (V,E), d then D = ∑ tDt , where d = Diam(G). Let Rm×n denote the vector space of all m×n real matrices t=1 Proof. Let D be the t-distance binary matrix of G. Then tD over the real field R and Bm×n denote the set of all m × n t t m×n m×n is a matrix whose non negative entry t represent the distance binary matrices of R . Define δ : R → Bm×n as between the corresponding vertices of G. Since G is con- m×n δ(D) = (δ(D))i j := (δ(di j)), ∀i, j,D ∈ R . nected, there should be a finite distance varies from 1 to d between any two vertices of G. so, Then (Am) ∈ B , ∀m ∈ {0,1,2,...} and it is the equivalent δ G n×n d m (m) binary matrix representation of AG. Let it be denoted by AG . D = ∑ tDt . t=1  1, if there exist a walk of length m form (m)  (AG )i j = vi to v j in G  0, otherwise. Remark 3.3. If we include the zero distance in the above sum, d then D = ∑t=0 tDt . Also, for C,F ∈ B , (C ◦ F) = (C) ◦ (F). m×n δ δ δ Remark 3.4. Let W denote the subspace of all symmetric n×n Definition 2.5. Consider the graph G = (V,E) with n vertices. matrices of R such that all its diagonal entries 0. Consider Then the m-distance matrix Dm of G is an n × n symmetric the n × n binary matrices Bu,t (u < t),u,t ∈ N in W gives as binary matrix defined by, below  1, if (i, j) = (u,t) or (i, j) = (t,u)  1, if d(v ,v ) = m (But )i j = (D ) := i j 0, otherwise. m i j 0, otherwise. Then BW = {Bu,t : 1 ≤ u < t ≤ n} will be the standard basis Properties n(n−1) of W and dimension of W is 2 . Since, Dm ∈ W, it can be represented as a linear combination of elements of BW . (i) Dm ∈ Bn×n, ∀m = 0,1,2,... n−1 n (ii) D0 = In Dm = ∑ ∑ br,k,mBr,k, r=1 k=r+1 (iii) Diam(G) = maxm{m : Dm 6= 0} where br,k,m ∈ R. Also, the distance matrix D ∈ W, so  0, if i 6= j (iv) D ◦ D = n−1 n i j D , if i = j, for 0 ≤ i, j ≤ d. i D = ∑ ∑ bu,t Bu,t . (3.1) u=1t=u+1 Remark 2.6. By the property (iv), we get {D0,D1,...,Dd} n×n d as an orthogonal subset of Bn×n ⊂ R with respect to the By Theorem 3.2,D = ∑m=1 mDm, so Hadamard product. d n−1 n ! D = ∑ m ∑ ∑ br,k,mBu,k 3. Main Results m=1 r=1 k=r+1 n−1 n d ! Theorem 3.1. The set {D ,D ,...,D } is a Linearly inde- 0 1 d mbr k mBr k (3.2) n×n ∑ ∑ ∑ , , , pendent subset of the vector space R . r=1 k=r+1 m=1

Proof. If c0D0 +c1D1 +...cdDd = 0 for some c0,c1,...,cd ∈ Since BW is basis, (3.1)&(3.2) gives, R. d Then by taking Hadamard product ◦ by D j(0 ≤ j ≤ d) on bu,t = ∑ mbr,k,m. both side, m=1 This gives the relationship between scalars bu,t and br,k,m D ◦ (c D + c D + ...c D ) = 0 j 0 0 1 1 d d which are in the linear combination of D and Dm respectively, c0D j ◦ D0 + c1D j ◦ D1 + ...c jD j ◦ D j + ...cdD j ◦ Dd = 0 with respect to the basis BW .

878 Distance matrix from adjacency matrix using Hadamard product — 879/881

Lemma 3.5. Let AG be the adjacency matrix of the graph walks joining any two vertices of G which can also be joined G = (V,E). Let d = Diam(G). Then for 0 ≤ k,m ≤ d, by a walk of length fewer than m. The remaining 1’s in (m)  (m) (s) A − δ ∑m−1 A ◦ A corresponds to all the m-length  1, if there exist a walk of length m and G s=0 G G (k) (m)  paths joining vertices of G. These paths will be the shortest (A ◦A ) = a walk of length k between v and v G G i j i j m-length paths joining the vertices because those vertices can-  0, otherwise. not be joined by a path of length fewer than m. Thus the 1’s of (m)  (m) (s) (k) (m) m−1 AG −δ ∑s=0 AG ◦ AG corresponds to all the m-distance Proof. Since, (AG ◦ AG ) is a binary matrix , its entries are either 1 or 0. paths joining the vertices of G. In other words, (k) (m) (k) (m) (k) If (AG ◦ AG )i j = (AG )i j ◦ (AG )i j = 1, then (AG )i j = 1 m−1 ! (m) (m) (m) (s) and (A )i j = 1 G Dm = AG − δ ∑ AG ◦ AG . (k) s=0 (AG )i j = 1 ⇒ a walk of length k between vi and v j, (m) (AG )i j = 1 ⇒ a walk of length m between vi and v j. (k) (m) ∴ (AG ◦AG )i j = 1 ⇒ a walk of length k and a walk of length (k) (m) Theorem 3.7. Let AG be the adjacency matrix of G = (V,E) m between vi and v j. Similarly, (AG ◦ AG )i j = 0 ⇒ either (k) (m) with diameter d. Then, (AG )i j = 0 or (AG )i j = 0, which means a walk of length k or a walk of length m between vi and v j does not exist. Therefore d m−1 !! (m) (m) (s) D = ∑ m AG − δ ∑ AG ◦ AG . (k) (m) m=1 s=0 (AG ◦ AG )i j = 0, d when there does not exist a walk of length k or a walk of Proof. By Theorem 3.2, D = ∑m=1 mDm. Also, by Theorem length m between vi and v j. 3.6, By Theorem 3.2, to express the distance matrix D in terms of m−1 ! D = A(m) − δ A(m) ◦ A(s) . adjacency matrix AG, it is enough to express the m-distance m G ∑ G G s=0 matrix Dm in terms of the adjacency matrix AG. The following result gives relation between Dm and AG. Combining above two, we have

Theorem 3.6. Let AG be the adjacency matrix of G = (V,E). d m−1 !! (m) (m) (s) Let d = Diam(G), Then for 1 ≤ m ≤ d, D = ∑ m AG − δ ∑ AG ◦ AG . m=1 s=0 m−1 ! (m) (m) (s) Dm = AG − δ ∑ AG ◦ AG , s=0 This is the formula for finding the distance matrix D of where D is the m-distance matrix of G. m a graph G from the powers of its adjacency matrix using Proof. By Lemma 3.5, Hadamard product.

 1, if there exist a walk of length m and (m) (s)  4. Illustration (AG ◦AG )i j = a walk of length s between vi and v j  0, otherwise. Consider the following graph G. Then the adjacency ma-

m−1 (m) (s) Then, ∑s=0 AG ◦ AG need not be a binary matrix . But  m−1 (m) (s) δ ∑s=0 AG ◦ AG will be the equivalent binary matrix of it.

m−1 !! m−1 ! (m) (s) (m) (s) δ ∑ AG ◦ AG = δ ∑ (AG )i j ◦ (AG )i j s=0 i j s=0   1, if there exist a walk of length m between vi and v j = that can also be joined by a walk of length < m  0, otherwise.

 m−1 (m) (s) (m) Then the subtraction of δ ∑s=0 AG ◦ AG from AG re- (m) Figure 1 moves all the 1’s in AG that corresponds to the m-length

879 Distance matrix from adjacency matrix using Hadamard product — 880/881

  trix AG of G is 0 1 0 1 0 0 1 0 1 0 0 0   1 2 3 4 5 6 (2)  (2) (0) (2) (1) 0 1 0 0 0 1 D2 =A −δ A ◦ A + A ◦ A =  1 0 0 1 0 1 1 G G G G G 1 0 0 0 1 0   2 0 0 0 0 1 1 0 0 0 1 0 0   A = 3 1 0 0 1 1 0 0 0 1 0 0 0 G   4 0 0 1 0 0 0 5 1 1 1 0 0 1 2 1 2 1 2 2 6 1 1 0 0 1 0 1 2 1 0 2 2    (3) (3) (1) (3) (2) 2 1 2 1 2 1 A ◦ I + A ◦ A + A ◦ A =  G G G G G 1 0 1 1 1 0 (0) (1)   Here d = Diam(G) = 3, AG = I, AG = δ(AG) = AG 2 2 2 1 2 2 2 2 1 0 2 2 3 2 1 1 2 1 1 1 1 1 1 1 2 2 1 0 1 1 1 1 1 0 1 1     (3)  (3) (3) (1) (3) (2) 2 1 1 3 0 1 2 2 1 1 1 0 1 1 D = A − δ A ◦ I + A ◦ A + A ◦ A A = ,δ(A )=  3 G G G G G G G 1 0 0 1 1 0 G 1 0 0 1 1 0     0 0 0 0 0 0 2 1 1 1 4 2 1 1 1 1 1 1 0 0 0 1 0 0 1 1 2 0 2 3 1 1 1 0 1 1   0 0 0 0 0 0 =   0 0 1 0 1 1 0 1 0 0 0 1 0 0 0 0 0 0 0 0 0 0 1 1     0 0 0 1 0 0 (2) (1) 1 0 0 0 1 0 A ◦ A =   G G 0 0 0 0 0 0 Now 1 1 1 0 0 1   3 1 1 0 0 1 0 D = ∑ mDm = 1.D1 + 2.D2 + 3.D3 m=1     4 3 6 1 7 7 1 1 1 1 1 1 0 0 1 0 1 1 0 1 0 1 0 0 3 2 3 1 6 5 1 1 1 1 1 1 0 0 0 0 1 1 1 0 1 0 0 0         3 6 3 2 3 7 3 3 1 1 1 1 1 1 1 0 0 1 1 0 0 1 0 0 0 1 AG = ,δ(AG)=  =  + 2  1 1 3 0 1 2 1 1 1 0 1 1 0 0 1 0 0 0 1 0 0 0 1 0         7 6 7 1 6 7 1 1 1 1 1 1 1 1 1 0 0 1 0 0 0 1 0 0 7 5 3 2 7 4 1 1 1 1 1 1 1 1 0 0 1 0 0 0 1 0 0 0 0 0 0 0 0 0 0 2 1 2 1 1 0 0 1 0 1 1 0 0 0 1 0 0 2 0 2 3 1 1 0 0 0 0 1 1       0 0 0 0 0 0 1 2 0 1 1 2 1 0 0 1 1 0 +3  =   A(3) ◦ A(1) =   0 1 0 0 0 1 2 3 1 0 2 3 G G 0 0 1 0 0 0       0 0 0 0 0 0 1 1 1 2 0 1 1 1 1 0 0 1       0 0 0 1 0 0 1 1 2 3 1 0 1 1 0 0 1 0

1 1 1 1 1 1 5. Conclusion 1 1 1 0 1 1 Generally it is difficult to find the distance matrix of a large   (3) (2) 1 1 1 0 1 1 order simple undirected graph. Here we provide a formula A ◦ A =   G G 1 0 0 0 1 0 for finding the distance matrix from the adjacency matrix of   1 1 1 1 1 1 a simple, connected , undirected graph of any finite order 1 1 1 0 1 1 . A computer program can be easily written in any of the (1) (0) programming languages for computing distance matrix of the AG ◦ I = 0, D0 = AG = I graph using this formula that shall give instant result. So far (1) (1) (0) (1) (1) D1 = AG − δ(AG ◦ AG ) = AG − 0 = AG we considered only simple connected undirected graphs. We can extend this formula for weighted undirected graphs as 1 0 1 0 1 1 well as digraphs. 0 1 0 0 1 1    (2) (0) (2) (1) 1 0 1 0 1 0 A ◦ A + A ◦ A =   G G G G 0 0 0 1 0 0 References   1 1 1 0 2 0 [1] L. Graham and L. Lovasz, Distance matrix polynomials 1 1 0 0 1 1 of trees, Advances in Mathematics, 29(1978), 60–88.

880 Distance matrix from adjacency matrix using Hadamard product — 881/881

[2] Bapat, Graphs and Matrices, Universitext, Springer, 2010. [3] Narsingh Deo, with Applications to Engi- neering and Computer Science, Courier Dover Publica- tions, 2016. [4] F. Harary, Graph Theory, Addison-Wesley, 1994. [5] R. J. Wilson, Introduction to Graph Theory, 3rd ed. New York, Longman, 1985. [6] Horn, A. Roger, Johnson, R. Charles, Matrix Analysis, Cambridge University Press, 2012. [7] M. Edelberg, M. R. Garey, and R. L. Graham, On the distance matrix of a tree, Discrete Mathematics, 14(1976), 23–39. [8] R. L. Graham and H. O. Pollak, On the addressing prob- lem for loop switching, The Bell System Technical Jour- nal, 50(1971), 2495–2519.

????????? ISSN(P):2319 − 3786 Malaya Journal of Matematik ISSN(O):2321 − 5666 ?????????

881