DIJKSTRA FOR MINIMAL DISTANCE IMPLEMENTED