Let "A=\\{1,2,3,4,5\\}" and "R" be the relation on "A" such that "R=\\{(1,1),(1,4),(2,2),(3,4),(3,5),(4,1),(5,2),(5,5)\\}." Let us find the transitive closure of "R" by Warshall's Algorithm:
"W^{(0)}=M_R=\\begin{pmatrix}\n1 & 0 & 0 & 1 & 0\\\\\n0 & 1 & 0 & 0 & 0\\\\\n0 & 0 & 0 & 1 & 1\\\\\n1 & 0 & 0 & 0 & 0\\\\\n0 & 1 & 0 & 0 & 1\n\\end{pmatrix}"
"W^{(1)}=\\begin{pmatrix}\n1 & 0 & 0 & 1 & 0\\\\\n0 & 1 & 0 & 0 & 0\\\\\n0 & 0 & 0 & 1 & 1\\\\\n1 & 0 & 0 & 1 & 0\\\\\n0 & 1 & 0 & 0 & 1\n\\end{pmatrix}"
"W^{(2)}=\\begin{pmatrix}\n1 & 0 & 0 & 1 & 0\\\\\n0 & 1 & 0 & 0 & 0\\\\\n0 & 0 & 0 & 1 & 1\\\\\n1 & 0 & 0 & 1 & 0\\\\\n0 & 1 & 0 & 0 & 1\n\\end{pmatrix}"
"W^{(3)}=\\begin{pmatrix}\n1 & 0 & 0 & 1 & 0\\\\\n0 & 1 & 0 & 0 & 0\\\\\n0 & 0 & 0 & 1 & 1\\\\\n1 & 0 & 0 & 1 & 0\\\\\n0 & 1 & 0 & 0 & 1\n\\end{pmatrix}"
"W^{(4)}=\\begin{pmatrix}\n1 & 0 & 0 & 1 & 0\\\\\n0 & 1 & 0 & 0 & 0\\\\\n1 & 0 & 0 & 1 & 1\\\\\n1 & 0 & 0 & 1 & 0\\\\\n0 & 1 & 0 & 0 & 1\n\\end{pmatrix}"
"M_{R^*}=W^{(5)}=\\begin{pmatrix}\n1 & 0 & 0 & 1 & 0\\\\\n0 & 1 & 0 & 0 & 0\\\\\n1 & 1 & 0 & 1 & 1\\\\\n1 & 0 & 0 & 1 & 0\\\\\n0 & 1 & 0 & 0 & 1\n\\end{pmatrix}"
It follows that the transitive closure "R^*" of "R" is the following:
"R^*=\\{(1,1),(1,4),(2,2),(3,1),(3,2),(3,4),(3,5),(4,1),(4,4),(5,2),(5,5)\\}."
Comments
Leave a comment