Require: $1<N$ Require: $a,b\in \left\{0,1,2,\dots ,N-1\right\}$ Require: $W$ is a boolean array of size

$N$ with every element initially set to True

Require: ${N}_{W}$ is the number of True elements in array

$W$ (initialised to

$N$)

Require: $P\left[i,j\right]$ is the probability of branching from node

$j$ to node

$i$ Require: $\mathit{AdjIn}\left[i\right]$ and

$\mathit{AdjOut}\left[i\right]$ are the lists of indices of all nodes connected to node

$i$ via incoming and outgoing edges, respectively

Recursive function $F\left(\alpha ,\beta ,W,{N}_{W}\right)$ 1: $W\left[\beta \right]\leftarrow $ False

2: ${N}_{W}\leftarrow {N}_{W}-1$ 3: if $\alpha =\beta $ and

${N}_{W}=0$ then

4: $\Sigma \leftarrow 1$ 5: else

6: $\Sigma \leftarrow 0.0$

7: for all $i\in \mathit{AdjOut}\left[\beta \right]$ do

8: for all $j\in \mathit{AdjIn}\left[\beta \right]$ do

9: if $W\left[i\right]$ and $W\left[j\right]$ then

10: $\Sigma \leftarrow \Sigma +P\left[\beta ,j\right]F\left(j,i,W,{N}_{W}\right)P\left[i,\beta \right]$

11: end if

12: end for

13: end for

14: $\Sigma \leftarrow 1\u2215\left(1-\Sigma \right)$

15: if $\alpha \ne \beta $ then

16: $\Lambda \leftarrow 0.0$

17: for all $i\in \mathit{AdjOut}\left[\beta \right]$ do

18: if W[i] then

19: $\Lambda \leftarrow \Lambda +F\left(\alpha ,i,W,{N}_{W}\right)P\left(i,\beta \right)$

20: end if

21: end for

22: $\Sigma \leftarrow \mathit{\Sigma \Lambda}$

23: end if 24: end if 25: $W\left[\beta \right]\leftarrow $ True

26: ${N}_{W}\leftarrow {N}_{W}+1$ 27: return $\Sigma $