Question #141743
Let A= {1,2,3,4,5,} and R be a relation on A, such that
R = [(1,4), (2,2), (3,4), (3,5), (4,1), (5,2), (5,5)]. Use warshall’s Algorithm to find the matrix of transitive closure of R
1
Expert's answer
2020-11-02T20:34:39-0500

R={(1,4),(2,2),(3,4),(3,5),(4,1),(5,2),(5,5)}R = \{(1,4), (2,2), (3,4), (3,5), (4,1), (5,2), (5,5)\}


Here are the steps of the Warshall’s algorithm:


Step 1. Assign initial values W=MR,k=0W=M_R, k=0.


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


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


Step 4. If k=nk=n, then stop: we have the solution W=MRW=M_{R^*}, else go to the step 2.



n=A=5.n=|A|=5.


W(0)=MR=(0001001000000111000001001)W^{(0)}=M_R=\left(\begin{array} {cccccc} 0 & 0 & 0 & 1 & 0 \\ 0 & 1 & 0 & 0 & 0 \\ 0 & 0 & 0 & 1 & 1 \\ 1 & 0 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 & 1 \end{array}\right)



W(1)=(0001001000000111001001001)W^{(1)}=\left(\begin{array} {cccccc} 0 & 0 & 0 & 1 & 0 \\ 0 & 1 & 0 & 0 & 0 \\ 0 & 0 & 0 & 1 & 1 \\ 1 & 0 & 0 & 1 & 0 \\ 0 & 1 & 0 & 0 & 1 \end{array}\right)



W(2)=(0001001000000111001001001)W^{(2)}=\left(\begin{array} {cccccc} 0 & 0 & 0 & 1 & 0 \\ 0 & 1 & 0 & 0 & 0 \\ 0 & 0 & 0 & 1 & 1 \\ 1 & 0 & 0 & 1 & 0 \\ 0 & 1 & 0 & 0 & 1 \end{array}\right)



W(3)=(0001001000000111001001001)W^{(3)}=\left(\begin{array} {cccccc} 0 & 0 & 0 & 1 & 0 \\ 0 & 1 & 0 & 0 & 0 \\ 0 & 0 & 0 & 1 & 1 \\ 1 & 0 & 0 & 1 & 0 \\ 0 & 1 & 0 & 0 & 1 \end{array}\right)


W(4)=(1001001000100111001001001)W^{(4)}=\left(\begin{array} {cccccc} 1 & 0 & 0 & 1 & 0 \\ 0 & 1 & 0 & 0 & 0 \\ 1 & 0 & 0 & 1 & 1 \\ 1 & 0 & 0 & 1 & 0 \\ 0 & 1 & 0 & 0 & 1 \end{array}\right)


Thus, the matrix of transitive closure of RR is the following:


MR=W(5)=(1001001000110111001001001)M_{R^*}=W^{(5)}=\left(\begin{array} {cccccc} 1 & 0 & 0 & 1 & 0 \\ 0 & 1 & 0 & 0 & 0 \\ 1 & 1 & 0 & 1 & 1 \\ 1 & 0 & 0 & 1 & 0 \\ 0 & 1 & 0 & 0 & 1 \end{array}\right)



Therefore, the transitive closure of RR 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)}R^* = \{(1,1),(1,4), (2,2),(3,1),(3,2), (3,4), (3,5), (4,1),(4,4), (5,2), (5,5)\}





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