For the relation R = {(p,p) ,(q,p),(q,q),(r,r),(r,s),(s,s) ,(s,m) ,(m,m)} 1.Using warshall algorithm find the transitive …
Archangel Macsika
For the relation R = {(p,p) ,(q,p),(q,q),(r,r),(r,s),(s,s) ,(s,m) ,(m,m)} 1.Using warshall algorithm find the transitive closure R* of R 2.write matrix representation of R* 3.Check whether the relation of R* is an equivalence relation or a partial order.
Consider a relation R={(p,p),(q,p),(q,q),(r,r),(r,s),(s,s),(s,m),(m,m)} on the set A={p,q,r,s,m}.
1. Let us state the steps of the Warshall's algorithm:
1. LetW:=MR,k:=0.
2. Put k:=k+1.
3. For all i=k such that wik=1 and for all j let wij=wij∨wkj.
4. If k=n then stop and W=MR∗, else go to step 2.
Let us find transitive closure of the relation R using Warshall's algorithm:
W(0)=MR=⎝⎛1100001000001000011000011⎠⎞
W(1)=⎝⎛1100001000001000011000011⎠⎞
W(2)=⎝⎛1100001000001000011000011⎠⎞
W(3)=⎝⎛1100001000001000011000011⎠⎞
W(4)=⎝⎛1100001000001000011000111⎠⎞
MR∗=W(5)=⎝⎛1100001000001000011000111⎠⎞
It follows that R∗={(p,p),(q,p),(q,q),(r,r),(r,s),(r,m),(s,s),(s,m),(m,m)}.
2. Let us write the matrix representation of R∗. It follows from the previous item that
MR∗=⎝⎛1100001000001000011000111⎠⎞
3. Let us check whether the relation of R∗ is an equivalence relation.
Since (q,p)∈R∗ but (p,q)∈/R∗, we conclude that the relation is not symmetric, and hence it is not an equivalence relation.
Let us check whether the relation of R∗ is a partial order.
Since {(p,p),(q,q),(r,r),(s,s),(m,m)}⊂R∗, the relation R∗ is reflexive. Taking into account that (a,b)∈R∗ and (b,a)∈R∗ imply a=b for any (a,b),(a,b)∈R∗, we conclude that this relation is antisymmetric. Since R∗ is the transitive closure, it is transitive.