In order to minimize the total path lengths, the path from the root to each node must be a
shortest path connecting them. Otherwise, we substitute such a path with a shortest path, and get
a “lighter” spanning tree whose total path lengths from the root to all nodes are smaller.