calc. shortest path