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)}
Here are the steps of the Warshall’s algorithm:
Step 1. Assign initial values W=MR,k=0.
Step 2. Execute k:=k+1.
Step 3. For all i=k such that wik=1, and for all j execute the operation wij=wij∨wkj.
Step 4. If k=n, then stop: we have the solution W=MR∗, else go to the step 2.
n=∣A∣=5.
W(0)=MR=⎝⎛0001001001000001010000101⎠⎞
W(1)=⎝⎛0001001001000001011000101⎠⎞
W(2)=⎝⎛0001001001000001011000101⎠⎞
W(3)=⎝⎛0001001001000001011000101⎠⎞
W(4)=⎝⎛1011001001000001011000101⎠⎞
Thus, the matrix of transitive closure of R is the following:
MR∗=W(5)=⎝⎛1011001101000001011000101⎠⎞
Therefore, the transitive closure of R is the following:
Comments