DM - Lecture 07 (1) Part 1
DM - Lecture 07 (1) Part 1
12/01/23 1
Representing Relations
Two methods are generally used to represent
relations
Representing relations using matrices
Pictorial representation
Graphs
Arrow Graphs
Digraphs
2
Matrix Representation of a Relation
A relation between finite sets can be represented using
a zero-one matrix
3
Representing Relations
Example: Let A = {1,2,3} and B = {x,y}
Let R be a relation from A to B defined as
R = {(1, x), (2, x), (2, y), (3,x)}
12/01/23 4
Representing Relations
Example: Let A={a1, a2, a3} and B={b1, b2, b3, b4}
Which ordered pairs are in the relation R represented by the
matrix
12/01/23 5
Representing Relations
Square matrix of a relation can be used for determining whether
the relation has certain properties
R is reflexive if all the elements on the main diagonal of MR are
equal to 1
R is symmetric if and only if mji = 1 whenever mij = 1
R is antisymmetric if mji = 1 with i not equal j then mij = 0
12/01/23 6
Representing Relations
R is not antisymmetric
12/01/23 7
Representing Relations
These matrices are symmetric or not?
1 0 1 1 1 1 0 0
0 1 0 0 1 1 0 0
MR MR
1 0 0 1 1 1 0 0
1 0 1 1 1 1 0 0
symmetric matrix, non-symmetric matrix,
symmetric relation. non-symmetric relation.
12/01/23 8
Representing Relations
The matrices representing the union and the
intersection of two relations
To obtain the Union of two zero-one matrices, we apply
the Boolean “or” function to all corresponding elements in
the matrices
To obtain the intersection of two zero-one matrices, we
apply the Boolean “and” function to all corresponding
elements in the matrices.
12/01/23 9
Representing Relations
Example: Let the relations R and S be represented
by the matrices
1 0 1 1 0 1
M R 1 0 0 M S 0 1 1
0 1 0 1 0 0
12/01/23 11
Representing Relations Using Digraphs
Example: Display the digraph with V = {a, b, c, d},
E = {(a, b), (a, d), (b, b), (b, d), (c, a), (c, b), (d, b)}.
a
b
d c
12/01/23 13
The directed graph of the relation
R = {(1, 1), (1, 3), (2, 1), (2, 3), (2, 4), (3, 1), (3, 2),
(4, 1)} on the set A= {1, 2, 3, 4} is
What are the ordered pairs in the relation R
represented by the directed graph shown below.
R = {(1, 3), (1, 4), (2, 1), (2, 2), (2, 3), (3, 1), (3, 3), (4, 1),
(4, 3)}
Determine whether the relations for the directed
graphs shown below are reflexive, symmetric,
antisymmetric, and/or transitive.