Algorithm finding the shortest distance between all pairs of points added.