I have searched for quite a long time and I am not sure how to do the transitive closure. The question is from my teacher is:
Given the set A={1,2,3,4} and the relation {(1, 2), (2, 1), (2, 3), (3, 4), (4, 1)}, do the transitive closure.
My first approach was, since, the transitve closure $R^+$ = $\bigcup^n_{i=1}R^i$ where n is the number of elements in the set A, I could do $M_{R^I}$ = $M_R \cup M^2_R \cup M^3_R \cup ... \cup M^n_R$.
Doing the first matrix of $M_R$ I get $$ \begin{pmatrix} 0 & 1 & 0 & 1 \\ 1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & 1 & 0 \\ \end{pmatrix} $$
...
$M^4_R$
$$ \begin{pmatrix} 1 & 0 & 1 & 0 \\ 0 & 1 & 0 & 0 \\ 1 & 0 & 1 & 0 \\ 0 & 1 & 0 & 1 \\ \end{pmatrix} $$
Doing the reunion of the matrices from $M^1_R$ until $M^4_R$ I get a 4x4 matrix with all 1's. This meaning that the transitive closure of this relation would be all the elements connected. Is my answer correct? If not could you please tell if the problem is my approach (and suggest another) or my matrix multiplication?
Thanks, suggestions welcome!
The transitive closure is the relation that shows which nodes are reachable from a given node. Since the path $1 \to 2 \to 3 \to 4 \to 1$ exists it follows that any node can reach any other node and so $R = A^2$.