Initilizes a graph that represents a maps and calculates the optimal route using Dijkstra's algorithm.