Finding the shortest distance between points on a graph