Merged Dijkstra class.