Let 𝑠𝑖 be the number of steps taken starting from node 𝑣𝑖. It is sufficient to show that 𝑠𝑢=𝑠𝑣 for any two adjacent nodes 𝑢 and 𝑣.

What happens when we change our root from 𝑢 to 𝑣? First, consider the second step: the shortest path to all nodes in 𝑉 decreases, while the shortest path to all nodes in 𝑈 increases (here, 𝑋 denotes the subtree rooted at 𝑥). Therefore, the contribution of the second step increases by 𝑆𝑈−𝑆𝑉, where 𝑆𝑋 denotes the size of subtree 𝑋.

What about the first step? Let 𝐸𝑋 be the expected time to leave subtree 𝑋 given that you start at node 𝑥.

Lemma

For every subtree 𝑋, 𝐸𝑋=2𝑆𝑋−1.

Proof: We induct. If 𝑆𝑋=1, this claim is obvious.

Otherwise, let 𝑑 be the degree of node 𝑥. Then, we expect to visit 𝑥 𝑑 times before finally leaving, which means we will start from 𝑥 and come back 𝑑−1 times. In each trip, we move to each of our children with equal probability. Therefore, we have

𝐸𝑋=(𝑑−1)[1𝑑−1∑(𝐸𝐶+1)]+1=[∑(𝐸𝐶+1)]+1=[∑2𝑆𝐶]+1=2𝑆𝑥−1

where 𝐶 denotes a child subtree of 𝑋.


To finish, notice that when moving our root from 𝑢 to 𝑣, the contribution from the first step increases by 𝐸𝑉𝑆𝑈 and decreases by 𝐸𝑈𝑆𝑉. Expanding this out, the net change to this contribution is

𝐸𝑉𝑆𝑈−𝐸𝑈𝑆𝑉=(2𝑆𝑉−1)𝑆𝑈−(2𝑆𝑈−1)𝑆𝑉=−𝑆𝑈+𝑆𝑉

which exactly cancels out the change in contribution from the second step!