Add ShortestPath function.