140 likes | 246 Views
Representing Relations. Rosen 7.3. Using Matrices. For finite sets we can use zero-one matrices. Elements of each set A and B must be listed in some particular (but arbitrary) order. When A=B we use the same ordering for A and B. m ij = 1 if (a i ,b j ) R = 0 if (a i ,b j ) R.
E N D
Representing Relations Rosen 7.3
Using Matrices For finite sets we can use zero-one matrices. Elements of each set A and B must be listed in some particular (but arbitrary) order. When A=B we use the same ordering for A and B. mij = 1 if (ai,bj) R = 0 if (ai,bj) R
Example Zero-One Matrix b1 b2 b3 a1 a2 a3 R = {(a1,b1), (a1,b2), (a2,b2), (a3,b2), (a3,b3)}
Matrix of a relation on a set, A Can be used to determine whether the relations has certain properties. Recall that R on A is reflexive if (a,a) R for every element a A. Reflexive Not Reflexive
A relation R on a set A • is called Symmetric if (b,a) R whenever (a,b) R for a,b A. MR = (MR)t • is Antisymmetric if (a,b) R and (b,a) R only if a=b for a,b A is antisymmetric. • If mij = 1, ij, mji = 0 Symmetric Antisymmetric Neither
Examples Reflexive Symmetric Reflexive Antisymmetric
Let R1, R2 be relations on A A = {1,2,3} R1 = {(1,1), (1,3), (2,1), (3,3)} R2 = {(1,1), (1,2), (1,3), (2,2), (2,3), (3,1)}
R1R2, R1R2 MR1R2 = MR1 MR2, MR1R2 = MR1 MR2
What is R2 R1? R1 = {(1,1), (1,3), (2,1), (3,3)} R2 = {(1,1), (1,2), (1,3), (2,2), (2,3), (3,1)} The composite of R1 and R2 is the relation consisting of ordered pairs (a,c) where a A, c A, and for which there exists an element b A such that (a,b) R1 and (b,c) R2. R2 R1 = {(1,1), (1,2), (1,3), (2,1), (2,2), (2,3), (3,1)}
Boolean Product Let A = [aij] be an m by k zero-one matrix and B = [bij] be a k by n zero-one matrix. Then the Boolean Product of A and B denoted by A B is the m by n matrix with i,j entry cij where cij = (ai1b1j) (ai2 b2j) ... (aik bkj).
What is R2 R1? R2 R1 = {(1,1), (1,2), (1,3), (2,1), (2,2), (2,3), (3,1)} MR2R1 =MR1 MR2
Directed Graphs (Digraph) • A directed graph consists of a set V of vertices together with a set E of ordered pairs of elements of V called edges. • (a,b), a is initial vertex, b is the terminal vertex Reflexive (Loops at all vertices) Symmetric (All edges both ways) b a c
Relation R on a set A R = {(a,b), (b,b), (b,c), (c,a), (c,c)} Transitive? No b a c R = {(a,b), (b,b), (b,c), (a,c), (c,c)} Transitive? Yes b a Rosen, pp. 493-494 c
Relation R on a set A R = {(a,a), (a,c), (b,b), (b,a), (b,c), (c,c)} Reflexive Antisymmetric Transitive b a c