Solution (source code)

= Solution

Suppose $a$ and $b$ communicate. Choose $r,s$ with $P^r(a,b)>0$ and $P^s(b,a)>0$. Then $r+s$ is a possible return time to $a$, so $d(a)$ divides $r+s$. If $n$ is any possible return time to $b$, concatenating the paths gives a return to $a$ of length $r+n+s$. Thus $d(a)$ also divides $r+n+s$, and subtraction shows that $d(a)$ divides every such $n$. Therefore $d(a)\mid d(b)$. Interchanging $a$ and $b$ gives the reverse divisibility, so
$$
\boxed{d(a)=d(b)}.
$$
\b[Hence <period is constant on a communicating class>.]