Download presentation
Presentation is loading. Please wait.
1
Dr. Ameria Eldosoky Discrete mathematics
2
Relations and Digraphs
3
Relations and Digraphs
The matrix of a Relation If A={a1,a2, …am} and B={b1,b2,…bn} are finite sets containing m and n elements, respectively, and R is a relation from A to B, we represent R by the m×n matrix MR =[mij], which is defined by mij = if (ai bj) ∈ R = otherwise The matrix MR is called the matrix of R.
4
Relations and Digraphs
Example 17 Let A ={1, 2, 3} and B={r, s}. Then we define R={(1, r), (2, s), (3, r)} is a relation from A to B. Then the matrix of R is
5
Relations and Digraphs
Consider the matrix Since M is 3×4, we let A={a1,a2,a3} and B={b1,b2,b3,b4} Then (ai,bj) in R if and only if mij=1, thus R={(a1,b1),(a1,b4),(a2,b2),(a2,b3),(a3,b1),(a3,b3}
6
Relations and Digraphs
The Digraph of a Relation If A is a finite set, R is a relation on A (from A to A) 1) Draw a small circle for each element of A and label the circle with the corresponding element of A (Vertices) 2) Draw an arrow from vertex ai to vertex aj if and only if ai R aj (Edge) The resulting pictorial representation of R is called a directed graph or digraphy of R.
7
Relations and Digraphs
Example 19 Let A={1, 2, 3, 4} R={(1,1), (1,2), (2,1), (2,2), (2,3), (2,4), (3,4), (4,1)}
8
Relations and Digraphs
Example 20 Find the relation determined by the following Figure. R={ (1,1), (1,3), (2,3), (3,3), (3,2), (4,3) }
9
Relations and Digraphs
In-/Out- Degree If R is a relation on a set A, and a in A, then The in-degree of a relative to the relation R is the number of b in A such that (b,a) in R. The out-degree of a is the number of b in A such that (a,b) in R
10
Relations and Digraphs
Example 22 Let A={a, b, c, d}, and R be the relation on A that has the matrix Construct the digraph of R, and list the in-degrees and out-degrees of all vertices a b c d 2 3 1 In-degree Out-degree
11
Relations and Digraphs
If R is a relation on a set A, and B is a subset of A, the restriction of R to B is R ∩ (B×B) Example 24 Let A={a,b,c,d,e,f}, R={(a,a), (a,c), (b,c), (a,e), (b,e), (c,e)}. Let B={a,b,c}, then B×B={(a,a), (a,b), (a,c), (b,a), (b,b), (b,c), (c,a), (c,b), (c,c) } and the restriction of R to B is {(a, a), (a, c), (b, c)}
12
Paths in Relations and Digraphs
Suppose that R is a relation on a set A. 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 with b, such that a R x1, x1 R x2, …,xn-1 R b Note: A path of length n involves n+1 elements of A, although they are not necessarily distinct.
13
Paths in Relations and Digraphs
Example 1 Consider the digraph in the following figure. Then п1: 1, 2, 5, 4, 3 is a path of length 4 from vertex 1 to 3 п2: 1, 2, 5, 1 is a path of length 3 from vertex 1 to itself п3: 2, 2 is a path of length 1 from vertex 2 to itself Cycle: a path that begins and ends at the same vertex (п2 п3 )
14
Paths in Relations and Digraphs
If n is a fixed positive integer, we define a relation Rn on A as follows: x Rn y means that there is a path of length n from x to y in R Define a relation R∞ on A, by letting x R y mean that there is some path in R from x to y. The length of such a path will depend on x and y. The relation R∞ is sometimes called the connectivity relation for R. Rn(x) consists of all verities that can be reached form x by means of a path in R of length n. The set R∞ (x) consists of all vertices that can be reached from x by some path in R
15
Paths in Relations and Digraphs
Example 2 Let A be the set of all living human beings R be the relation of mutual acquaintance a R b means that a and b know one another a R2 b means that a and b have an acquaintance in common a Rn b if a knows someone x1, who knows x2, …, who knows xn-1, who knows b. a R∞ b means that some chain of acquaintances exists that begins at a and ends at b. Q: It is interesting (and unknown) whether every two Americans, say, are related by R∞
16
Paths in Relations and Digraphs
Example 3 Let A be a set of cities x R y if there is a direct flight from x to y on at least one airline. x Rn y if one can book a flight from x to y having exactly n-1 intermediate stops x R∞ y if one can get from x to y by plane
17
Paths in Relations and Digraphs
Example 5 Let A={a,b,c,d,e} and R={(a,a), (a,b), (b,c), (c,e), (c,d), (d,e)} Compute (a) R2 (b) R ∞ R
18
Paths in Relations and Digraphs
Compute R2 a R2 a since a R a and a R a a R2 b since a R a and a R b a R2 c since a R b and b R c b R2 e since b R c and c R e b R2 d since b R c and c R d c R2 e since c R d and d R e Hence R2 ={(a,a), (a,b), (a,c), (b,e), (b,d), (c,e)}
19
Paths in Relations and Digraphs
Compute R ∞ To compute R ∞ , we need all ordered pairs of vertices for which there is a path of any length from the first vertex to the second. We can see that from the figure R∞ = { (a,a), (a,b), (a,c), (a,d), (a,e), (b,c),(b,d), (b,e), (c,d), (c,e), (d,e) }. R Note: If |R| is large, it can be tedious and perhaps difficult to compute R ∞
20
Paths in Relations and Digraphs
Boolean Matrix (p.37) A Boolean Matrix is an m×n matrix whose entries are either 0 or 1. Let A=[aij] and B=[bij] be m×n matrix Boolean matrix. The Join of A and B : A V B = C = [cij] cij= if aij=1 or bij=1 cij= otherwise The meet of A and B: A ^ B = D = [dij] dij= if aij and bij are both 1 dij= otherwise
21
Paths in Relations and Digraphs
Boolean Product (p.38) A = [aij] is an m×p Boolean matrix and B = [bij] is a p×n Boolean matrix. The Boolean product of A and B, denoted A⊙B, is the m ×n Boolean matrix C=[cij] defined by
22
Paths in Relations and Digraphs
Example Let then
23
Paths in Relations and Digraphs
Theorem 5 (p. 39) 1. (a) A V B= B V A (b) A ^ B = B ^ A 2. (a) (A V B) V C = A V (B V C) (b) (A ^ B) ^ C = A ^ (B ^ C) 3. (a) A ^ ( B V C) = (A ^ B) V (A ^ C) (b) A V (B ^ C) = (A V B) ^ (A V C) 4. (A ⊙ B) ⊙C = A ⊙ (B ⊙C)
24
Paths in Relations and Digraphs
Theorem 1 If R is a relation on A={a1,a2,…an}, then Proof: Let MR=[mij] and MR2 =[nij]. By definition, the i, j-th element of MR ⊙ MR is equal to 1 if only if row i of MR and column j of MR has a 1 in the same relative position, say position k. This means that mik=1 and mkj=1 for some k, 1 ≤ k ≤ n. By definition of matrix MR, the preceding conditions mean that ai R ak, and ak R aj. Thus ai R2 aj, and so nij=1. Therefore, position i, j of MR ⊙ MR is 1 if and only if nij=1.
25
Paths in Relations and Digraphs
Example 6 Let A and R be as in Example 5. Then
26
Paths in Relations and Digraphs
Theorem 2 For n ≥ 2 and R is a relation on a finite set A, we have
27
Paths in Relations and Digraphs
If R and S are relations on A. the relation R U S is defined by x (R U S) y if and only if x R y or x R y. It is easy to verify that MRUS =MR V MS
28
Paths in Relations and Digraphs
The Reachability relation R* of a relation on a set A that has n elements is defined as follows: x R* y means that x=y or x R∞ y
29
Paths in Relations and Digraphs
Composition Let п1 = a, x1, x2, …, xn-1,b be a path in relation R of length n form a to b, and п2 = b, y1, y2, …, ym-1,c be a path in relation R of length m form b to c, then the composition of п1 and п2 is the path a, x1, x2, …, xn-1,b y1, y2, …, ym-1,c of length n+m denoted by п2 O п1
30
Paths in Relations and Digraphs
Consider the relation whose digraph is given in the following figure and the paths п1 = 1, 2, 3 and п2 = 3, 5, 6, 2, 4 Then the composition of п1 and п2 is the path п2 O п1 : 1, 2, 3, 5, 6, 2, 4 from 1 to 4 of length 6
31
Properties of Graph and Relations
The properties of symmetric matrix The matrix MR=[mij] of a symmetric relation on a finite set A= {a1,a2, …,an} satisfies the following property if mij=1 (ai R aj) then mji=1 (aj R ai) Moreover, if mij=0 (ai R aj) then mji=0 (ai R aj) Therefore, we have
32
Properties of Relations
The properties of asymmetric matrix The matrix MR=[mij] of an asymmetric relation on a finite set A= {a1,a2, …,an} satisfies the following property : if mij=1 (ai R aj) then mji=0 (aj R ai) Moreover, if mii=0 (ai R ai) for all i=1,2, …,n
33
Properties of Relations
The properties of antisymmetric matrix The matrix MR=[mij] of an antisymmetric relation on a finite set A= {a1,a2, …,an} satisfies the following property if i ≠ j, ( ai ≠ aj ) then mij=0 (ai R aj ) or mji=0 (aj R ai )
34
Properties of Relations
Example 6 Symmetric Not Asymmetic Not Antisymmetric Symmetric Not Asymmetic Not Antisymmetric Not Symmetric Not Asymmetic Antisymmetric
35
Properties of Relations
Example 6 Not Symmetric Not Asymmetic Not Antisymmetric Not Symmetric Not Asymmetic Antisymmetric Not Symmetric Asymmetic Antisymmetric
36
Properties of Relations
The digraphs of asymmetric relation The digraphs cannot simultaneously have an edge from vertex i to vertex j and an edge from vertex j to vertex i. This is true even i equals j (no cycles). All edges are “one-way streets” The digraphs of antisymmetric relation For different vertices i and j, there cannot be an edge from vertex i to vertex j and edge from vertex j to vertex i. When i=j, no condition is imposed. Thus there may be cycles of length 1, but again all edges are “one way”.
37
Properties of Relations
The digraphs of symmetric relation If there is an edge from vertex i to vertex j, then there is an edge from vertex j to vertex i. Thus, if two vertex are connected by an edge, they must always be connected in both directions. We keep the vertices as they appear in the digraph, but if two vertices a and b are connected by edges in each direction, we replace these two edges with one undirected edge, “two-way street ” (Graph of the symmetric relation)
38
Properties of Relations
Example 7 Let A={a,b,c,d,e} and R be the symmetric relation given by R={(a,b), (b,a), (a,c), (c,a), (b,c), (c,b), (b,e), (e,b), (e,d), (d,e), (c,d), (d,c)} digraphs graphs Undirected edge Adjacent vertices
39
Properties of Relations
Transitive Relations A relation R on a set A is transitive if whenever a R b and b R c, then a R c. For instance: (Ex. 8) the relation “<” on the set of integers If a < b and b < c, then we have a < c Note: not Transitive if there exist a, b and c in A so that a R b and b R c, but a R c.
40
Properties of Relations
A sufficient condition of transitive A relation R is transitive if and only if its matrix MR=[mij] has the property if mij=1 and mjk=1, then mik=1. the left-hand side means that has a 1 in position (i,k). Thus the transitivity of R means that if has a 1 in any position, then MR must have a 1 in the same position. Thus, in particular, if , then R is transitive.
41
Properties of Relations
Example 11 Let A={1,2,3} and let R be the relation on A whose matrix is Show that R is transitive. Solution: By direct computation, , therefore, R is transitive.
42
Properties of Relations
If R is transitive, may not equal to MR (Verify the Example 10)
43
4.4 Properties of Relations
If R is a transitive relation, and a R b and b R c mean that there is a path of length 2 in R from a to c, namely a R2 c. Therefore, we may rephrase the definition of transitivity as follows: If a R2 c, then a R c, that is R2 ⊆ R
44
Properties of Relations
Theorem 1 A relation R is transitive if and only if it satisfies the following property: If there is a path of length greater than 1 from vertex a to vertex b, there is a path of length 1 from a to b (that is, a is related to b). Algebraically stated, R is transitive if and only if Rn ⊆ R for all n >=1 How to Proof the Theorem?
45
Equivalence Relations
A relation R on a set A is called an equivalence relation if it is reflexive, symmetric, and transitive. Example 1: Let A be the set of all triangles in the plane, and let R be the relation on A defined as follow R= { (a, b) ∈A×A | a is congruent to b} Therefore, R is an equivalence relation. Q: R= { (a, b) ∈A×A | a is similar to b} ?
46
Equivalence Relations
Example 2 Let A={1,2,3,4} and let R={(1,1),(1,2), (2,1), (2,2), (3,4), (4,3), (3,3), (4,4)} R is an equivalence relation.
47
Equivalence Relations
Example 3 Let A=Z, the set of integers, and let R be defined by a R b if and only if a<=b, is R an equivalence relation? Reflexive? Yes, since a<=a for all a in A Symmetric? No, (1, 2) in R but (2,1) is not in R Transitive? Yes, since a<=b and b<=c, then we have a<=c Therefore, R is not an equivalence relation.
48
4.5 Equivalence Relations
Example 4 Let A=Z and let R= { (a, b) ∈A×A | a and b yield the same remainder when divided by 2}. In this case, we call 2 the modulus and write read “a is congruent to b mod 2” Reflexive: Symmetric: if , then a and b yield the same remainder when divided by 2, thus Transitive: if , then a, b and c yield the same remainder when divided by 2. Thus
49
4.5 Equivalence Relations
Theorem 1 Let P be a partition on a set A. Recall that the sets in P are called the blocks of P. Define the relation A as follows: a R b if and only if a and b are member of the same block Then R is an equivalence relation on A . Proof: (a) If a in A, then a is in the same block as itself, so a R a (b) If a R b, then a and b are in the same block, so b R a (c) If a R b, and b R c, then a , b and c must all lie in the same block of P, thus a R c. Note: If P is a partition of a set A, then P can be used to construct an equivalence on A
50
4.5 Equivalence Relations
Example 6 Let A={1,2,3,4} and consider the partition P={{1,2,3},{4}} of A. Find the equivalence relation R on A determined by P. Solution: Based on the Theorem 1, each element in a block is related to every other element in the same block and only to those elements. Thus, R={(1,1), (1,2), (1,3), (2,1), (2,2), (2,3), (3,1), (3,2), (3,3), (4,4)}
51
Equivalence Relations
P is a partition of A and R is the equivalence relation determined by P If a in Ai, i=1,2…6 then Ai=R(a) Lemma 1*: a R b iff R(a)=R(b) A1 A2 A3 A4 A5 A6
52
Equivalence Relations
Lemma 1 (Note: Lemma is a theorem whose main purpose is to aid in proving some other theorem) Let R be an equivalence relation on a set A, and let a ∈ A , b ∈ A. Then a R b if and only if R(a)=R(b) Proof: First, suppose that R(a)=R(b). Since R is reflexive, b ∈ R(b); therefore, b in R(a), so a R b
53
Equivalence Relations
Conversely, suppose that a R b, then (1) b in R(a) by definition. Therefore, since R is symmetric (2) a in R(b) by theorem 2 (b) of Section 4.4. To prove R(a)=R(b) First, we choose x in R(b), since R is transitive, the fact x in R(b) with b in R(a) (1) , implies by Theorem 2(c) of Section 4.4 that x in R(a). Thus, R(b) ⊆ R(a) Second, support y in R(a). This fact and a in R(b) (2) imply. As before, that y in R(b). Thus R(a) ⊆ R(b) Therefore, we have R(a) = R(b) The Lemma proved.
54
Equivalence Relations
Theorem 2 Let R be an equivalence relation on A, and let P be the collection of all distinct relative sets R(a) for a in A. Then P is a partition of A, and R is the equivalence relation determined by P. Proof: According to the definition of a partition, we should show the two following properties (a) Every element of A belongs to some relative set (b) If R(a) and R(b) are not identical, then R(a) ∩ R(b) = ф
55
Equivalence Relations
Property (a) is true, since a ∈ R(a) (reflexivity) Property (b) is equivalent to the following statement If R(a) ∩ R(b) ≠ ф, then R(a) = R(b) (p59 Theorem 2 b) Assume c∈ R(a) ∩ R(b), then a R c, b R c. then we have c R b (symmetric) a R c, c R b a R b (transitivity) Therefore, R(a) = R(b) (by lemma 1)
56
Equivalence Relations
Equivalence classes If R is an equivalence relation on A, then the sets R(a) (or [a]) are traditionally called equivalence classes of R. The partition P constructed in Theorem 2 consists of all equivalence classes of R, and this partition will be denoted by A/R. (the quotients set of A)
57
Equivalence Relations
Example 7 Let A={1,2,3,4} and let R={(1,1),(1,2), (2,1), (2,2), (3,4), (4,3), (3,3), (4,4)} Determine A/R Solution: R(1) = {1, 2} = R(2) , R(3) = {3, 4} = R(4) Hence A/R = { {1,2} , {3,4}}
58
Equivalence Relations
Example 8 Let A=Z and let R= { (a, b) ∈A×A | a and b yield the same remainder when divided by 2}. Solution: First R(0)={…,-4,-2,0,+2,+4,…}, the set of even integers, since the remainder is zero when each of these numbers is divided by 2. R(1) = {…, -3,-1,0,+1,+3,… }, the set of odd integers, since the remainder is 1 when divided by 2. Hence, A/R consists of the even integers and the set of odd integers.
59
Equivalence Relations
The procedure of determining A/R is as follows: Support A={a1,a2,…} (finite or countable) Step 1: i=0; j=0; Step 2: i=i+1; Step 3: if ai ∈ A, then j=j+1; bj=ai and compute the equivalence class R(bj ), A= A- R(bj) Step 4: if A become an empty set, then we obtain the equivalence classes R(b1), R(b2), … R(bj) (Note: j may be finite or infinite) otherwise repeat step 2 ~ 4
60
Operations on Relations
Example 5 Let A={1,2,3} and consider the two reflexive relations R = { (1,1), (1,2), (1,3), (2,2), (3,3) } S = { (1,1), (1,2), (2,2), (3,2), (3,3) } then R-1 = { (1,1), (2,1), (3,1), (2,2), (3,3) }. R and R-1 are both reflexive. R= { (2,1), (2,3), (3,1), (3,2) } is irreflexive while R is reflexive. R∩S = {(1,1), (1,2), (2,2), (3,3) } (reflexive) R∪S = { (1,1), (1,2), (1,3), (2,2), (3,2), (3,3) } (reflexive)
61
Operations on Relations
Theorem 3 (Homework Ex. 37) Let R be a relation on a set A. Then (a) R is symmetric if and only if R=R-1 (b) R is antisymmetric if and only if R ∩ R -1 ⊆ Δ (c) R is asymmetric if and only if R ∩ R -1 = Ø
62
Operations on Relations
Theorem 4 Let R and S be relations on A (a) If R is symmetric, so are R-1 and R (b) If R and S are symmetric, So R ∩ S and R U S
63
Operations on Relations
Example 3 R={ (a,a), (b,b), (a,c), (b,a), (c,b), (c,d), (c,e), (c,a), (b,d), (d,a), (d,e), (e,b), (e,a), (e,d), (e,c) } R-1= { (b,a), (e,b), (c,c), (c,d), (d,d), (d,b), (c,b), (d,a), (e,e), (e,a) } R∩S = {(a b), (b e) (c c) }
64
Operations on Relations
Example 4
65
Operations on Relations
Operations on Boolean Matrix
66
Operations on Relations
Example 6 Let A={1,2,3} and consider the symmetric relations R = { (1,1), (1,2), (2,1), (1,3), (3,1) } S = { (1,1), (1,2), (2,1), (2,2), (3,3) } then (a) R-1 = { (1,1), (2,1), (1,2), (3,1), (1,3) } (symmetric) R = { (2,2), (2,3), (3,2), (3,3) } (symmetric) (b) R∩S = { (1,1), (1,2), (2,1) } (symmetric) R∪S = { (1,1), (1,2), (1,3), (2,1), (2,2), (3,1), (3,3) } (symmetric)
67
Operations on Relations
Theorem 5 Let R and S be relations on A (a) (R ∩ S )2 ⊆ R2 ∩ S2 (b) If R and S are transitive, so is R ∩ S (c) If R and S are equivalence relations, so is R ∩ S
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.