UNIT-II-Relations and Graphs Notes
UNIT-II-Relations and Graphs Notes
SET THEORY(Review)
SET: A collection of well defined objects is called set.
Eg: Collection of even natural numbers
𝐴 = 0, 2, 4, 6, 8, … . = 𝑥 ∈ ℕ 𝑥 𝑖𝑠 𝑒𝑣𝑒𝑛}, where ℕ is set of
natural numbers.
Null set or Empty set: The Null set or the empty set is the set
containing no elements. It is denoted by { } or ∅.
For example: 𝐴 = 𝑥 𝑥 𝑖𝑠 𝑎𝑛 𝑖𝑛𝑡𝑒𝑔𝑒𝑟 𝑏𝑒𝑡𝑤𝑒𝑒𝑛 15 𝑎𝑛𝑑 16} = { }
Universal Set: The universal set is the set of all elements. It is
denoted as 𝑈.
Subset: What about the sets 𝐴 = {1, 2, 3} and 𝐵 = 1, 2, 3, 4 ?
Clearly 𝐴 , 𝐵 are not equal, but notice that every element of A is
also an element of B. Because of this we say that A is a subset of B,
or in symbols 𝐴 ⊆ 𝐵.
Note:
1. Set A is subset of itself.
2. For any set A, ∅ ⊆ A (i.e., empty set is a subset of A).
3. If 𝐴 ⊆ B and B ⊆ A, then 𝐴 = 𝐵.
Power set: If you collect all these subsets of A into a new set,
we get a set of sets. We call the set of all subsets of A the power
set of A, and write it 𝒫(𝐴).
The set of all subsets of a given set is called power set.
For 𝐴 = 1,2,3 ,
𝒫 𝐴 = ∅, 1 , 2 , 3 , 1,2 , 2,3 , 1,3 , 1,2,3
Cardinality of a set: The number of elements in a set A is called
cardinality of A. It is denoted as |𝐴|.
Ex: If 𝐴 = 1,2,3 , 𝐴 = 3.
i .e., 𝐴ҧ = 𝑥 𝑥 ∈ 𝑈 , 𝑥 ∉ 𝐴}
𝐴ҧ
AAA
A
Symmetric difference:
The symmetric difference of sets A and B, denoted by 𝐴⨁𝐵,
consists of those elements which belong to A or B not to both.
De-Morgan’s Law:
(i) 𝐴 ∩ 𝐵 = 𝐴ҧ ∪ 𝐵ത
(ii) 𝐴 ∪ 𝐵 = 𝐴ҧ ∩ 𝐵ത
Product set:
If A and B are two nonempty sets, then the product set or
Cartesian product 𝐴 × 𝐵 is the set of all ordered pairs (𝑎, 𝑏) with
𝑎 ∈ 𝐴 and 𝑏 ∈ 𝐵. Thus
𝐴×𝐵 = 𝑎, 𝑏 𝑎 ∈ 𝐴 and 𝑏 ∈ 𝐵}.
Example: 1. Let 𝐴 = 1,2,3 𝑎𝑛𝑑 𝐵 = {𝑟, 𝑠}
then 𝐴×𝐵 = 1, 𝑟 , 1, 𝑠 , 2, 𝑟 , 2, 𝑠 , 3, 𝑟 , 3, 𝑠
also 𝐵 × 𝐴 = { 𝑟, 1 , 𝑟, 2 , 𝑟, 3 , 𝑠, 1 , 𝑠, 2 , 𝑠, 3 }
Note:
1. In general, (𝑎, 𝑏) ≠ (𝑏, 𝑎), so for two different sets A and B, 𝐴 ×
𝐵 ≠ 𝐵 × 𝐴.
2. a, b = (c, d) if and only if a = c and b = d.
3. A × B = A ∙ B = |B × A|.
4. For a set A, 𝐴 × 𝐴 = 𝑎, 𝑏 𝑎, 𝑏 ∈ 𝐴}
Ex: If 𝐴 = 1,0,2
𝐴 × 𝐴 = { 1,1 , 1, 0 , 1, 2 , 0, 1 , 0, 0 , 0, 2 , 2,1 , 2,0 , 2,2 }
5. Cartesian product 𝐴1 × 𝐴2 × ⋯ × 𝐴𝑛 of the nonempty sets
𝐴1 , 𝐴2 , … , 𝐴𝑛 is the set of all ordered n-tuples (𝑎1 , 𝑎2 , … , 𝑎𝑛 ), where
𝑎𝑖 ∈ 𝐴𝑖 , 𝑖 = 1,2, … , 𝑛.
Thus
𝐴1 × 𝐴2 × ⋯ × 𝐴𝑛 = {(𝑎1 , 𝑎2 , … , 𝑎𝑛 )| 𝑎𝑖 ∈ 𝐴𝑖 , 𝑖 = 1,2, … , 𝑛}.
Definition:
Let A and B be nonempty sets. A relation (or binary relation) R from
A to B is a subset of 𝐴 × 𝐵.
• If 𝑅 ⊆ 𝐴 × 𝐵 𝑎𝑛𝑑 𝑎, 𝑏 ∈ 𝑅, we say that a is related to b by R,
we also write 𝑎 𝑅 𝑏.
• If a is not related to b by R (i.e., 𝑎, 𝑏 ∉ 𝑅) , we write 𝑎 R b.
If 𝑅 ⊆ 𝐴 × 𝐴, we simply say that R is relation on A, instead of
relation from A to A.
Examples:
1. Let 𝐴 = 1, 2, 3 and 𝐵 = {𝑟, 𝑠}.
Then 𝑅 = 1, 𝑟 , 2, 𝑠 , 3, 𝑟 is a relation from A to B.
2. Let 𝐴 = 1, 2, 3, 4, 5 . Define the following relation R (less than) on
A: 𝑎 𝑅 𝑏 if and only if 𝑎 < 𝑏.
Then,
𝑅 = { 1, 2 , 1, 3 , 1, 4 , 1, 5 , 2, 3 , 2, 5 , 2, 4 , 3, 4 , 3, 5 , (4, 5)}.
4. Let 𝐴 = ℤ+ , the set of all positive integers.
Define the following relation R on A:
𝑎 𝑅 𝑏 if and only if "𝑎 𝒅𝒊𝒗𝒊𝒅𝒆𝒔 𝑏“.
Then 4 𝑅 12, 𝑏𝑢𝑡 5 𝑅 7.
5. Let 𝐴 = ℝ, the set of real numbers. We define the following relation
R on A:
𝑥2 𝑦2
𝑥𝑅𝑦 if and only if 𝑥 𝑎𝑛𝑑 𝑦 𝑠𝑎𝑡𝑖𝑠𝑓𝑦 𝑡ℎ𝑒 𝑒𝑞𝑢𝑎𝑡𝑖𝑜𝑛 + = 1.
4 9
𝑥2 𝑦2
The set R consists of all points on the ellipse + = 1.
4 9
The Matrix Representation of a Relation:
The relation between finite sets can be represented using a zero-one
matrix.
If 𝐴 = 𝑎1 , 𝑎2 , … , 𝑎𝑚 and B = 𝑏1 , 𝑏2 , … , 𝑏𝑛 are finite sets
containing 𝑚 and 𝑛 elements, respectively, and 𝑅 is a relation from 𝐴
to 𝐵. The relation R can be represented by the matrix 𝑴𝑹 = 𝑚𝑖𝑗 ,
1 𝑖𝑓 (𝑎𝑖 , 𝑏𝑗 ) ∈ 𝑅
𝑤ℎ𝑒𝑟𝑒 𝑚𝑖𝑗 = ൝
0 𝑖𝑓 (𝑎𝑖 , 𝑏𝑗 ) ∉ 𝑅
1 0
Then the matrix of 𝑅 is: 𝑴𝑹 = 0 1 .
1 0
1 0 0 1
𝑴= 0 1 1 0
1 0 1 0
Since order of 𝑴 is 3 × 4, we let
𝐴 = 𝑎1 , 𝑎2 , 𝑎3 and B = 𝑏1 , 𝑏2 , 𝑏3 , 𝑏4
Then (𝑎𝑖 , 𝑏𝑗 ) ∈ 𝑅 if and only if 𝑚𝑖𝑗 = 1. Thus
𝑅= 𝑎1 , 𝑏1 , 𝑎1 , 𝑏4 , 𝑎2 , 𝑏2 , 𝑎2 , 𝑏3 , 𝑎3 , 𝑏1 , 𝑎3 , 𝑏3 .
The Digraph Representation of a Relation:
If 𝐴 is a finite set and 𝑅 is a relation on 𝐴 𝑖. 𝑒. , 𝑅 ⊆ 𝐴 × 𝐴 , we
can also represent 𝑅 pictorially as follows.
• Draw a small circle for each element of 𝐴. These circles are
called vertices.
• Draw an arrow called an edge, from vertex 𝑎𝑖 to 𝑎𝑗 if and only if
𝑎𝑖 𝑅 𝑎𝑗 .
• The resulting pictorial representation of 𝑅 is called a directed
graph or digraph of 𝑅.
Thus, if 𝑅 is a relation on 𝐴, the edges in the digraph of 𝑅 correspond
exactly to the pairs in 𝑅, and the vertices correspond exactly to the
elements of the set 𝐴.
1 3
1 3
4
In-degree and Out-degree of vertices:
If 𝑅 is a relation on a set 𝐴 and 𝒂 ∈ 𝑨, then
• the in-degree of 𝑎 (relative to the relation 𝑅) is the number of 𝑏 ∈
𝐴 such that 𝑏, 𝑎 ∈ 𝑅.
• The out-degree of 𝑎 is the number of 𝑏 ∈ 𝐴 such that 𝑎, 𝑏 ∈ 𝑅.
In other words, the in-degree of a vertex is the number of edges
terminating at the vertex. The out-degree of a vertex is the number of
edges leaving the vertex.
Example:
1. Consider the following graph:
1 3
4
2. Let 𝐴 = 𝑎, 𝑏, 𝑐, 𝑑 , and let 𝑅 be the relation on 𝐴 that has the matrix
1 0 0 0
𝑀𝑅 = 0 1 0 0
1 1 1 0
0 1 0 1
Construct the digraph of 𝑅, and list in-degrees and out-degrees of all
vertices.
3. Let 𝐴 = 1, 4, 5 , let 𝑅 be the relation given by the digraph shown
below. Find R and matrix of R.
1 4
5
Problems:
1. Give the relation R defined on 𝐴 and its digraph for following matrices:
1 1 0 1
i) Let 𝐴 = 1, 2, 3, 4 , 𝑀𝑅 = 0 1 1 0 .
0 0 1 1
1 0 0 0
1 1 0 0 0
0 0 1 1 0
ii) Let 𝐴 = 𝑎, 𝑏, 𝑐, 𝑑, 𝑒 , 𝑀𝑅 = 0 0 0 1 1.
0 1 1 0 0
1 0 0 0 0
2. Find the relations determined by the digraphs given below. Give its matrix and also find
in-degree and out-degree of each vertex:
1
i) 2
ii)
4 2
1 3
3
5
5 4
5 4
5 4
𝜋2 : 1, 2, 5, 1, is a path of length 3 from vertex 1 to itself:
1 2
5 4
1 2
5 4
Cycles:
A path that begins and ends at the same vertex is called a cycle.
In the above example 𝜋2 𝑎𝑛𝑑 𝜋3 are cycles of length 3 and 1,
respectively.
Connectivity relation for R:
If n is a fixed positive integer, we define a relation 𝑹𝒏 on 𝑨 as
follows:
𝑥 𝑅𝑛 𝑦 means that there is a path of length n from 𝑥 𝑡𝑜 𝑦 in R.
We also define a relation 𝑹∞ on A , by letting 𝑥 𝑅∞ 𝑦 mean that
there is some path(of any length) in 𝑅 from 𝑥 𝑡𝑜 𝑦.
The relation 𝑅∞ is called the connectivity relation for 𝑅.
Example:
1. Let 𝐴 = {1, 2, 3, 4, 5, 6}. Let R be the relation whose digraph is
shown in figure below. Find the relation 𝑅2 on A.
2 5
1
4 3 6
Note that two vertices a and b are 𝑅2 connected if and only if there is a path of length two
connecting those vertices in graph.
Thus
1 𝑅2 2 since 1 𝑅 2 and 2𝑅2 path is : 1 → 2 → 2
1 𝑅2 4 since 1 𝑅 2 and 2𝑅4 1→2→4
1 𝑅2 5 since 1 𝑅 2 and 2𝑅5 1→2→5
2 𝑅2 2 since 2 𝑅 2 and 2 𝑅 2 2→2→2
2 𝑅2 4 since 2 𝑅 2 and 2𝑅4 2→2→4
2 𝑅2 5 since 2 𝑅 2 and 2𝑅5 2→2→5
2 𝑅2 6 since 2 𝑅 5 and 5 𝑅 6 2→5→6
3 𝑅2 5 since 3 𝑅 4 and 4𝑅6 3→4→6
4 𝑅2 6 since 4 𝑅 5 and 5𝑅6 4 → 5 → 60
Hence 𝑅2 = { 1, 2 , 1, 4 , 1, 5 , 2, 2 , 2, 4 , 2, 5 , 2, 6 , 3, 4 , 4, 6 }
Problems:
1. Let 𝐴 = { 𝑎, 𝑏, 𝑐, 𝑑, 𝑒} and
𝑅= 𝑎, 𝑎 , 𝑎, 𝑏 , 𝑏, 𝑐 , 𝑐, 𝑒 , 𝑐, 𝑑 , 𝑑, 𝑒
Compute (i) 𝑅2 and (ii) 𝑅∞ .
Problems:
1. Let 𝐴 = { 𝑎, 𝑏, 𝑐, 𝑑, 𝑒} and 𝑅 = 𝑎, 𝑎 , 𝑎, 𝑏 , 𝑏, 𝑐 , 𝑐, 𝑒 , 𝑐, 𝑑 , 𝑑, 𝑒
Compute (i) 𝑅2 and (ii) 𝑅∞ .
Solution: The digraph of R is shown below:
(i) 𝑎 𝑅2 𝑎 since 𝑎 𝑅 a and 𝑎𝑅𝑎 path is : 𝑎 → 𝑎 → 𝑎
a b 𝑎 𝑅2 𝑏 since 𝑎 𝑅 𝑎 and 𝑎𝑅𝑏 𝑎→𝑎→𝑏
𝑎 𝑅2 𝑐 since 𝑎 𝑅 𝑏 and 𝑏𝑅𝑐 𝑎→𝑏→𝑐
𝑏 𝑅2 𝑒 since 𝑏 𝑅 𝑐 and 𝑐𝑅𝑒 𝑏→𝑐→𝑒
d c
𝑏 𝑅2 𝑑 since b 𝑅 𝑐 and 𝑐𝑅𝑑 𝑏→𝑐→𝑑
e 𝑐 𝑅2 𝑒 since 𝑐 𝑅 𝑑 and 𝑑𝑅𝑒 c→𝑑→𝑒
Hence 𝑅2 = { 𝑎, 𝑎 , 𝑎, 𝑏 , 𝑎, 𝑐 , 𝑏, 𝑒 , 𝑏, 𝑑 , 𝑐, 𝑒 }
(ii) To compute 𝑅∞ , we need all ordered pairs of vertices for which there is a path of any length
from first vertex to second vertex. From the above digraph, we see that
𝑅∞ = { 𝑎, 𝑎 , 𝑎, 𝑏 , 𝑎, 𝑐 , 𝑎, 𝑑 , 𝑎, 𝑒 , 𝑏, 𝑐 , 𝑏, 𝑒 , 𝑏, 𝑑 , 𝑐, 𝑑 , 𝑐, 𝑒 ,
𝑑, 𝑒 }.
2. For the following digraphs, compute the matrices 𝑀𝑅2 and 𝑀𝑅∞
c
2 3
e
a
d 1 4
b f 6 5
Properties of Relations:
Reflexive relation:
A relation R on a set A is said to be reflexive if 𝑎, 𝑎 ∈ 𝑅 for all
𝑎 ∈ 𝐴, that is, 𝑎 𝑅 𝑎 for all 𝑎 ∈ 𝐴.
Thus R is reflexive if every element 𝑎 ∈ 𝐴 is related to itself.
Examples:
1. Let 𝐴 = {1, 2, 3}
𝑅1 = { 1, 1 , 2, 2 , (3,3)} is reflexive relation
𝑅2 = { 1, 2 , 2, 3 , (3,1)} is not a reflexive relation
2. Let △ = 𝑎, 𝑎 𝑎 ∈ 𝐴} is a reflexive relation on A, because
𝑎, 𝑎 ∈ △ for all 𝑎 ∈ 𝐴.
This relation is also called the “equality relation” on the set A.
so, △ = 𝑎, 𝑏 ∈ 𝐴 × 𝐴 𝑎 = 𝑏 }.
Note:
• The matrix of a reflexive relation must have all 1’s on its diagonal.
• A reflexive relation has a cycle of length 1(loop) at every vertex.
• R is reflexive if and only if ∆ ⊆ 𝑅.
Symmetric relations:
A relation R on a set A is said to be symmetric if whenever 𝑎 𝑅 𝑏,
then 𝑏 𝑅 𝑎.
Examples: 1. Let 𝐴 = ℤ, the set of integers,
𝑅= 𝑎, 𝑏 ∈ 𝐴 × 𝐴 𝑎 < 𝑏}, is the “less than” relation.
Here, if 𝑎, 𝑏 ∈ 𝑅, 𝑜𝑟 𝑎 𝑅 𝑏, i.e., 𝑎 < 𝑏,
then it is not true that 𝑏 < 𝑎 ( i. e., 𝑏 ≮ 𝑎 ), so R is not
symmetric.
2. Let 𝐴 = ℤ+ , set of positive integers. The relation R on A is defined
as: 𝑅= 𝑎, 𝑏 ∈ 𝐴 × 𝐴 𝑎 𝑑𝑖𝑣𝑖𝑑𝑒𝑠 𝑏},
Is R symmetric?
Step 3: Put 1’s in all the positions 𝑝𝑖 , 𝑞𝑗 of 𝑾𝒌 (if they are not
already there).
1. Let 𝐴 = 1, 2, 3, 4 and let
𝑅 = { 1, 2 , 2, 3 , 3, 4 , (2, 1)}. Find the transitive closure of
R using Warshall’s algorithm.
Solution:
0 1 0 0
Here 𝑀𝑅 = 1 0 1 0 =𝑊 and 𝑛 = 4.
0
0 0 0 1
0 0 0 0
First we find 𝑊1 from 𝑊0 . For 𝑊1 , look at locations of 1’ s in column 1 and row 1 of 𝑊0 .
𝑊0 has 1’s in location 2 = 𝑝1 of column 1 and location 2 = 𝑞1 of row 1.
Thus 𝑊1 is just 𝑊0 with new 1 in the position (2, 2) 𝑖. 𝑒. , 𝑝1 , 𝑞1 .
0 1 0 0
𝑊1 = 1 1 1 0
0 0 0 1
0 0 0 0
Now we compute 𝑊2 from 𝑊1 . For 𝑊2 , we must consult column 2 and row 2 of 𝑊1 .
Locations of 1’s in 2nd column of 𝑊1 are : 1, 2
Locations of 1’s in 2nd row of 𝑊1 are : 1, 2 and 3.
Thus for 𝑊2 , we must put 1’s in positions (1, 1), (1, 2), (1, 3), (2, 1), (2, 2), (2, 3) of 𝑊1 (if
1’s are not already there).
Functions ( Review)
A function 𝑓: 𝐴 → 𝐵 is a special relation such that for each element 𝑎 ∈ 𝐴 there is
exactly (or at most) one element 𝑏 ∈ 𝐵. This is written as 𝑓(𝑎) = 𝑏.
or 𝑓 = 𝑎, 𝑏 𝑏 = 𝑓 𝑎 ∈ 𝐵, 𝑓𝑜𝑟 𝑎 ∈ 𝐴}
Here set is 𝐴 called domain and 𝐵 is called codomain of the function 𝑓. The element 𝑎 in 𝐴
is called argument of the function and 𝑓(𝑎) is called image of 𝑎 under 𝑓. The set of all images
of elements of 𝐴 is called range of 𝑓. So 𝑟𝑎𝑛𝑔𝑒 𝑓 = 𝑓 𝑎 ∈ 𝐵 𝑎 ∈ 𝐴}.
Example 1: Let 𝐴 = {1, 2, 3, 4} and 𝐵 = 𝑎, 𝑏, 𝑐, 𝑑 , and let
𝑓= 1, 𝑎 , 2, 𝑎 , 3, 𝑑 , 4, 𝑐
A f B
1 a Here 𝑟𝑎𝑛𝑔𝑒 𝑓 = {𝑎, 𝑐, 𝑑}.
2 b
3 c
4 d
Example 2: Let 𝐴 = {1, 2, 3} and 𝐵 = 𝑥, 𝑦, 𝑧 , consider the following relations
R= 1, 𝑥 , 2, 𝑥 , (3, 𝑧)
S= 1, 𝑥 , 1, 𝑦 , 2, 𝑧 , (3, 𝑦)
Here R is a function. But S is not a function, because 𝑆 1 = 𝑥, 𝑦 , 1 has two images.
Example 3: Let P be a computer program that accepts an integer as input and produces an
integer as output. Let 𝐴 = 𝐵 = ℤ. Then P determines a relation 𝑓𝑝 defined as follows:
𝑚, 𝑛 ∈ 𝑓𝑝 means that 𝑛 is the output produced by program P where the input is 𝑚.
Note: Example 3 can be generalized to a program with any set 𝐴 of possible inputs and set 𝐵 of
corresponding outputs. In general, therefore, we may think of functions are input-output
relations.
Different types of functions:
1. Injective (or one-to-one) function:
Let 𝑓: 𝐴 → 𝐵, be a function, then 𝑓 is said to be injective function,
if 𝑓 𝑥1 = 𝑓 𝑥2 ⇒ 𝑥1 = 𝑥2
or if 𝑥1 ≠ 𝑥2 ⇒ 𝑓 𝑥1 ≠ 𝑓 𝑥2 .
2. Surjective (or onto) function:
Let 𝑓: 𝐴 → 𝐵, be a function, then 𝑓 is said to be surjective function, if “𝑟𝑎𝑛𝑔𝑒 𝑜𝑓 𝑓 = 𝐵”
or every element of set 𝐵 is a image of some element of set 𝐴.
3. Bijective function:
A function 𝑓: 𝐴 → 𝐵 is bijective if 𝑓 is both injective and surjective.
Invertible functions:
A function 𝑓: 𝐴 → 𝐵 is said to be invertible function if its inverse relation, 𝑓 −1 , is also a
function.
Example 1: Let 𝐴 = {1, 2, 3, 4} and 𝐵 = 𝑎, 𝑏, 𝑐, 𝑑 , and let
𝑓= 1, 𝑎 , 2, 𝑎 , 3, 𝑑 , 4, 𝑐
here, 𝑓 −1 = 𝑎, 1 , 𝑎, 2 , 𝑑, 3 , 𝑐, 4 which is not a function, since 𝑓 −1 = 1, 2 .
Note: A function is invertible if and only if it is bijective. More over 𝑓 −1 is also bijective.
Composition of functions:
Let 𝑓: 𝐴 → 𝐵 and 𝑔 ∶ 𝐵 → 𝐶 be functions. Then the composition of 𝑓 and 𝑔, 𝑔 ∘ 𝑓, is a relation
from 𝐴 to 𝐶, defined by 𝑔 ∘ 𝑓 𝑥 = 𝑔 𝑓 𝑥 for every 𝑥 ∈ A.
𝑓∘𝑔 𝑥 =𝑓 𝑔 𝑥 = 𝑓 4𝑥 2 + 1 = 4𝑥 2 + 1 3
1 2 3 1 2 3 1 2 3
1𝐴 = , 𝑝1 = , 𝑝2 =
1 2 3 1 3 2 2 1 3
1 2 3 1 2 3 1 2 3
𝑝3 = 𝑝4 = 𝑝5 =
2 3 1 3 1 2 3 2 1
Example 3: Using the permutations of Example 2, compute 𝑎 𝑝4−1 ; b 𝑝3 ∘ 𝑝2 .
Solution: (a) Viewing 𝑝4 as a function, we have
𝑝4 = 1, 3 , 2, 1 , 3, 2 .
1 2 3
Then, 𝑝4−1 = 3, 1 , 1, 2 , 2, 3 = 1, 2 , 2, 3 , 3, 1 = = 𝑝3
2 3 1
(b) For 𝑝3 ∘ 𝑝2 ,
1 2 3 1 2 3
𝑝3 ∘ 𝑝2 = ∘
2 3 1 2 1 3
Here, The function 𝑝2 takes 1 to 2 and 𝑝3 takes 2 to 3, so 𝑝3 ∘ 𝑝2 takes 1 to 3.
𝑝2 𝑝3 𝑝3 ∘ 𝑝2
1 2 3, so 1 3
2 1 2, so 2 2
3 3 1, so 3 1
1 2 3 1 2 3 1 2 3
So, 𝑝3 ∘ 𝑝2 = ∘ = = 𝑝5 .
2 3 1 2 1 3 3 2 1
Or
Note: 1. The composition of two permutation is another permutation, usually referred to as the
product of these permutations.
2. Product of two permutations is not commutative.
3. If 𝐴 = {𝑎1 , 𝑎2 , … , 𝑎𝑛 } is a set with n elements, then there are 𝑛! Permutations of A.
Cyclic permutations:
Let 𝑏1 , 𝑏2 , … , 𝑏𝑟 be distinct elements of the set 𝐴 = {𝑎1 , 𝑎2 , … , 𝑎𝑛 }. The permutation
p: 𝐴 → 𝐴 defined by
𝑝 𝑏1 = 𝑏2
𝑝 𝑏2 = 𝑏3
⋮
𝑝 𝑏𝑟−1 = 𝑏𝑟
𝑝 𝑏𝑟 = 𝑏1 and 𝑝 𝑥 =𝑥 if 𝑥 ∈ 𝐴, 𝑥 ∉ {𝑏1 , 𝑏2 , … , 𝑏𝑟 },
Two cycles are said to be disjoint if no element of A appears in both cycles.
Example: Let 𝐴 = 1, 2, 3, 4, 5, 6 . Then the cycles 1, 2, 5 𝑎𝑛𝑑 (3, 4, 6) are disjoint,
whereas the cycles (1, 2, 5) and (2, 4, 6) are not.
1 2 3 4 5 6 7 8 of the set
Example: Write the permutation 𝑝 =
3 4 6 5 2 1 8 7
𝐴 = {1, 2, 3, 4, 5, 6, 7, 8} as a product of cycles.
Solution:
We start with 1 and find 𝑝 1 = 3, 𝑝 3 = 6 𝑎𝑛𝑑 𝑝 6 = 1, so there is a cycle (1, 3, 6).
Next we choose the first element of A that has not appeared in a previous cycle.
We choose 2, and we have 𝑝 2 = 4, 𝑝 4 = 5 𝑎𝑛𝑑 𝑝 5 = 2, so we obtain the cycle
(2, 4, 5).
Now, we choose 7, 𝑝 7 = 8 𝑎𝑛𝑑 𝑝 8 = 7, we obtain the cycle 7, 8 .
Then, we can write 𝑝 as a product of disjoint cycles as
𝑝 = 1, 3, 6 ∘ 2, 4, 5 ∘ 7, 8 .
Transpositions:
A cycle of length 2 is called a transposition. That is, a transposition is a cycle 𝑝 = 𝑎𝑖 , 𝑎𝑗 ,
where 𝑝 𝑎𝑖 = 𝑎𝑗 and 𝑝 𝑎𝑗 = 𝑎𝑖 .
Every cycle can be written as a product of transpositions. In fact,
𝑏1 , 𝑏2 , … , 𝑏𝑟 = 𝑏1 , 𝑏𝑟 ∘ 𝑏1 , 𝑏𝑟−1 ∘ ⋯ ∘ (𝑏1 , 𝑏3 ) ∘ (𝑏1 , 𝑏2 ).
Example:
1. 1, 2, 3, 4, 5 = 1, 5 ∘ 1, 4 ∘ (1, 3) ∘ (1, 2).
2. 𝑝 = 1, 3, 6 ∘ 2, 4, 5 ∘ 7, 8 = 1, 6 ∘ 1, 3 ∘ (2, 5) ∘ (2, 4) ∘ 7, 8 .
1 2 3 4 5 6 7
1. Is the permutation 𝑝 = even or odd
2 4 5 7 6 3 1
Solution:
First we write 𝑝 as a product of disjoint cycles, obtaining
𝑝 = 1, 2, 4, 7 ∘ 3, 5, 6 = 1, 7 ∘ 1, 4 ∘ 1, 2 ∘ 3, 6 ∘ 3, 5 .
Since 𝑝 is a product of an odd number of transpositions, it is an odd permutation.
𝑎 𝑏 𝑐 𝑑 𝑒 𝑓 𝑔
(a)
𝑔 𝑑 𝑏 𝑎 𝑐 𝑓 𝑒
𝑎 𝑏 𝑐 𝑑 𝑒 𝑓 𝑔
(b)
𝑑 𝑒 𝑎 𝑏 𝑔 𝑓 𝑐
3. Let 𝐴 = 1, 2, 3, 4, 5 . Let𝑓 = 5, 2, 3 and 𝑔 = (3, 4, 1) be permutation of A.
Compute each of the following and write the result as the product of disjoint cycles.
(a) 𝑓 ∘ 𝑔 (b) 𝑓 −1 ∘ 𝑔−1 .
1 2 3 4 5 6
4. Let 𝐴 = 1, 2, 3, 4, 5, 6 and 𝑝 = be a permutation of A.
4 3 5 1 2 6
(a) Write 𝑝 as a product of disjoint cycles.
(b) Compute 𝑝−1 .
(c) Compute 𝑝2 .
(d) Find the period of 𝑝, that is, the smallest positive integer 𝑘 such that 𝑝𝑘 = 1𝐴 .
Graphs
Graphs are discrete structures consisting of vertices and edges that connect the vertices.
Definitions:
A graph 𝐺 = (𝑉, 𝐸) consists of 𝑉, a nonempty set of vertices and 𝐸, a set of edges. Each
edge is associated with one or two vertices, called its end points.
Example: Let 𝐺 = 𝑉, 𝐸 , 𝑉 = 𝑣1 , 𝑣2 , 𝑣3 , 𝑣4 and 𝐸 = {𝑒1 , 𝑒2 , 𝑒3 , 𝑒4 , 𝑒5 }, where
𝑒1 = 𝑣1 , 𝑣2 , 𝑒2 = 𝑣1 , 𝑣3 , 𝑒3 = 𝑣2 , 𝑣3 , 𝑒4 = 𝑣3 , 𝑣4 𝑎𝑛𝑑 𝑒5 = 𝑣1 , 𝑣4 .
Graph G is given by: 𝑣1 𝑒1 𝑣2
𝑒4 𝑒2 𝑒3
𝑣4 𝑣3
𝑒5
Note: The set of vertices 𝑉 of a graph 𝐺 may be infinite. A graph with an infinite vertex set is
called an infinite graph, and graph with a finite vertex set is called a finite graph.
Here we will discuss about finite graphs.
Multiple edges:
Two or more edges connecting the same pair of vertices are called multiple edges.
Example:
𝑒1
𝑒2
𝑣1 𝑣2
𝑒3
Loops:
An edge having same vertex as its end points is called a loop.
Example: 𝑣 𝑒1
Simple graph: A graph without loops and without multiple edges is called simple graph.
Example:
Pseudo graph: A graph with both loops and multiple edges is called pseudo graph.
Directed graph (or digraph):
A directed graph or digraph 𝐺 = (𝑉, 𝐸) consists of a nooempty set 𝑉 and a set of edges E.
Each directed edge is associated with an ordered pair of vertices. called it end points.
Example: Let 𝐺 = 𝑉, 𝐸 , 𝑉 = 𝑣1 , 𝑣2 , 𝑣3 , 𝑣4 and 𝐸 = {𝑒1 , 𝑒2 , 𝑒3 , 𝑒4 , 𝑒5 }, where
𝑒1 = 𝑣1 , 𝑣2 , 𝑒2 = 𝑣1 , 𝑣3 , 𝑒3 = 𝑣2 , 𝑣3 , 𝑒4 = 𝑣3 , 𝑣4 𝑎𝑛𝑑 𝑒5 = 𝑣1 , 𝑣4 .
Graph G is given by: 𝑣1 𝑒1 𝑣2
𝑒4 𝑒2 𝑒3
𝑣4 𝑣3
𝑒5
When a directed graph has no loops and no multiple directed edges is called a simple directed
graph.
A directed graph with multiple edges is called directed multi graph.
A graph with both directed and undirected edges is called a mixed graph.
Graph Terminology and Special Types of Graphs:
Two vertices 𝑢 𝑎𝑛𝑑 𝑣 in an undirected graph G are called 𝒂𝒅𝒋𝒂𝒄𝒆𝒏𝒕 (or neighbors) in
𝐺 if 𝑢 𝑎𝑛𝑑 𝑣 are endpoints of an edge 𝑒 of 𝐺.
Such an edge e is called 𝒊𝒏𝒄𝒊𝒅𝒆𝒏𝒕 𝒘𝒊𝒕𝒉 the vertices 𝑢 𝑎𝑛𝑑 𝑣 and 𝑒 is said to
𝒄𝒐𝒏𝒏𝒆𝒄𝒕 𝒖 𝒂𝒏𝒅 𝒗.
The degree of a vertex in an undirected graph is the number of edges incident with it, except
that a loop at a vertex contributes twice to the degree of that vertex. The degree of the vertex v
is denoted by 𝒅𝒆𝒈(𝒗).
Example 1: deg 𝑎 = 4
deg 𝑏 = 6
deg 𝑐 = 1
deg 𝑑 = 5 deg 𝑒 = 6
Example 2: deg 𝑎 = 2
deg 𝑏 = 4
deg 𝑐 = 4
deg 𝑑 = 1
deg 𝑒 = 3
deg 𝑓 = 4
deg 𝑔 = 0
Note:
1. A vertex of degree zero is called isolated. It follows that an isolated vertex is not adjacent to
any vertex. Vertex g in Example 2 is isolated vertex.
2. A vertex of degree 1 is called pendent. A pendant vertex is adjacent to exactly one other
vertex. Vertex d in Example 2 is pendant.
Theorem 1: The Handshaking Theorem:
Let 𝐺 = (𝑉, 𝐸) be an undirected graph with 𝑚 edges.
Then 2𝑚 = σ𝑣∈𝑉 deg(v) .
(Note that this applies even if multiple edges and loops are present.)
Justification: Each edge contributes two to the sum of the degrees of the vertices because an edge
is incident with exactly two (possibly equal) vertices. This means that the sum of the degrees of
the vertices is twice the number of edges.
Question: How many edges are there in a graph with 10 vertices each of degree six? (find !)
Theorem 2: An undirected graph has an even number of vertices of odd degree.
Proof:
Let 𝑉1 and 𝑉2 be the set of vertices of even degree and the set of vertices of odd degree,
respectively, in an undirected graph 𝐺 = (𝑉, 𝐸) with 𝑚 edges.
Then by Hand shaking property, we have,
2𝑚 = σ𝑣∈𝑉 deg(v) = σ𝑣∈𝑉1 deg(v) + σ𝑣∈𝑉2 deg(v)
Because deg(𝑣) is even for 𝑣 ∈ 𝑉1 , the first term in the right-hand side of the last equality is even.
Furthermore, the sum of the two terms on the right-hand side of the last equality is even, because this
sum is 2𝑚.
Hence, the second term in the sum is also even.
Because all the terms in this sum are odd, there must be an even number of such terms.
Thus, there are an even number of vertices of odd degree.
Definitions: If (𝑢, 𝑣) is a directed edge of the graph 𝐺, then 𝑢 is said to be adjacent to 𝒗
and 𝑣 is said to be adjacent from 𝒖.
The vertex 𝑢 is called the initial vertex of (𝒖, 𝒗), and 𝑣 is called the terminal or end vertex of
(𝒖, 𝒗).
The initial vertex and terminal vertex of a loop are the same.
In a graph with directed edges the in-degree of a vertex 𝑣, denoted by deg − (𝑣), is the
number of edges with 𝑣 as their terminal vertex.
The out-degree of 𝑣, denoted by deg + 𝑣 , is the number of edges with 𝑣 as their initial
vertex.
Some Special Simple Graphs
Complete Graphs: A complete graph on 𝒏 vertices, denoted by 𝐾𝑛 , is a simple graph that
contains exactly one edge between each pair of distinct vertices.
The graphs 𝐾𝑛 , for n = 1, 2, 3, 4, 5, 6, are given below.
A simple graph for which there is at least one pair of distinct vertex not connected by an edge is
called non complete.
Cycles: A cycle 𝑪𝒏 , 𝑛 ≥ 3, consists of 𝑛 vertices 𝑣1 , 𝑣2 , . . . , 𝑣𝑛 and edges
𝑣1 , 𝑣2 , 𝑣2 , 𝑣3 , . . . , 𝑣𝑛−1 , 𝑣𝑛 𝑎𝑛𝑑 𝑣𝑛 , 𝑣1 . The cycles 𝐶3 , 𝐶4 , 𝐶5 , 𝑎𝑛𝑑 𝐶6 are
shown below:
Example 1: 𝐶6 is bipartite, as shown in Figure, because its vertex set can be partitioned into the
two sets 𝑉1 = {𝑣1 , 𝑣3 , 𝑣5 } and 𝑉2 = {𝑣2 , 𝑣4 , 𝑣6 }, and every edge of 𝐶6 connects a
vertex in 𝑉1 and a vertex in 𝑉2 .
𝑋 =
Note:
Adjacency matrices can also be used to represent undirected graphs with loops and with
𝑡ℎ
multiple edges. A loop at the vertex 𝑣𝑖 is represented by a 1 at the 𝑖, 𝑖 position of the
adjacency matrix. When multiple edges connecting the same pair of vertices 𝑣𝑖 and 𝑣𝑗 ,
or multiple loops at the same vertex, are present, the adjacency matrix is no longer a
𝑡ℎ
zero–one matrix, because the 𝑖, 𝑗 entry of this matrix equals the number of edges
that are associated to {𝑣𝑖 , 𝑣𝑗 }. All undirected graphs, including multigraphs and pseudo
graphs, have symmetric adjacency matrices.
Example: The adjacency matrix of the graph given below is:
𝐴𝐺 =
1. Write adjacency matrix of following graphs:
0 1 0 1 1
1 0 1 0 1
(i) 𝑋 = 0 1 0 1 0 (ii) 𝑋 =
1 0 1 0 1
1 1 0 1 0
Incidence Matrices
Let 𝐺 = (𝑉, 𝐸) be an undirected graph. Suppose that 𝑣1 , 𝑣2 , . . . , 𝑣𝑛 are the vertices and
𝑒1 , 𝑒2 , . . . , 𝑒𝑚 are the edges of 𝐺. Then the incidence matrix with respect to this ordering of
𝑉 and 𝐸 is the 𝑛 × 𝑚 matrix 𝑴 = [𝑚𝑖𝑗 ], where
(i) (ii) 2 3
1 0 0 1
0 1 0 0
𝑀= 0 0 1 1
1 1 0 0
0 0 1 0
3. Write adjacency and incidence matrices for the following graphs:
𝐾5 , 𝐶6 , 𝐶4 , 𝐾2,3 , 𝐾3,3 .