Implement Dijkstra from wiki, with mimimum assumptions about graph representation.