updated the dijkstra algo in build_min_path_tree