Working Dijkstra algorithm solution (slow).

This is slow, but it works, and the graph is relatively small.