Let G be a line graph, so V = {1, 2, 3, ..., n} and E = {(1, 2), (2, 3), (3, 4), ..., (n-1, n)}

Let ei = hi1 be the expected number of steps for a random walk starting at vertex i to reach vertex 1

We need to solve the recurrence equations:

We can solve this by defining di = ei - ei-1, which results in the recurrence di+1 = di -2 for 2 < i < n. Applying the initial condition e1 = 0 gives the solution di = e2 - 2(i-2), which gives

ei = (i-1)e2 - i2 + 3i -2

Plugging this into the third equation above and solving gives

ei = (i - 1)(2n - 3) - i2 + 3i - 2

This is monotonically increasing from 1 to n, and en = (n - 1)2

Reference: This is using techniques similar to those found in

Elementary probability Theory with Stochastic Pocesses
Kai Lai Chung
Springer-Verlag, 1974