returns the shortest distance between two towns in a railroad network.