Calculation of the minimum distance between a pair of given caverns