Representing Relations
CMSC 56 | Discrete Mathematical Structure for Computer Science
November 14, 2018
Instructor: Allyn Joy D. Calcaben
College of Arts & Sciences
University of the Philippines Visayas
3. Representing Relations using Digraphs
Definition 1
A directed graph, or digraph, consists of a set V of vertices
(or nodes) together with a set E of ordered pairs of elements of V
called edges (or arcs). The vertex a is called the initial vertex of the
edge (a, b), and the vertex b is called the terminal vertex of this
edge.
4. Representing Relations using Digraphs
Definition 1
A directed graph, or digraph, consists of a set V of vertices
(or nodes) together with a set E of ordered pairs of elements of V
called edges (or arcs). The vertex a is called the initial vertex of the
edge (a, b), and the vertex b is called the terminal vertex of this
edge.
An edge of the form (a, a) is represented using an arc from the vertex a
back to itself. Such an edge is called a loop.
5. Example
What is 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 { 1, 2, 3, 4 }?
6. Solution
What is 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 { 1, 2, 3, 4 }?
1 2
34
7. Example
What is the ordered pairs in the
relation R represented by the
directed graph on the right?
1 2
34
8. Solution
What is the ordered pairs in the relation R
represented by the directed graph below?
1 2
34
The ordered pairs (x, y) in the relation are;
R = { (1, 3), (1, 4), (2, 1), (2, 2), (2, 3),
(3, 1), (3, 3), (4, 1), (4, 3) }
9. Reflexive Digraphs
A relation is reflexive if and only if there is a loop at every vertex
of the directed graph, so that every ordered pair of the form (x, x)
occurs in the relation.
10. Symmetric Digraphs
A relation is symmetric if and only if for every edge between
distinct vertices in its digraph there is an edge in the opposite
direction, so that (y, x) is in the relation whenever (x, y) is in
opposite directions between distinct vertices.
11. Antisymmetric Digraphs
A relation is antisymmetric if and only if there are never two
edges in opposite directions between distinct vertices.
12. Transitive Digraphs
A relation is transitive if and only if whenever there is an edge
from a vertex x to a vertex y and an edge from a vertex y to a
vertex z, there is an edge from x to z.
13. TAKE NOTE:
A symmetric relation can be represented by an undirected
graph, which is a graph where edges do not have directions.
14. Example
a b
dc
Determine whether the relations for
the directed graph are reflexive,
symmetric, antisymmetric, and/or
transitive.
15. Solution
a b
dc
Determine whether the relations for the
directed graph are reflexive, symmetric,
antisymmetric, and/or transitive.
Not Reflexive, since loops are not
present at all the vertices of the directed
graph.
Symmetric and not antisymmetric,
because every edge between distinct
vertices is accompanied by an edge in
the opposite direction.
Not transitive, (c, a) and (a, b) belong to
the directed graph, but (c, b) does not.
16. Quiz (1/8 size Paper)
a
b c
Determine whether the relations for
the directed graph are reflexive,
symmetric, antisymmetric, and/or
transitive.
17. Solution
a
b c
Determine whether the relations for the
directed graph are reflexive, symmetric,
antisymmetric, and/or transitive.
Reflexive, since there are loops at every
vertex of the directed graph.
Neither Symmetric nor antisymmetric,
because there is an edge from a to b but
not one from b to a, but there are edges
in both directions connecting b and c.
Not transitive, (a, b) and (b, c) belong to
the directed graph, but (a, c) does not.
19. Representing Relations using Matrices
A relation between finite sets can be represented using a zero-one
matrix. Suppose that R is a relation from A = { a1, a2, a3, . . . , am }
to B = { b1, b2, b3, . . . , bm } .
The relation R can be represented by the matrix MR = [mij], where
1 if (ai , bj) ∈ R
mij =
0 if (ai , bj) ∉ R
20. Example
Let A = { a1, a2, a3 } and B = { b1, b2, b3, b4, b5 }. Which ordered pairs
are in the relation R represented by the matrix?
0 1 0 0 0
MR = 1 0 1 1 0
1 0 1 0 1
21. Solution
Let A = { a1, a2, a3 } and B = { b1, b2, b3, b4, b5 }.
Which ordered pairs are in the relation R
represented by the matrix?
0 1 0 0 0
MR
= 1 0 1 1 0
1 0 1 0 1
Since R consists of those ordered pairs
(ai, bj) with mij = 1, it follows that:
R = { (a1, b2), (a2, b1), (a2, b3), (a2, b4),
(a3, b1), (a3, b3), (a3, b5),}
22. Reflexive Matrix
A relation is reflexive if and only if mii = 1, for i = 1, 2, . . ., n. In
other words, if all elements on the main diagonal of MR are equal
to 1.
23. Symmetric Matrix
A relation is symmetric if and only if mji = mij. This means that it
must be either mji = 1 whenever mij = 1 or mji = 0 whenever mij = 0.
24. Antisymmetric Matrix
A relation is antisymmetric if and only if mij = 1 with i ≠ j,
then mji = 0. Or in other words, either mij = 0 or mji = 0 when i ≠ j.
25. Example
Suppose that the relation R on a set is represented by the matrix
Is R reflexive, symmetric, and/or antisymmetric?
1 1 0
MR = 1 1 1
0 1 1
26. Solution
Suppose that the relation R on a set is
represented by the matrix
Is R reflexive, symmetric, and antisymmetric?
1 1 0
MR = 1 1 1
0 1 1
Reflexive, since all the diagonal
elements of the matrix are equal
to 1.
Symmetric, because mji = mij = 1.
Not antisymmetric, it is easy to
see that neither mij = 0 nor mji = 0
when i ≠ j.
27. Union of Matrices
The matrix representing the union of two or more relations has a
1 in the positions where either MR1
or MR2
has a 1.
MR1 U R2
= MR1
V MR2
28. Intersection of Matrices
The matrix representing the intersection of two or more relations
has a 1 in the positions where both MR1
and MR2
have a 1.
MR1 ∩ R2
= MR1
ꓥ MR2
29. Example
Suppose that the relation R1 and R2 on a set is represented by the
matrix
What are the matrices representing R1 U R2 and R1 ∩ R2 ?
1 0 1
MR1
= 1 0 0
0 1 0
1 0 1
MR2
= 0 1 1
1 0 0
30. Suppose that the relation R1 and R2 on a set is
represented by the matrix
What are the matrices representing R1 U R2 and
R1 ∩ R2 ?
Example
1 0 1
MR1
= 1 0 0
0 1 0
1 0 1
MR2
= 0 1 1
1 0 0
1 0 1
MR1 U R2
= 1 1 1
1 1 0
1 0 1
MR1 ∩ R2
= 0 0 0
0 0 0
31. Composite of Matrices
Suppose that A, B, and C have m, n, and p elements, respectively. Let
the zero-one matrices for S ◦ R, R, and S be MS ◦ R = [tij], MR = [rij], and
MS = [sij]. The ordered pair (ai, cj) belongs to S ◦ R if and only if there
is an element bk such that (ai, bk) belongs to R and (bk, cj) belongs to
S. It follows that tij = 1 if and only if rik = skj = 1 for some k.
MS ◦ R = MR
⨀ MS
32. Example
Find the matrix representing the relations S ◦ R, where the
matrices representing R and S are
1 0 1
MR = 1 1 0
0 0 0
0 1 0
MS = 0 0 1
1 0 1
33. Find the matrix representing the relations S ◦ R,
where the matrices representing R and S are
Solution
1 0 1
MR = 1 1 0
0 0 0
0 1 0
MS = 0 0 1
1 0 1
1 1 1
MS ◦ R = 0 1 1
0 0 0
The matrix for S ◦ R is
34. Power of Matrices
The matrix representing the composite of two relations can be
used to find the matrix for MRn.
MRn = MR
[n]
35. Example
Find the matrix representing the relation R2, where the matrix
representing R is
0 1 0
MR = 0 1 1
1 0 0
36. Solution
The matrix for R2 is
0 1 0
MR = 0 1 1
1 0 0
Find the matrix representing the relation R2,
where the matrix representing R is
0 1 1
MR = 1 1 1
0 1 0
40. CMSC 56 2nd LE Top 3 Scorers
79.0% Samson, Aron Miles
78.0% Honeyman, John
75.5% Gavieta, Don Michael
W Section
41. CMSC 56 2nd LE Top 3 Scorers
79.0% Samson, Aron Miles
78.0% Honeyman, John
75.5% Gavieta, Don Michael
W Section
42. CMSC 56 2nd LE Top 3 Scorers
79.0% Samson, Aron Miles
78.0% Honeyman, John
75.5% Gavieta, Don Michael
W Section
43. CMSC 56 2nd LE Top 3 Scorers
79.0% Samson, Aron Miles
78.0% Honeyman, John
75.5% Gavieta, Don Michael
W Section
44. 79.0% Samson, Aron Miles
78.0% Honeyman, John
75.5% Gavieta, Don Michael
74.0% Ngo, Ma. Gishelle Anne
72.0% Castañeda, Jayvee
CMSC 56 2nd LE Top 5 Scorers
Overall
Editor's Notes
The directed graph representing a relation can be used to determine whether the relation has various properties.
The directed graph representing a relation can be used to determine whether the relation has various properties.
The directed graph representing a relation can be used to determine whether the relation has various properties.
The directed graph representing a relation can be used to determine whether the relation has various properties.
The directed graph representing a relation can be used to determine whether the relation has various properties.
The matrix of a relation on a set, which is a square matrix, can be used to determine whether the relation has certain properties.
The matrix of a relation on a set, which is a square matrix, can be used to determine whether the relation has certain properties.
The matrix of a relation on a set, which is a square matrix, can be used to determine whether the relation has certain properties.
The matrix of a relation on a set, which is a square matrix, can be used to determine whether the relation has certain properties.
The matrix of a relation on a set, which is a square matrix, can be used to determine whether the relation has certain properties.
The matrix of a relation on a set, which is a square matrix, can be used to determine whether the relation has certain properties.
The matrix of a relation on a set, which is a square matrix, can be used to determine whether the relation has certain properties.
The matrix of a relation on a set, which is a square matrix, can be used to determine whether the relation has certain properties.