Relations & Digraphs
Product Sets
Definition: An ordered pair 𝑎𝑎, 𝑏𝑏 is a listing of the
objects/items 𝑎𝑎 and 𝑏𝑏 in a prescribed order: 𝑎𝑎 is the first
and 𝑏𝑏 is the second. (a sequence of length 2)
Definition: The ordered pairs 𝑎𝑎1, 𝑏𝑏1 and 𝑎𝑎2, 𝑏𝑏2 are
equal iff 𝑎𝑎1 = 𝑎𝑎2 and 𝑏𝑏1 = 𝑏𝑏2.
Definition: If 𝐴𝐴 and 𝐵𝐵 are two nonempty sets, we define
the product set or Cartesian product 𝐴𝐴 × 𝐵𝐵 as the set of
all ordered pairs 𝑎𝑎, 𝑏𝑏 with 𝑎𝑎 ∈ 𝐴𝐴 and 𝑏𝑏 ∈ 𝐵𝐵:
𝐴𝐴 × 𝐵𝐵 = 𝑎𝑎, 𝑏𝑏 𝑎𝑎 ∈ 𝐴𝐴 and 𝑏𝑏 ∈ 𝐵𝐵}
© S. Turaev, CSC 1700 Discrete Mathematics 2
Product Sets
Example: Let 𝐴𝐴 = 1,2,3 and 𝐵𝐵 = 𝑟𝑟, 𝑠𝑠 , then
𝐴𝐴 × 𝐵𝐵 =
𝐵𝐵 × 𝐴𝐴 =
© S. Turaev, CSC 1700 Discrete Mathematics 3
Product Sets
Theorem: For any two finite sets 𝐴𝐴 and 𝐵𝐵,
𝐴𝐴 × 𝐵𝐵 = 𝐴𝐴 ⋅ 𝐵𝐵 .
Proof: Use multiplication principle!
© S. Turaev, CSC 1700 Discrete Mathematics 4
Definitions:
 Let 𝐴𝐴 and 𝐵𝐵 be nonempty sets. A relation 𝑅𝑅 from 𝐴𝐴
to 𝐵𝐵 is a subset of 𝐴𝐴 × 𝐵𝐵.
 If 𝑅𝑅 ⊆ 𝐴𝐴 × 𝐵𝐵 and 𝑎𝑎, 𝑏𝑏 ∈ 𝑅𝑅, we say that 𝑎𝑎 is related
to 𝑏𝑏 by 𝑅𝑅, and we write 𝑎𝑎 𝑅𝑅 𝑏𝑏.
 If 𝑎𝑎 is not related to 𝑏𝑏 by 𝑅𝑅, we write 𝑎𝑎 𝑅𝑅 𝑏𝑏.
 If 𝑅𝑅 ⊆ 𝐴𝐴 × 𝐴𝐴, we say 𝑅𝑅 is a relation on 𝐴𝐴.
Relations & Digraphs
© S. Turaev, CSC 1700 Discrete Mathematics 5
Example 1: Let 𝐴𝐴 = 1,2,3 and 𝐵𝐵 = 𝑟𝑟, 𝑠𝑠 . Then
𝑅𝑅 = 1, 𝑟𝑟 , 2, 𝑠𝑠 , 3, 𝑟𝑟 ⊆ 𝐴𝐴 × 𝐵𝐵
is a relation from 𝐴𝐴 to 𝐵𝐵.
Example 2: Let 𝐴𝐴 and 𝐵𝐵 are sets of positive integer
numbers. We define the relation 𝑅𝑅 ⊆ 𝐴𝐴 × 𝐵𝐵 by
𝑎𝑎 𝑅𝑅 𝑏𝑏 ⇔ 𝑎𝑎 = 𝑏𝑏
Relations & Digraphs
© S. Turaev, CSC 1700 Discrete Mathematics 6
Example 3: Let 𝐴𝐴 = 1,2,3,4,5 . The relation 𝑅𝑅 ⊆ 𝐴𝐴 × 𝐴𝐴 is
defined by
𝑎𝑎 𝑅𝑅 𝑏𝑏 ⇔ 𝑎𝑎 < 𝑏𝑏
Then 𝑅𝑅 =
Example 4: Let 𝐴𝐴 = 1,2,3,4,5,6,7,8,9,10 . The relation
𝑅𝑅 ⊆ 𝐴𝐴 × 𝐴𝐴 is defined by
𝑎𝑎 𝑅𝑅 𝑏𝑏 ⇔ 𝑎𝑎|𝑏𝑏
Then 𝑅𝑅 =
Relations & Digraphs
© S. Turaev, CSC 1700 Discrete Mathematics 7
Definition: Let 𝑅𝑅 ⊆ 𝐴𝐴 × 𝐵𝐵 be a relation from 𝐴𝐴 to 𝐵𝐵.
 The domain of 𝑅𝑅, denoted by Dom 𝑅𝑅 , is the set of
elements in 𝐴𝐴 that are related to some element in
𝐵𝐵.
 The range of 𝑅𝑅, denoted by Ran 𝑅𝑅 , is the set of
elements in 𝐵𝐵 that are second elements of pairs in
𝑅𝑅.
Relations & Digraphs
© S. Turaev, CSC 1700 Discrete Mathematics 8
Relations & Digraphs
Example 5: Let 𝐴𝐴 = 1,2,3 and 𝐵𝐵 = 𝑟𝑟, 𝑠𝑠 .
𝑅𝑅 = 1, 𝑟𝑟 , 2, 𝑠𝑠 , 3, 𝑟𝑟
Dom R =
Ran R =
Example 6: Let 𝐴𝐴 = 1,2,3,4,5 . The relation 𝑅𝑅 ⊆ 𝐴𝐴 × 𝐴𝐴 is
defined by 𝑎𝑎 𝑅𝑅 𝑏𝑏 ⇔ 𝑎𝑎 < 𝑏𝑏
Dom R =
Ran R =
© S. Turaev, CSC 1700 Discrete Mathematics 9
The Matrix of a Relation
Definition: Let 𝐴𝐴 = 𝑎𝑎1, 𝑎𝑎2, … , 𝑎𝑎 𝑚𝑚 , 𝐵𝐵 = 𝑏𝑏1, 𝑏𝑏2, … , 𝑏𝑏𝑛𝑛
and 𝑅𝑅 ⊆ 𝐴𝐴 × 𝐵𝐵 be a relation. We represent 𝑅𝑅 by the 𝑚𝑚 ×
𝑛𝑛 matrix 𝐌𝐌𝑅𝑅 = [𝑚𝑚𝑖𝑖𝑖𝑖], which is defined by
𝑚𝑚𝑖𝑖𝑖𝑖 = �
1, 𝑎𝑎𝑖𝑖, 𝑏𝑏𝑗𝑗 ∈ 𝑅𝑅
0, 𝑎𝑎𝑖𝑖, 𝑏𝑏𝑗𝑗 ∉ 𝑅𝑅
The matrix 𝐌𝐌𝑅𝑅 is called the matrix of 𝑅𝑅.
Example: Let 𝐴𝐴 = 1,2,3 and 𝐵𝐵 = 𝑟𝑟, 𝑠𝑠 .
𝑅𝑅 = 1, 𝑟𝑟 , 2, 𝑠𝑠 , 3, 𝑟𝑟 𝐌𝐌𝑅𝑅 =
© S. Turaev, CSC 1700 Discrete Mathematics 10
The Digraph of a Relation
Definition: If 𝐴𝐴 is finite and 𝑅𝑅 ⊆ 𝐴𝐴 × 𝐴𝐴 is a relation. We
represent 𝑅𝑅 pictorially as follows:
 Draw a small circle, called a vertex/node, for each
element of 𝐴𝐴 and label the circle with the
corresponding element of 𝐴𝐴.
 Draw an arrow, called an edge, from vertex 𝑎𝑎𝑖𝑖 to
vertex 𝑎𝑎𝑗𝑗 iff 𝑎𝑎𝑖𝑖 𝑅𝑅 𝑎𝑎𝑗𝑗.
The resulting pictorial representation of 𝑅𝑅 is called a
directed graph or digraph of 𝑅𝑅.
© S. Turaev, CSC 1700 Discrete Mathematics 11
The Digraph of a Relation
Example: Let 𝐴𝐴 = 1, 2, 3, 4 and
𝑅𝑅 = 1,1 , 1,2 , 2,1 , 2,2 , 2,3 , 2,4 , 3,4 , 4,1
The digraph of 𝑅𝑅:
Example: Let 𝐴𝐴 = 1, 2, 3, 4 and
Find the relation 𝑅𝑅:
© S. Turaev, CSC 1700 Discrete Mathematics
1
2
3
4
12
The Digraph of a Relation
Definition: If 𝑅𝑅 is a relation on a set 𝐴𝐴 and 𝑎𝑎 ∈ 𝐴𝐴, then
 the in-degree of 𝑎𝑎 is the number of 𝑏𝑏 ∈ 𝐴𝐴 such that
𝑏𝑏, 𝑎𝑎 ∈ 𝑅𝑅;
 the out-degree of 𝑎𝑎 is the number of 𝑏𝑏 ∈ 𝐴𝐴 such
that 𝑎𝑎, 𝑏𝑏 ∈ 𝑅𝑅.
Example: Consider the digraph:
List in-degrees and out-degrees of all vertices.
© S. Turaev, CSC 1700 Discrete Mathematics
1
2
3
4
13
The Digraph of a Relation
Example: Let 𝐴𝐴 = 𝑎𝑎, 𝑏𝑏, 𝑐𝑐, 𝑑𝑑 and let 𝑅𝑅 be the relation on
𝐴𝐴 that has the matrix
𝐌𝐌𝑅𝑅 =
1 0
0 1
0 0
0 0
1 1
0 1
1 0
0 1
Construct the digraph of 𝑅𝑅 and list in-degrees and out-
degrees of all vertices.
© S. Turaev, CSC 1700 Discrete Mathematics 14
The Digraph of a Relation
Example: Let 𝐴𝐴 = 1,4,5 and let 𝑅𝑅 be given the digraph
Find 𝐌𝐌𝑅𝑅 and 𝑅𝑅.
© S. Turaev, CSC 1700 Discrete Mathematics
1 4
5
15
Paths in Relations & Digraphs
Definition: Suppose that 𝑅𝑅 is a relation on a set 𝐴𝐴.
A path of length 𝑛𝑛 in 𝑅𝑅 from 𝑎𝑎 to 𝑏𝑏 is a finite sequence
𝜋𝜋 ∶ 𝑎𝑎, 𝑥𝑥1, 𝑥𝑥2, … , 𝑥𝑥𝑛𝑛−1, 𝑏𝑏
beginning with 𝑎𝑎 and ending with 𝑏𝑏, such that
𝑎𝑎 𝑅𝑅 𝑥𝑥1, 𝑥𝑥1 𝑅𝑅 𝑥𝑥2, … , 𝑥𝑥𝑛𝑛−1 𝑅𝑅 𝑏𝑏.
Definition: A path that begins and ends at the same
vertex is called a cycle:
𝜋𝜋 ∶ 𝑎𝑎, 𝑥𝑥1, 𝑥𝑥2, … , 𝑥𝑥𝑛𝑛−1, 𝑎𝑎
© S. Turaev, CSC 1700 Discrete Mathematics 16
Paths in Relations & Digraphs
Example: Give the examples for paths of length 1,2,3,4
and 5.
© S. Turaev, CSC 1700 Discrete Mathematics
1 2
43
5
17
Paths in Relations & Digraphs
Definition: If 𝑛𝑛 is a fixed number, we define a relation 𝑅𝑅 𝑛𝑛
as follows: 𝑥𝑥 𝑅𝑅𝑛𝑛
𝑦𝑦 means that there is a path of length 𝑛𝑛
from 𝑥𝑥 to 𝑦𝑦.
Definition: We define a relation 𝑅𝑅∞
(connectivity relation
for 𝑅𝑅) on 𝐴𝐴 by letting 𝑥𝑥 𝑅𝑅∞
𝑦𝑦 mean that there is some
path from 𝑥𝑥 to 𝑦𝑦.
Example: Let 𝐴𝐴 = 𝑎𝑎, 𝑏𝑏, 𝑐𝑐, 𝑑𝑑, 𝑒𝑒 and
𝑅𝑅 = 𝑎𝑎, 𝑎𝑎 , 𝑎𝑎, 𝑏𝑏 , 𝑏𝑏, 𝑐𝑐 , 𝑐𝑐, 𝑒𝑒 , 𝑐𝑐, 𝑑𝑑 , 𝑑𝑑, 𝑒𝑒 .
Compute (a) 𝑅𝑅2
; (b) 𝑅𝑅3
; (c) 𝑅𝑅∞
.
© S. Turaev, CSC 1700 Discrete Mathematics 18
Paths in Relations & Digraphs
Let 𝑅𝑅 be a relation on a finite set 𝐴𝐴 = 𝑎𝑎1, 𝑎𝑎2, … , 𝑎𝑎𝑛𝑛 , and
let 𝐌𝐌𝑅𝑅 be the 𝑛𝑛 × 𝑛𝑛 matrix representing 𝑅𝑅.
Theorem 1: If 𝑅𝑅 is a relation on 𝐴𝐴 = 𝑎𝑎1, 𝑎𝑎2, … , 𝑎𝑎𝑛𝑛 , then
𝐌𝐌𝑅𝑅2 = 𝐌𝐌𝑅𝑅 ⊙ 𝐌𝐌𝑅𝑅.
Example: Let 𝐴𝐴 = 𝑎𝑎, 𝑏𝑏, 𝑐𝑐, 𝑑𝑑, 𝑒𝑒 and
𝑅𝑅 = 𝑎𝑎, 𝑎𝑎 , 𝑎𝑎, 𝑏𝑏 , 𝑏𝑏, 𝑐𝑐 , 𝑐𝑐, 𝑒𝑒 , 𝑐𝑐, 𝑑𝑑 , 𝑑𝑑, 𝑒𝑒 .
© S. Turaev, CSC 1700 Discrete Mathematics 19
Paths in Relations & Digraphs
Example: Let 𝐴𝐴 = 𝑎𝑎, 𝑏𝑏, 𝑐𝑐, 𝑑𝑑, 𝑒𝑒 and
𝑅𝑅 = 𝑎𝑎, 𝑎𝑎 , 𝑎𝑎, 𝑏𝑏 , 𝑏𝑏, 𝑐𝑐 , 𝑐𝑐, 𝑒𝑒 , 𝑐𝑐, 𝑑𝑑 , 𝑑𝑑, 𝑒𝑒 .
𝐌𝐌𝑅𝑅 =
1 1
0 0
0 0
1 0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
1
1
0
Compute 𝐌𝐌𝑅𝑅2.
© S. Turaev, CSC 1700 Discrete Mathematics 20
Reflexive & Irreflexive Relations
Definition:
 A relation 𝑅𝑅 on a set 𝐴𝐴 is reflexive if 𝑎𝑎, 𝑎𝑎 ∈ 𝑅𝑅 for
all 𝑎𝑎 ∈ 𝐴𝐴, i.e., if 𝑎𝑎 𝑅𝑅 𝑎𝑎 for all 𝑎𝑎 ∈ 𝐴𝐴.
 A relation 𝑅𝑅 on a set 𝐴𝐴 is irreflexive if 𝑎𝑎 𝑅𝑅 𝑎𝑎 for all
𝑎𝑎 ∈ 𝐴𝐴.
Example:
 Δ = 𝑎𝑎, 𝑎𝑎 | 𝑎𝑎 ∈ 𝐴𝐴 , the relation of equality on the
set 𝐴𝐴.
 𝑅𝑅 = 𝑎𝑎, 𝑏𝑏 ∈ 𝐴𝐴 × 𝐴𝐴| 𝑎𝑎 ≠ 𝑏𝑏 , the relation of
inequality on the set 𝐴𝐴.
© S. Turaev, CSC 1700 Discrete Mathematics 21
Reflexive & Irreflexive Relations
Exercise: Let 𝐴𝐴 = 1, 2, 3 , and let 𝑅𝑅 = 1,1 , 1,2 .
Is 𝑅𝑅 reflexive or irreflexive?
Exercise: How is a reflexive or irreflexive relation
identified by its matrix?
Exercise: How is a reflexive or irreflexive relation
characterized by the digraph?
© S. Turaev, CSC 1700 Discrete Mathematics 22
(A-, Anti-) Symmetric Relations
Definition:
 A relation 𝑅𝑅 on a set 𝐴𝐴 is symmetric if whenever
𝑎𝑎 𝑅𝑅 𝑏𝑏, then 𝑏𝑏 𝑅𝑅 𝑎𝑎.
 A relation 𝑅𝑅 on a set 𝐴𝐴 is asymmetric if whenever
𝑎𝑎 𝑅𝑅 𝑏𝑏, then 𝑏𝑏 𝑅𝑅 𝑎𝑎.
 A relation 𝑅𝑅 on a set 𝐴𝐴 is antisymmetric if whenever
𝑎𝑎 𝑅𝑅 𝑏𝑏 and 𝑏𝑏 𝑅𝑅 𝑎𝑎, then 𝑎𝑎 = 𝑏𝑏.
© S. Turaev, CSC 1700 Discrete Mathematics 23
(A-, Anti-) Symmetric Relations
Example: Let 𝐴𝐴 = 1, 2, 3, 4, 5, 6 and let
𝑅𝑅 = 𝑎𝑎, 𝑏𝑏 ∈ 𝐴𝐴 × 𝐴𝐴 | 𝑎𝑎 < 𝑏𝑏
Is 𝑅𝑅 symmetric, asymmetric or antisymmetric?
 Symmetry:
 Asymmetry:
 Antisymmetry:
© S. Turaev, CSC 1700 Discrete Mathematics 24
(A-, Anti-) Symmetric Relations
Example: Let 𝐴𝐴 = 1, 2, 3, 4 and let
𝑅𝑅 = 1,2 , 2,2 , 3,4 , 4,1
Is 𝑅𝑅 symmetric, asymmetric or antisymmetric?
Example: Let 𝐴𝐴 = ℤ+
and let
𝑅𝑅 = 𝑎𝑎, 𝑏𝑏 ∈ 𝐴𝐴 × 𝐴𝐴 | 𝑎𝑎 divides 𝑏𝑏
Is 𝑅𝑅 symmetric, asymmetric or antisymmetric?
© S. Turaev, CSC 1700 Discrete Mathematics 25
(A-, Anti-) Symmetric Relations
Exercise: How is a symmetric, asymmetric or
antisymmetric relation identified by its matrix?
Exercise: How is a symmetric, asymmetric or
antisymmetric relation characterized by the digraph?
© S. Turaev, CSC 1700 Discrete Mathematics 26
Transitive Relations
Definition: A relation 𝑅𝑅 on a set 𝐴𝐴 is transitive if
whenever 𝑎𝑎 𝑅𝑅 𝑏𝑏 and 𝑏𝑏 𝑅𝑅 𝑐𝑐 then 𝑎𝑎 𝑅𝑅 𝑐𝑐.
Example: Let 𝐴𝐴 = 1, 2, 3, 4 and let
𝑅𝑅 = 1,2 , 1,3 , 4,2
Is 𝑅𝑅 transitive?
Example: Let 𝐴𝐴 = ℤ+
and let
𝑅𝑅 = 𝑎𝑎, 𝑏𝑏 ∈ 𝐴𝐴 × 𝐴𝐴 | 𝑎𝑎 divides 𝑏𝑏
Is 𝑅𝑅 transitive?
© S. Turaev, CSC 1700 Discrete Mathematics 27
Transitive Relations
Exercise: Let 𝐴𝐴 = 1,2,3 and 𝑅𝑅 be the relation on 𝐴𝐴
whose matrix is
𝐌𝐌𝑅𝑅 =
1 1 1
0 0 1
0 0 1
Show that 𝑅𝑅 is transitive. (Hint: Check if 𝐌𝐌𝑅𝑅 ⊙
2
= 𝐌𝐌𝑅𝑅)
Exercise: How is a transitive relation identified by its
matrix?
Exercise: How is a transitive relation characterized by the
digraph?
© S. Turaev, CSC 1700 Discrete Mathematics 28
Equivalence Relations
Definition: A relation 𝑅𝑅 on a set 𝐴𝐴 is called an equi-
valence relation if it is reflexive, symmetric and transitive.
Example: Let 𝐴𝐴 = 1, 2, 3, 4 and let
𝑅𝑅 = 1,1 , 1,2 , 2,1 , 2,2 , 3,4 , 4,3 , 3,3 , 4,4 .
Then 𝑅𝑅 is an equivalence relation.
Example: Let 𝐴𝐴 = ℤ and let
𝑅𝑅 = 𝑎𝑎, 𝑏𝑏 ∈ 𝐴𝐴 × 𝐴𝐴 ∶ 𝑎𝑎 ≡ 𝑏𝑏 mod 2 .
Show that 𝑅𝑅 is an equivalence relation.
© S. Turaev, CSC 1700 Discrete Mathematics 29
Exercises : Relations
© S. Turaev, CSC 1700 Discrete Mathematics 30
Exercises : Relations
© S. Turaev, CSC 1700 Discrete Mathematics 31
Exercises : Relations
© S. Turaev, CSC 1700 Discrete Mathematics 32

Relations digraphs

  • 1.
  • 2.
    Product Sets Definition: Anordered pair 𝑎𝑎, 𝑏𝑏 is a listing of the objects/items 𝑎𝑎 and 𝑏𝑏 in a prescribed order: 𝑎𝑎 is the first and 𝑏𝑏 is the second. (a sequence of length 2) Definition: The ordered pairs 𝑎𝑎1, 𝑏𝑏1 and 𝑎𝑎2, 𝑏𝑏2 are equal iff 𝑎𝑎1 = 𝑎𝑎2 and 𝑏𝑏1 = 𝑏𝑏2. Definition: If 𝐴𝐴 and 𝐵𝐵 are two nonempty sets, we define the product set or Cartesian product 𝐴𝐴 × 𝐵𝐵 as the set of all ordered pairs 𝑎𝑎, 𝑏𝑏 with 𝑎𝑎 ∈ 𝐴𝐴 and 𝑏𝑏 ∈ 𝐵𝐵: 𝐴𝐴 × 𝐵𝐵 = 𝑎𝑎, 𝑏𝑏 𝑎𝑎 ∈ 𝐴𝐴 and 𝑏𝑏 ∈ 𝐵𝐵} © S. Turaev, CSC 1700 Discrete Mathematics 2
  • 3.
    Product Sets Example: Let𝐴𝐴 = 1,2,3 and 𝐵𝐵 = 𝑟𝑟, 𝑠𝑠 , then 𝐴𝐴 × 𝐵𝐵 = 𝐵𝐵 × 𝐴𝐴 = © S. Turaev, CSC 1700 Discrete Mathematics 3
  • 4.
    Product Sets Theorem: Forany two finite sets 𝐴𝐴 and 𝐵𝐵, 𝐴𝐴 × 𝐵𝐵 = 𝐴𝐴 ⋅ 𝐵𝐵 . Proof: Use multiplication principle! © S. Turaev, CSC 1700 Discrete Mathematics 4
  • 5.
    Definitions:  Let 𝐴𝐴and 𝐵𝐵 be nonempty sets. A relation 𝑅𝑅 from 𝐴𝐴 to 𝐵𝐵 is a subset of 𝐴𝐴 × 𝐵𝐵.  If 𝑅𝑅 ⊆ 𝐴𝐴 × 𝐵𝐵 and 𝑎𝑎, 𝑏𝑏 ∈ 𝑅𝑅, we say that 𝑎𝑎 is related to 𝑏𝑏 by 𝑅𝑅, and we write 𝑎𝑎 𝑅𝑅 𝑏𝑏.  If 𝑎𝑎 is not related to 𝑏𝑏 by 𝑅𝑅, we write 𝑎𝑎 𝑅𝑅 𝑏𝑏.  If 𝑅𝑅 ⊆ 𝐴𝐴 × 𝐴𝐴, we say 𝑅𝑅 is a relation on 𝐴𝐴. Relations & Digraphs © S. Turaev, CSC 1700 Discrete Mathematics 5
  • 6.
    Example 1: Let𝐴𝐴 = 1,2,3 and 𝐵𝐵 = 𝑟𝑟, 𝑠𝑠 . Then 𝑅𝑅 = 1, 𝑟𝑟 , 2, 𝑠𝑠 , 3, 𝑟𝑟 ⊆ 𝐴𝐴 × 𝐵𝐵 is a relation from 𝐴𝐴 to 𝐵𝐵. Example 2: Let 𝐴𝐴 and 𝐵𝐵 are sets of positive integer numbers. We define the relation 𝑅𝑅 ⊆ 𝐴𝐴 × 𝐵𝐵 by 𝑎𝑎 𝑅𝑅 𝑏𝑏 ⇔ 𝑎𝑎 = 𝑏𝑏 Relations & Digraphs © S. Turaev, CSC 1700 Discrete Mathematics 6
  • 7.
    Example 3: Let𝐴𝐴 = 1,2,3,4,5 . The relation 𝑅𝑅 ⊆ 𝐴𝐴 × 𝐴𝐴 is defined by 𝑎𝑎 𝑅𝑅 𝑏𝑏 ⇔ 𝑎𝑎 < 𝑏𝑏 Then 𝑅𝑅 = Example 4: Let 𝐴𝐴 = 1,2,3,4,5,6,7,8,9,10 . The relation 𝑅𝑅 ⊆ 𝐴𝐴 × 𝐴𝐴 is defined by 𝑎𝑎 𝑅𝑅 𝑏𝑏 ⇔ 𝑎𝑎|𝑏𝑏 Then 𝑅𝑅 = Relations & Digraphs © S. Turaev, CSC 1700 Discrete Mathematics 7
  • 8.
    Definition: Let 𝑅𝑅⊆ 𝐴𝐴 × 𝐵𝐵 be a relation from 𝐴𝐴 to 𝐵𝐵.  The domain of 𝑅𝑅, denoted by Dom 𝑅𝑅 , is the set of elements in 𝐴𝐴 that are related to some element in 𝐵𝐵.  The range of 𝑅𝑅, denoted by Ran 𝑅𝑅 , is the set of elements in 𝐵𝐵 that are second elements of pairs in 𝑅𝑅. Relations & Digraphs © S. Turaev, CSC 1700 Discrete Mathematics 8
  • 9.
    Relations & Digraphs Example5: Let 𝐴𝐴 = 1,2,3 and 𝐵𝐵 = 𝑟𝑟, 𝑠𝑠 . 𝑅𝑅 = 1, 𝑟𝑟 , 2, 𝑠𝑠 , 3, 𝑟𝑟 Dom R = Ran R = Example 6: Let 𝐴𝐴 = 1,2,3,4,5 . The relation 𝑅𝑅 ⊆ 𝐴𝐴 × 𝐴𝐴 is defined by 𝑎𝑎 𝑅𝑅 𝑏𝑏 ⇔ 𝑎𝑎 < 𝑏𝑏 Dom R = Ran R = © S. Turaev, CSC 1700 Discrete Mathematics 9
  • 10.
    The Matrix ofa Relation Definition: Let 𝐴𝐴 = 𝑎𝑎1, 𝑎𝑎2, … , 𝑎𝑎 𝑚𝑚 , 𝐵𝐵 = 𝑏𝑏1, 𝑏𝑏2, … , 𝑏𝑏𝑛𝑛 and 𝑅𝑅 ⊆ 𝐴𝐴 × 𝐵𝐵 be a relation. We represent 𝑅𝑅 by the 𝑚𝑚 × 𝑛𝑛 matrix 𝐌𝐌𝑅𝑅 = [𝑚𝑚𝑖𝑖𝑖𝑖], which is defined by 𝑚𝑚𝑖𝑖𝑖𝑖 = � 1, 𝑎𝑎𝑖𝑖, 𝑏𝑏𝑗𝑗 ∈ 𝑅𝑅 0, 𝑎𝑎𝑖𝑖, 𝑏𝑏𝑗𝑗 ∉ 𝑅𝑅 The matrix 𝐌𝐌𝑅𝑅 is called the matrix of 𝑅𝑅. Example: Let 𝐴𝐴 = 1,2,3 and 𝐵𝐵 = 𝑟𝑟, 𝑠𝑠 . 𝑅𝑅 = 1, 𝑟𝑟 , 2, 𝑠𝑠 , 3, 𝑟𝑟 𝐌𝐌𝑅𝑅 = © S. Turaev, CSC 1700 Discrete Mathematics 10
  • 11.
    The Digraph ofa Relation Definition: If 𝐴𝐴 is finite and 𝑅𝑅 ⊆ 𝐴𝐴 × 𝐴𝐴 is a relation. We represent 𝑅𝑅 pictorially as follows:  Draw a small circle, called a vertex/node, for each element of 𝐴𝐴 and label the circle with the corresponding element of 𝐴𝐴.  Draw an arrow, called an edge, from vertex 𝑎𝑎𝑖𝑖 to vertex 𝑎𝑎𝑗𝑗 iff 𝑎𝑎𝑖𝑖 𝑅𝑅 𝑎𝑎𝑗𝑗. The resulting pictorial representation of 𝑅𝑅 is called a directed graph or digraph of 𝑅𝑅. © S. Turaev, CSC 1700 Discrete Mathematics 11
  • 12.
    The Digraph ofa Relation Example: Let 𝐴𝐴 = 1, 2, 3, 4 and 𝑅𝑅 = 1,1 , 1,2 , 2,1 , 2,2 , 2,3 , 2,4 , 3,4 , 4,1 The digraph of 𝑅𝑅: Example: Let 𝐴𝐴 = 1, 2, 3, 4 and Find the relation 𝑅𝑅: © S. Turaev, CSC 1700 Discrete Mathematics 1 2 3 4 12
  • 13.
    The Digraph ofa Relation Definition: If 𝑅𝑅 is a relation on a set 𝐴𝐴 and 𝑎𝑎 ∈ 𝐴𝐴, then  the in-degree of 𝑎𝑎 is the number of 𝑏𝑏 ∈ 𝐴𝐴 such that 𝑏𝑏, 𝑎𝑎 ∈ 𝑅𝑅;  the out-degree of 𝑎𝑎 is the number of 𝑏𝑏 ∈ 𝐴𝐴 such that 𝑎𝑎, 𝑏𝑏 ∈ 𝑅𝑅. Example: Consider the digraph: List in-degrees and out-degrees of all vertices. © S. Turaev, CSC 1700 Discrete Mathematics 1 2 3 4 13
  • 14.
    The Digraph ofa Relation Example: Let 𝐴𝐴 = 𝑎𝑎, 𝑏𝑏, 𝑐𝑐, 𝑑𝑑 and let 𝑅𝑅 be the relation on 𝐴𝐴 that has the matrix 𝐌𝐌𝑅𝑅 = 1 0 0 1 0 0 0 0 1 1 0 1 1 0 0 1 Construct the digraph of 𝑅𝑅 and list in-degrees and out- degrees of all vertices. © S. Turaev, CSC 1700 Discrete Mathematics 14
  • 15.
    The Digraph ofa Relation Example: Let 𝐴𝐴 = 1,4,5 and let 𝑅𝑅 be given the digraph Find 𝐌𝐌𝑅𝑅 and 𝑅𝑅. © S. Turaev, CSC 1700 Discrete Mathematics 1 4 5 15
  • 16.
    Paths in Relations& Digraphs Definition: Suppose that 𝑅𝑅 is a relation on a set 𝐴𝐴. A path of length 𝑛𝑛 in 𝑅𝑅 from 𝑎𝑎 to 𝑏𝑏 is a finite sequence 𝜋𝜋 ∶ 𝑎𝑎, 𝑥𝑥1, 𝑥𝑥2, … , 𝑥𝑥𝑛𝑛−1, 𝑏𝑏 beginning with 𝑎𝑎 and ending with 𝑏𝑏, such that 𝑎𝑎 𝑅𝑅 𝑥𝑥1, 𝑥𝑥1 𝑅𝑅 𝑥𝑥2, … , 𝑥𝑥𝑛𝑛−1 𝑅𝑅 𝑏𝑏. Definition: A path that begins and ends at the same vertex is called a cycle: 𝜋𝜋 ∶ 𝑎𝑎, 𝑥𝑥1, 𝑥𝑥2, … , 𝑥𝑥𝑛𝑛−1, 𝑎𝑎 © S. Turaev, CSC 1700 Discrete Mathematics 16
  • 17.
    Paths in Relations& Digraphs Example: Give the examples for paths of length 1,2,3,4 and 5. © S. Turaev, CSC 1700 Discrete Mathematics 1 2 43 5 17
  • 18.
    Paths in Relations& Digraphs Definition: If 𝑛𝑛 is a fixed number, we define a relation 𝑅𝑅 𝑛𝑛 as follows: 𝑥𝑥 𝑅𝑅𝑛𝑛 𝑦𝑦 means that there is a path of length 𝑛𝑛 from 𝑥𝑥 to 𝑦𝑦. Definition: We define a relation 𝑅𝑅∞ (connectivity relation for 𝑅𝑅) on 𝐴𝐴 by letting 𝑥𝑥 𝑅𝑅∞ 𝑦𝑦 mean that there is some path from 𝑥𝑥 to 𝑦𝑦. Example: Let 𝐴𝐴 = 𝑎𝑎, 𝑏𝑏, 𝑐𝑐, 𝑑𝑑, 𝑒𝑒 and 𝑅𝑅 = 𝑎𝑎, 𝑎𝑎 , 𝑎𝑎, 𝑏𝑏 , 𝑏𝑏, 𝑐𝑐 , 𝑐𝑐, 𝑒𝑒 , 𝑐𝑐, 𝑑𝑑 , 𝑑𝑑, 𝑒𝑒 . Compute (a) 𝑅𝑅2 ; (b) 𝑅𝑅3 ; (c) 𝑅𝑅∞ . © S. Turaev, CSC 1700 Discrete Mathematics 18
  • 19.
    Paths in Relations& Digraphs Let 𝑅𝑅 be a relation on a finite set 𝐴𝐴 = 𝑎𝑎1, 𝑎𝑎2, … , 𝑎𝑎𝑛𝑛 , and let 𝐌𝐌𝑅𝑅 be the 𝑛𝑛 × 𝑛𝑛 matrix representing 𝑅𝑅. Theorem 1: If 𝑅𝑅 is a relation on 𝐴𝐴 = 𝑎𝑎1, 𝑎𝑎2, … , 𝑎𝑎𝑛𝑛 , then 𝐌𝐌𝑅𝑅2 = 𝐌𝐌𝑅𝑅 ⊙ 𝐌𝐌𝑅𝑅. Example: Let 𝐴𝐴 = 𝑎𝑎, 𝑏𝑏, 𝑐𝑐, 𝑑𝑑, 𝑒𝑒 and 𝑅𝑅 = 𝑎𝑎, 𝑎𝑎 , 𝑎𝑎, 𝑏𝑏 , 𝑏𝑏, 𝑐𝑐 , 𝑐𝑐, 𝑒𝑒 , 𝑐𝑐, 𝑑𝑑 , 𝑑𝑑, 𝑒𝑒 . © S. Turaev, CSC 1700 Discrete Mathematics 19
  • 20.
    Paths in Relations& Digraphs Example: Let 𝐴𝐴 = 𝑎𝑎, 𝑏𝑏, 𝑐𝑐, 𝑑𝑑, 𝑒𝑒 and 𝑅𝑅 = 𝑎𝑎, 𝑎𝑎 , 𝑎𝑎, 𝑏𝑏 , 𝑏𝑏, 𝑐𝑐 , 𝑐𝑐, 𝑒𝑒 , 𝑐𝑐, 𝑑𝑑 , 𝑑𝑑, 𝑒𝑒 . 𝐌𝐌𝑅𝑅 = 1 1 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 1 1 0 Compute 𝐌𝐌𝑅𝑅2. © S. Turaev, CSC 1700 Discrete Mathematics 20
  • 21.
    Reflexive & IrreflexiveRelations Definition:  A relation 𝑅𝑅 on a set 𝐴𝐴 is reflexive if 𝑎𝑎, 𝑎𝑎 ∈ 𝑅𝑅 for all 𝑎𝑎 ∈ 𝐴𝐴, i.e., if 𝑎𝑎 𝑅𝑅 𝑎𝑎 for all 𝑎𝑎 ∈ 𝐴𝐴.  A relation 𝑅𝑅 on a set 𝐴𝐴 is irreflexive if 𝑎𝑎 𝑅𝑅 𝑎𝑎 for all 𝑎𝑎 ∈ 𝐴𝐴. Example:  Δ = 𝑎𝑎, 𝑎𝑎 | 𝑎𝑎 ∈ 𝐴𝐴 , the relation of equality on the set 𝐴𝐴.  𝑅𝑅 = 𝑎𝑎, 𝑏𝑏 ∈ 𝐴𝐴 × 𝐴𝐴| 𝑎𝑎 ≠ 𝑏𝑏 , the relation of inequality on the set 𝐴𝐴. © S. Turaev, CSC 1700 Discrete Mathematics 21
  • 22.
    Reflexive & IrreflexiveRelations Exercise: Let 𝐴𝐴 = 1, 2, 3 , and let 𝑅𝑅 = 1,1 , 1,2 . Is 𝑅𝑅 reflexive or irreflexive? Exercise: How is a reflexive or irreflexive relation identified by its matrix? Exercise: How is a reflexive or irreflexive relation characterized by the digraph? © S. Turaev, CSC 1700 Discrete Mathematics 22
  • 23.
    (A-, Anti-) SymmetricRelations Definition:  A relation 𝑅𝑅 on a set 𝐴𝐴 is symmetric if whenever 𝑎𝑎 𝑅𝑅 𝑏𝑏, then 𝑏𝑏 𝑅𝑅 𝑎𝑎.  A relation 𝑅𝑅 on a set 𝐴𝐴 is asymmetric if whenever 𝑎𝑎 𝑅𝑅 𝑏𝑏, then 𝑏𝑏 𝑅𝑅 𝑎𝑎.  A relation 𝑅𝑅 on a set 𝐴𝐴 is antisymmetric if whenever 𝑎𝑎 𝑅𝑅 𝑏𝑏 and 𝑏𝑏 𝑅𝑅 𝑎𝑎, then 𝑎𝑎 = 𝑏𝑏. © S. Turaev, CSC 1700 Discrete Mathematics 23
  • 24.
    (A-, Anti-) SymmetricRelations Example: Let 𝐴𝐴 = 1, 2, 3, 4, 5, 6 and let 𝑅𝑅 = 𝑎𝑎, 𝑏𝑏 ∈ 𝐴𝐴 × 𝐴𝐴 | 𝑎𝑎 < 𝑏𝑏 Is 𝑅𝑅 symmetric, asymmetric or antisymmetric?  Symmetry:  Asymmetry:  Antisymmetry: © S. Turaev, CSC 1700 Discrete Mathematics 24
  • 25.
    (A-, Anti-) SymmetricRelations Example: Let 𝐴𝐴 = 1, 2, 3, 4 and let 𝑅𝑅 = 1,2 , 2,2 , 3,4 , 4,1 Is 𝑅𝑅 symmetric, asymmetric or antisymmetric? Example: Let 𝐴𝐴 = ℤ+ and let 𝑅𝑅 = 𝑎𝑎, 𝑏𝑏 ∈ 𝐴𝐴 × 𝐴𝐴 | 𝑎𝑎 divides 𝑏𝑏 Is 𝑅𝑅 symmetric, asymmetric or antisymmetric? © S. Turaev, CSC 1700 Discrete Mathematics 25
  • 26.
    (A-, Anti-) SymmetricRelations Exercise: How is a symmetric, asymmetric or antisymmetric relation identified by its matrix? Exercise: How is a symmetric, asymmetric or antisymmetric relation characterized by the digraph? © S. Turaev, CSC 1700 Discrete Mathematics 26
  • 27.
    Transitive Relations Definition: Arelation 𝑅𝑅 on a set 𝐴𝐴 is transitive if whenever 𝑎𝑎 𝑅𝑅 𝑏𝑏 and 𝑏𝑏 𝑅𝑅 𝑐𝑐 then 𝑎𝑎 𝑅𝑅 𝑐𝑐. Example: Let 𝐴𝐴 = 1, 2, 3, 4 and let 𝑅𝑅 = 1,2 , 1,3 , 4,2 Is 𝑅𝑅 transitive? Example: Let 𝐴𝐴 = ℤ+ and let 𝑅𝑅 = 𝑎𝑎, 𝑏𝑏 ∈ 𝐴𝐴 × 𝐴𝐴 | 𝑎𝑎 divides 𝑏𝑏 Is 𝑅𝑅 transitive? © S. Turaev, CSC 1700 Discrete Mathematics 27
  • 28.
    Transitive Relations Exercise: Let𝐴𝐴 = 1,2,3 and 𝑅𝑅 be the relation on 𝐴𝐴 whose matrix is 𝐌𝐌𝑅𝑅 = 1 1 1 0 0 1 0 0 1 Show that 𝑅𝑅 is transitive. (Hint: Check if 𝐌𝐌𝑅𝑅 ⊙ 2 = 𝐌𝐌𝑅𝑅) Exercise: How is a transitive relation identified by its matrix? Exercise: How is a transitive relation characterized by the digraph? © S. Turaev, CSC 1700 Discrete Mathematics 28
  • 29.
    Equivalence Relations Definition: Arelation 𝑅𝑅 on a set 𝐴𝐴 is called an equi- valence relation if it is reflexive, symmetric and transitive. Example: Let 𝐴𝐴 = 1, 2, 3, 4 and let 𝑅𝑅 = 1,1 , 1,2 , 2,1 , 2,2 , 3,4 , 4,3 , 3,3 , 4,4 . Then 𝑅𝑅 is an equivalence relation. Example: Let 𝐴𝐴 = ℤ and let 𝑅𝑅 = 𝑎𝑎, 𝑏𝑏 ∈ 𝐴𝐴 × 𝐴𝐴 ∶ 𝑎𝑎 ≡ 𝑏𝑏 mod 2 . Show that 𝑅𝑅 is an equivalence relation. © S. Turaev, CSC 1700 Discrete Mathematics 29
  • 30.
    Exercises : Relations ©S. Turaev, CSC 1700 Discrete Mathematics 30
  • 31.
    Exercises : Relations ©S. Turaev, CSC 1700 Discrete Mathematics 31
  • 32.
    Exercises : Relations ©S. Turaev, CSC 1700 Discrete Mathematics 32