Find the shortest path between two cities using Djikstra's algorithm.
Input: New York and San Francisco
The shortest path between New York and San Francisco is I-95 N, US-1 N, US-101 N, and CA-1 N. In total, this route is 3,539 miles long.
Djikstra's algorithm can be used to find the shortest path between two cities. First, the graph G = (V, E) representing the cities and the roads between them must be constructed. Then, the cost for each edge in the graph is set. The cost for a given edge (u, v) is equal to the time it takes to travel from the city ‘u’ to the city ‘v’. Next, the initial nodes {u_0} and {v_0} should be chosen, which in this case are New York and San Francisco. 

Next, the algorithm walks a given edge (u,v) with the cost c(u,v) until a node w is encountered that has a lower cost than u and v. In this case, w would be the city at the midpoint of the road between New York and San Francisco. The algorithm then looks at all edges adjacent to w (a, b, c, ...) and takes the edges with the lowest costs. When an edge from w to a is found, the algorithm continues by walking the edge towards a from w.  This process continues until all nodes are visited or a negative cost is encountered, indicating an infinite loop.

Finally, when all nodes have been visited, the shortest path between New York and San Francisco can be found.