added in common function to compute expected number of links between two locations (K.Shalin code)