Download as pdf or txt
Download as pdf or txt
You are on page 1of 10

2.

1 Relations and
Digraphs

1
Matrix of a Relation
If A={a1, a2,…am} and B={b1, b2,…bn} are finite sets
containing m and n elements, respectively, and R is a relation
from A to B, we represent R by the m x n matrix MR = [mij],
which is defined by:

1 if (ai, bj) ∈ R
Mij =
0 if (ai, bj) ∉ R

2
Matrix of a Relation, cont.
Example:
Let A={a,b, c, d}, B={1, 2, 3} and R={(a,1), (a,2), (b,1),
(c,2), (d,1)}. Find the matrix of R, MR.
Solution:
1 2 3

MR =

3
Matrix of a Relation, cont.
Example:
Let A={a,b,c,d,e} and let R be the relation on A that has the
matrix
Find the relation R.

Solution:
a b c d e
R={(a,a),(a,b),(b,c),(b,d),(c,d),
(c,e),(d,b),(d,c),(e,a)}

4
Digraph of a Relation
If A is a finite set and R is a relation on A, we can represent R
by a directed graph or digraph.
Steps in creating a digraph of R:
1. Draw a small circle for each element of A and label the
circle with the corresponding element of A. These circles are
called vertices.
2. Draw an arrow, called an edge, from vertex ai to vertex aj if
and only if ai R aj.

5
Digraph of a Relation, cont.
Example:
Let
A={1,2,3,4}
R={(1,1),(1,2),(2,1),(2,2),(2,3),(2,4),(3,4),(4,1)}
Draw a digraph for R.
Solution:

6
Digraph of a Relation, cont.
Example:
Find the relation determined by the given digraph and find its
MR .
Solution:
R={(1,2),(2,2),(2,3),(3,4),(4,4),(5,1),(5,4)}
1 2 3 4 5
1 0 1 0 0 0
2 0 1 1 0 0
MR = 3 0 0 0 1 0
4 0 0 0 1 0
5 1 0 0 1 0
7
In-degree/Out-degree
If R is a relation on a set A and a ∈A, then:
In-degree of a (relative to the relation R) is the number of
b∈A such that (b,a)∈R or in-degree of a vertex is the
number of edges terminating at that vertex.
Out-degree of a is the number of b∈A such that (a,b)∈R or
out-degree of a vertex is the number of edges leaving the
vertex.

8
In-degree/Out-degree, cont.
Example:
For the given digraph, find the in-degree and out-degree of all
vertices.
Solution:

1 2 3 4 5
In-degree 1 2 1 3 0
Out-degree 1 2 1 1 2

9
Restriction
If R is a relation on a set A, and B is a subset of A,
the restriction of R to B is R ∩ (B x B)
Example:
Let A={a,b,c,d,e,f} and R={(a,a),(a,c),(b,a),(a,e),(b,e),(c,e)}.
Let B={a,b,c}, find the restriction of R to B.
Solution:
B x B = {(a,a),(a,b),(a,c),(b,a),(b,b),(b,c),(c,a),(c,b),(c,c)}
the restriction R to B, R ∩ (B x B) = {(a,a),(a,c),(b,a)}

10

You might also like