Algorithm. The adjacency matrix of the path relation [00JV]

Let M = \operatorname {\underline {mat}}_{\mathbb {B}}R be the adjacency matrix of a finite directed graph {\mathopen {}\left ({\mathopen {}\left [n\right ]\mathclose {}},R\right )\mathclose {}}. We will show that the adjacency matrix M^* of the path relation R^{\circ *} can be computed recursively using the additive and multiplicative structure of matrices. In particular, we can define M^* = M_n where M_k is computed recursively as below:

\begin {aligned} M_0 &= I^n\\ M_{k+1} &= I^n \oplus {\mathopen {}\left (M\otimes M_k\right )\mathclose {}} \end {aligned}

Thus we have a recursive algorithm that can decide whether there is a path between two elements in a finite directed graph: indeed, there is a path from s to t in R if and only if M^*_{s,t} =\mathsf {true}.