Added shortest path function.