lazy implementaion of dijkstra's algorithm