1.3 Relations 1
1.3 Relations 1
2
Cartesian Product
If A and B are two non-empty sets, then their Cartesian
product A × B is the set of all ordered pair of elements
from A and B.
A × B = {(x, y) : x ∈ A, y ∈ B}
3
Relation
• Definition: A binary relation R from set X to Y (written as XRY or R(X,Y)) is a subset of
the Cartesian product X×Y. If the ordered pair of R is reversed, the relation also changes.
It will be another binary relation F from Y X
• Generally an n-ary relation R between sets A1,…,An and is a subset of the n-ary
product A1×⋯×An. The minimum cardinality of the relation R is Zero and maximum
is n2 in this case.
• For two distinct sets, A and B, having cardinalities m and n respectively, the maximum
cardinality of a binary relation R from A to B is mn.
4
Example
• Let A and B be two sets such that A = {1, 5, 9, 13, 17} and B = {1, 2, 3, 4, 5}. Then,
• R = {(x, y): x = 4y – 3, x ∈ A and y ∈ B} (Set-builder form)
• ={(1,1),(5,2),(9,3),(13,4),(17,5)}
• Let A be the set of people in the city. Define the following relation R on A
• (a,b) ∈ R if and only if there is a sequence a0, a1, a2, ..., an of people in A such that
a0 = a, an = b and ai-1 knows ai , i= 1 ,2 , ...., n.
• Note: n will depend on a and b.
5
Domain and Range: Sets Arising from a Relation
If there are two sets A and B, and relation R is the set of ordered pair (x, y),
x∈A and y∈B
6
Example
1. Let, A={1,2,9} and B={1,3,7}
• Case 1 − If relation R is 'equal to' then R={(1,1)}
Dom(R) = {1},Ran(R)={1},
• Case 2 − If relation R is 'less than' then R={(1,3),(1,7),(2,3),(2,7)}
Dom(R) = {1,2},Ran(R)={3,7}
• Case 3 − If relation R is 'greater than' then R={(2,1),(9,1),(9,3),(9,7)}
Dom(R) = {2,9},Ran(R)={1,3,7}
7
Representing a Relation
8
Relation as a Matrix:
Let P = [a1,a2,a3,.......am] and Q = [b1,b2,b3......bn] be
finite sets, containing m and n number of elements
respectively. R is a relation from P to Q. The relation
R can be represented by m x n matrix M = [Mij],
defined as
Mij = 0 if (ai,bj) ∉ R , Mij =1 if (ai,bj )∈ R
9
Relation as a Directed Graph
Example
A = {1, 2, 3, 4}
R = {(1, 2) (2, 2) (2, 4) (3, 2) (3, 4) (4, 1) (4, 3)}
10
Do It Yourself
11
In-degree and Out-degree
12
Do It Yourself
Find the in-degree and out-degree of each of the vertices of the graph given below
13
Paths in Relation and Digraph
• A path of length n in R from a to b is a finite sequence π : a, x1, x2, ....., xn−1, b,
beginning with a and ending b, such that (a,x1)∈R, (x1,x2)∈R, ......., (xn−1,b)∈R.
• A path that begins and ends at the same vertex is called a cycle.
• Note:
• A path of length n involves (n+1) elements of A.
• All the elements of the path are not necessarily distinct.
14
Connectivity Relation
15
Solved Example
16
Boolean Product of Two Matrices
17
Relation as an Arrow Diagram
If P and Q are finite sets and R is a relation from P
to Q. Relation R can be represented as an arrow
diagram as follows.
Let P = {1, 2, 3, 4}
Q = {a, b, c, d}
R = {(1, a), (2, a), (3, a), (1, b), (4, b), (4, c), (4, d)
18