Implementation of shortest path algorithm - based on Dijkstra's algorithm.