an algorithm for calculating the diagonal elements of Markov chain generator matrix