32
Relations & Digraphs

Relations digraphs

Embed Size (px)

Citation preview

Relations & Digraphs

Product SetsDefinition: An ordered pair π‘Žπ‘Ž, 𝑏𝑏 is a listing of the objects/items π‘Žπ‘Ž and 𝑏𝑏 in a prescribed order: π‘Žπ‘Ž is the firstand 𝑏𝑏 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 SetsExample: Let 𝐴𝐴 = 1,2,3 and 𝐡𝐡 = π‘Ÿπ‘Ÿ, 𝑠𝑠 , then

𝐴𝐴 Γ— 𝐡𝐡 =

𝐡𝐡 Γ— 𝐴𝐴 =

Β© S. Turaev, CSC 1700 Discrete Mathematics 3

Product SetsTheorem: 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 & DigraphsExample 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 RelationDefinition: 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 RelationDefinition: 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 RelationExample: 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 RelationDefinition: 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 RelationExample: Let 𝐴𝐴 = π‘Žπ‘Ž, 𝑏𝑏, 𝑐𝑐,𝑑𝑑 and let 𝑅𝑅 be the relation on 𝐴𝐴 that has the matrix

πŒπŒπ‘…π‘… =1 00 1

0 00 0

1 10 1

1 00 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 RelationExample: 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 & DigraphsDefinition: 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 & DigraphsExample: Give the examples for paths of length 1,2,3,4and 5.

Β© S. Turaev, CSC 1700 Discrete Mathematics

1 2

43

5

17

Paths in Relations & DigraphsDefinition: 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 & DigraphsLet 𝑅𝑅 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 & DigraphsExample: Let 𝐴𝐴 = π‘Žπ‘Ž, 𝑏𝑏, 𝑐𝑐,𝑑𝑑, 𝑒𝑒 and

𝑅𝑅 = π‘Žπ‘Ž, π‘Žπ‘Ž , π‘Žπ‘Ž, 𝑏𝑏 , 𝑏𝑏, 𝑐𝑐 , 𝑐𝑐, 𝑒𝑒 , 𝑐𝑐,𝑑𝑑 , 𝑑𝑑, 𝑒𝑒 .

πŒπŒπ‘…π‘… =

1 10 0

0 01 0

00

000

000

000

100

110

Compute πŒπŒπ‘…π‘…2.

Β© S. Turaev, CSC 1700 Discrete Mathematics 20

Reflexive & Irreflexive RelationsDefinition:

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 RelationsExercise: 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 RelationsDefinition:

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 RelationsExample: 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 RelationsExample: 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 RelationsExercise: 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 RelationsDefinition: 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 RelationsExercise: Let 𝐴𝐴 = 1,2,3 and 𝑅𝑅 be the relation on 𝐴𝐴whose matrix is

πŒπŒπ‘…π‘… =1 1 10 0 10 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 RelationsDefinition: 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