Professional Documents
Culture Documents
3
Comments on the Examples
• In each of the examples, a statement is made
about a pair of objects of the same type.
(Cartesian product)
6
Relations
• A binary relation occurs when we say
something about a property of an object
relative to another object of the same type
8
Relations
9
Relations
• Directed Graph
• Let R be a relation on a finite set A
11
Relations
• Directed graph (Digraph) representation of R
• Each dot is called a vertex
• If a vertex is labeled, a, then it is also called vertex a
• An arc from a vertex labeled a, to another vertex, b is
called a directed edge, or directed arc from a to b
• The ordered pair (A , R) a directed graph, or digraph,
of the relation R, where each element of A is a called
a vertex of the digraph
12
Relations
• Directed graph (Digraph) representation of R
(Continued)
• For vertices a and b , if a R b, a is adjacent to b and b is
adjacent from a
• Because (a, a) R, an arc from a to a is drawn; because
(a, b) R, an arc is drawn from a to b. Similarly, arcs are
drawn from b to b, b to c , b to a, b to d, and c to d
• For an element a A such that (a, a) R, a directed edge
is drawn from a to a. Such a directed edge is called a loop
at vertex a
13
Relations
• Directed graph (Digraph) representation of R
(Continued)
• Position of each vertex is not important
• In the digraph of a relation R, there is a directed edge
or arc from a vertex a to a vertex b if and only if a R b
• Let A ={a ,b ,c ,d} and let R be the relation defined
by the following set:
• R = {(a ,a ), (a ,b ), (b ,b ), (b ,c ), (b ,a ), (b ,d ),
(c ,d )}
14
Relations
• Domain and Range of the Relation
• Let R be a relation from a set A into a set B. Then R ⊆ A x B. The elements of
the relation R tell which element of A is R-related to which element of B
15
Example
• Consider the relation ‘is greater than’ on the
set A = {3, 5, 6, 8}.
17
Graphical Repn of a Relation
• Example: The reln ‘>’ on the set A = {3, 5, 6, 8}
can be depicted using a graph. The elements
of A are represented by dots, & if x is related
to y, an arrow is drawn from x to y. The result
is called a directed graph.
18
Matrix Repn of a Relation
• A relation can also be represented by a matrix
(plural ‘matrices’) called the relation matrix.
19
Application: Relational Database
20
Application: Relational Database
21
Application: Relational Database
22
Properties of Relations
• There are several properties that are used to classify
relations on a set.
• In some relations an element is always related to
itself.
• For example, let R be the relation on the set of all
people consisting of pairs (x,y) where x and y has the
same father and the same mother. Then xRx for
every person x.
23
Properties of Relations
• A relation R on a set A is called reflexive if
(a,a)R for every element aA (aA), aRa.
24
Properties of Relations
Example
Consider the following relations on the {1,2,3,4}
R1 ={(1,1),(1,2),(2,1),(2,2),(3,4),(4,1),(4,4)}
R2 ={(1,1),(1,2),(2,1)}
R3 ={(1,1),(1,2),(1,4),(2,1),(2,2),(3,3),(4,1),(4,4)}
R4 ={(2,1),(3,1),(3,2),(4,1),(3,4)}
R5 ={(1,1),(1,2),(1,3),(1,4),(2,2),(2,3),(2,4),(3,3),
(3,4),(4,4)}
R6 ={(3,4)}
Which of these relations are reflexive?
The relations R3 and R5 are reflexive because they both contain 25
Properties of Relations
A relation R on a set A is symmetric
if (b,a)R whenever (a,b)R for all a,b A
ab((a,b) R → (b,a)R )
26
Properties of Relations
A relation cannot be both symmetric and antisymmetric if it
contains some pair of the form (a,b), where a≠b
example
Let R be the following relation defined on the set
{a, b, c, d}:
R = {(a, a), (a, c), (a, d), (b, a), (b, b), (b, c), (b, d), (c, b), (c, c), (d,
b), (d, d)}.
Determine whether R is:
(a) reflexive. Yes
(b) symmetric. No there is no (c,a) for example
(c) antisymmetric. No b c b d
27
Properties of Relations
A relation cannot be both symmetric and antisymmetric if it
contains some pair of the form (a,b), where a≠b
example
Let R be the following relation defined on the set
{a, b, c, d}:
R = {(a, a), (b, b), (c, c), (d, d)}.
Determine whether R is:
(a) reflexive. Yes
(b) symmetric. yes
(c) antisymmetric. yes
28
Properties of Relations
Example
Consider the following relations on the {1,2,3,4}
R1 ={(1,1),(1,2),(2,1),(2,2),(3,4),(4,1),(4,4)}
R2 ={(1,1),(1,2),(2,1)}
R3 ={(1,1),(1,2),(1,4),(2,1),(2,2),(3,3),(4,1),(4,4)}
R4 ={(2,1),(3,1),(3,2),(4,1),(3,4)}
R5 ={(1,1),(1,2),(1,3),(1,4),(2,2),(2,3),(2,4),(3,3),
(3,4),(4,4)}
R6 ={(3,4)}
Which of these relations are symmetric and which are
antisymmetric ?
R2 and R3 are symmetric because in each case (b,a) belongs to the
29
Properties of Relations
30
Properties of Relations
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 a vertex x to a vertex z
completing a triangle where each side is a directed edge with the
correct direction.
2
1
3 4
31