Show that:
d+n−1D≤21(n+1)(n+2).
Let i=j, and let the shortest path between Ai and Aj be the following: Ai=Aγ0,Aγ1,…,Aγk=Aj. Let X be the set of such vertices (k+1 vertices), and let Y be the set of all other vertices (n−k−1 vertices total). The number of edges that connects vertices inside Y is not greater than Cn−k−12. All edges that connect vertices inside X are the edges of the shortest path, otherwise there exists shorter path between Ai and Aj. Therefore, there are exactly k edges.
If A∈Y, then there are 3 or less edges that connect A with vertices from X. Otherwise, there exists shorter path than the one that has k edges. Therefore, there exists not more than 3(n−k−1) edges that connect vertices from X and vertices from Y. Thus,
d≤Cn−k−12+k+3(n−k−1)≤21(n2+3n−4)−2n+1k1≤i<j≤n∑(d+2n+1di,j)Cn2d+2n+1D=21(n2+3n−4+k2−k−2kn)≤(k<n, hence kn<n2)⇒d+2n+1di,j≤21(n2+3n−4), thus≤21Cn2(n2+3n−4), so≤21Cn2(n2+3n−4).
The given inequality can be obtained by dividing inequality by Cn2 and using
n(n−1)n+1≥n−11andn2+3n−4≤n2+3n+2.