------ ---- ----_ .. _- ._-_. JOURNAL OF RESEARCH of the National Bureau of Standards - B. Mathematics and Mathematical Physics Vol. 70B, No.2 , April - June 1966 Realizing the Distance Matrix of a Graph A. J. Goldman Institute for Basic Standards, National Bureau of Standards, Washington, D.C. (Fe bruar y 23, 1966) An explicit d es cription is giv en for the uniqu e graph with as few ar cs (each b ea rin g a positive length) as possibl e, whi c h h as a pre sc rib ed mat ri x of s hort est -path dis tan ces betwee n pa irs of distinct vertice s. Th e s am e is done in th e case wh en the ith dia gonal matrix e ntr y, in ste ad of be ing zero , represents the. length of a sho rt est c lo sed path co ntainin g th e ith ver tex. Key Words: Graph, di stance matrix, s hort es t path. Let G be a finite oriented graph with verti ces where n > 2. To avoid unn ecessa ry compli ca tions, we r es trict attention to connect ed graph s, i. e., if i r!= j then G co ntain s a dir ec ted path from Vi to Vj . As additional struc tur e, we assume associated to G a positive-valued func ti on lc ass igning leng ths lc(i, j) to the arcs (Vi, Vj) of G. The dist ance matrix Dc of G ha s entri es dc;(i , i) = ° on the main dia go nal; a typical off-diagonal entry dc(i, J) repersents the length of a s hort es t directed path in G from Vi to Vj . An ar c of G is called redundant if its deletion leave s Dc unc hanged. Th e gra ph G will be called irreducible if it contains no re dundant arcs. A real square matrix D with entri es d(i , j) is called realizable if there is a gr ap h G such that D = Dr;. Hakimi and Yau t showed that necess ary and s uffi cient conditions for the realizability of Dar e d(i, i) = 0, d(i , J} > ° if i r!= j, d(i, J) d(i, k) + d(k, j). (1) (2) (3) The neces sity of the se conditions should be clear. To prove sufficiency one nee d only take th e ar cs of G to be all (Vi. Vj) with i r!= j, and define le by le/i, J) = d(i , j) ; it follows readily from (1) to (3) that Dc= D. If matrix D is realizabl e, it clearly ha s a realization by an irreducible graph. Hakimi and Yau (o p. cit.) showed that this irre du cible representation was unique , but did not give an explicit d escription of it. Our first purpose in this not e is to provide such a d es cription. THEOREM 1. Let G be an irreducibl e representation ofD . Arc (Vi> Vj) is present in G if and only ifi r!= j and d(i, j) < min {d(i, k) + d(k, j) : k r!= i, j}. (4) I S. L. Hakimi and S. S. Yau, Distance matrix of a grap h and it s rea lizabilit y, Q. Applied Ma th ., Jan. 1965,305- 31 7. In this case, ldi, j) = d(i, j ). (5) We re mark that it follows that G c an be c onstru cted (s imultan eously with the chec kin g of (3)) in th e follow- ing way. Re place the zeros on the main dia go nal of D by 00, ob taining a new matrix E = (ei) ' Form £2 = (e;J») using the spec ial " matrix multipli ca ti on" often employed for s hort est -p at h problem s, i.e., e;]) = min (e ik + ekJ k (D. Ro se nblatt ha s point ed out the relation of this operation to th e Peir ce -S c hroder relative s um ; see e.g., B. Ru sse ll's " Principles of Mathemati cs . ") In vi ew of (3) .and (4), arc (Vi, Vj ) is pre se nt in G if and only if i r!= j and eij r!= eIJ); if pr ese n t, its length is gi ven by (5). We begin the proof by obs erving that G, beca use of its irreducibility, contains no ar cs of th e for m (Vi, Vi). Thus arc (Vi, Vj) can be pres e nt in C only if i r!= j. If ar c (Vi, Vj) is present in G, it cons titut es a path from Vi to Vj, and so lc(i , J) dc(i , J) = d(i , J). (6) If strict inequality held in (6), then th ere would be a s hort e st path P ij from Vi to Vj (in G) which d oes not co ntain (V i, Vj), and no path of C would be le ngth e ned if eac h appearanc e of (V i , Vj) in it were re placed by P ij . Th e refore (Vi, vJ wo uld be redundant, a contra- diction. So (5) is proved. Suppose (4) does not hold, i.e., there is a k r!= i, j such that dc;(i , j) = d(i, J) d(i, k) + d(k, J) = dc;(i, k) + dc(k , J}. (7) Let P ik be a shortest path in G from Vi to Vh' , Phj a shortest path from Vk to Vj, and Qij the composition of P ik and P kj . If arc (Vi , Vj) were present in G, then by (2), (5) and (7) it co uld not lie in Pik or Pkj , and hence not in Qu. It follows from (5) and (7) that no path in 153