shortest distance between two nodes in a graph