dijkstra's algorithm put in a class for itself