Shortest Paths Between ALL Pairs of Nodes in a Connected Graph largest node number B[K] For any K, let I=A[K] and J=B[K]. So I > J. The graph must have less than M nodes. Let M - 1 be the largest allowed integer-label on any node in the graph: 0 < J < I < M J <= I - 1, I <= M - 1 J <= (M - 1) - 1 J <= M - 2 M*J + I will be an index in an array C[NN] To make C[ ] long enough to contain all values of M*J + I, for 0 < J < I < M. M*J + I <= M*(I - 1) + I <= M*I - M + I <= M*(M - 1) - M + 1 = M*M - 2M + 1 = = (M - 1)^2 < (M - 1)^2 + 1 = M^2 - 2*M + 2 = NN if M=100 then NN = 10000 - 200 + 2 = 9202 if M=50 then NN = 2500 - 100 + 2 = 2402 If the largest integer-label is less than 100, then the array C[ ] should have a length of 9202. Declare C[NN] = C[9202]. if 50, then declare C[NN] = C[2402]. *** if H = M - 1 nodes, H*(H - 1)/ 2 is the number of links in a complete graph. But (M - 1)*(M - 2) / 2 = [ M^2 - 3*M + 2 ]/2 < [M^2 - 2*M + 2]/2 = NN/2. So in any graph with less than M nodes there are less than NN linked pairs.