Question #257921

Let R = {(1,4), (2,1), (2,5),(2,4),(4,3),(5,3),(3,2)} on the set A = {1, 2, 3, 4, 5}. Use Warshall’s algorithm to find transitive closure of R.


1
Expert's answer
2021-10-29T02:50:01-0400

Let A={1,2,3,4,5}A=\{1,2,3,4,5\} and RR be the relation on AA such that R={(1,4),(2,1),(2,5),(2,4),(4,3),(5,3),(3,2)}.R= \{(1,4),(2,1),(2,5),(2,4),(4,3),(5,3),(3,2)\}. 


Warshall's Algorithm:


Step 1: put W:=MR, k:=0.W:=M_R,\ k:=0.


Step 2: put k:=k+1.k:=k+1.


Step 3: for all iki\ne k such that wik=1,w_{ik}=1, and for all jj put wij:=wijwkj.w_{ij}:=w_{ij}\lor w_{kj}.


Step 4: if k=nk=n then STOP else go to the step 2.


Let us find the transitive closure of RR by Warshall's Algorithm:


W(0)=MR=(0001010011010000010000100)W^{(0)}=M_R=\begin{pmatrix} 0 & 0 & 0 & 1 & 0\\ 1 & 0 & 0 & 1 & 1\\ 0 & 1 & 0 & 0 & 0\\ 0 & 0 & 1 & 0 & 0\\ 0 & 0 & 1 & 0 & 0 \end{pmatrix}



W(1)=(0001010011010000010000100)W^{(1)}=\begin{pmatrix} 0 & 0 & 0 & 1 & 0\\ 1 & 0 & 0 & 1 & 1\\ 0 & 1 & 0 & 0 & 0\\ 0 & 0 & 1 & 0 & 0\\ 0 & 0 & 1 & 0 & 0 \end{pmatrix}


W(2)=(0001010011110110010000100)W^{(2)}=\begin{pmatrix} 0 & 0 & 0 & 1 & 0\\ 1 & 0 & 0 & 1 & 1\\ 1 & 1 & 0 & 1 & 1\\ 0 & 0 & 1 & 0 & 0\\ 0 & 0 & 1 & 0 & 0 \end{pmatrix}


W(3)=(0001010011110111111111111)W^{(3)}=\begin{pmatrix} 0 & 0 & 0 & 1 & 0\\ 1 & 0 & 0 & 1 & 1\\ 1 & 1 & 0 & 1 & 1\\ 1 & 1 & 1 & 1 & 1\\ 1 & 1 & 1 & 1 & 1 \end{pmatrix}


W(4)=(1111111111111111111111111)W^{(4)}=\begin{pmatrix} 1 & 1 & 1 & 1 & 1\\ 1 & 1 & 1 & 1 & 1\\ 1 & 1 & 1 & 1 & 1\\ 1 & 1 & 1 & 1 & 1\\ 1 & 1 & 1 & 1 & 1 \end{pmatrix}


MR=W(5)=(1111111111111111111111111)M_{R^*}=W^{(5)}=\begin{pmatrix} 1 & 1 & 1 & 1 & 1\\ 1 & 1 & 1 & 1 & 1\\ 1 & 1 & 1 & 1 & 1\\ 1 & 1 & 1 & 1 & 1\\ 1 & 1 & 1 & 1 & 1 \end{pmatrix}


It follows that the transitive closure RR^* of RR is the following:


R=A×A.R^*=A\times A.



Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!
LATEST TUTORIALS
APPROVED BY CLIENTS