Presentation is loading. Please wait.

Presentation is loading. Please wait.

Chapter 4 Relations and Digraphs Weiqi Luo ( 骆伟祺 ) School of Software Sun Yat-Sen University : Office : A309

Similar presentations


Presentation on theme: "Chapter 4 Relations and Digraphs Weiqi Luo ( 骆伟祺 ) School of Software Sun Yat-Sen University : Office : A309"— Presentation transcript:

1 Chapter 4 Relations and Digraphs Weiqi Luo ( 骆伟祺 ) School of Software Sun Yat-Sen University Email : weiqi.luo@yahoo.com Office : A309 weiqi.luo@yahoo.com

2 School of Software  4.1 Product Sets and Partitions  4.2 Relations and Digraphs  4.3 Paths in Relations and Digraphs  4.4 Properties of Relations  4.5 Equivalence Relations  4.6 Data structures for Relations and Digraphs  4.7 Operations on Relations  4.8 Transitive Closure and Warshall’s Algorithm 2 Chapter Four: Relations and Digraphs

3 School of Software  Ordered pair An order pair (a, b) is a listing of objects a and b in a prescribed order, which a appearing first and b appearing second (a,b) = (c,d) a=c and b=d  Product set If A and B are two nonempty sets, we define the product set or Cartesian product A × B as the set of all ordered pairs (a, b) with a ∈ A and b ∈ B. Thus A × B = {(a, b) | a ∈ A and b ∈ B} 4.1. Product Sets and Partitions 3

4 School of Software  Example 1 & 2 Let A={1, 2, 3} and B={r, s} then A × B = {(1, r), (1, s), (2, r), (2, s), (3, r), (3, s)} B × A = {(r, 1), (s, 1), (r, 2), (s, 2), (r, 3), (s, 3)} Note: A × B is not equal to B × A 4.1. Product Sets and Partitions 4

5 School of Software  Theorem 1: For any two finite, nonempty sets A and B, |A × B| = |A||B| Proof: Suppose |A| = m, |B|=n. To form an ordered pair (a, b), a ∈ A, and b ∈ B, we must perform two successive tasks: 1) choose a first element from A (m ways) 2) choose a second element from B (n ways) By multiplication principle (Section 3.1). There are totally m×n ways to form an ordered pair (a, b), which means that |A×B| = |A||B| = m×n 4.1. Product Sets and Partitions 5

6 School of Software  Example 3 If A=B=R, the set of all real numbers, then R×R, also denoted by R 2, is the set of all points in the plane. The ordered pair (a, b) gives the coordinates of a point in the plane 4.1. Product Sets and Partitions 6 O X Y (a, b)

7 School of Software  Cartesian product A 1 × A 2 × … × A m = {(a 1,a 2, …,a m ) | a i ∈ A i } where A 1, A 2, …, A m are non-empty sets.  | A 1 × A 2 × … × A m | = |A 1 | |A 2 | … |A m | where A 1, A 2, …, A m are finite, nonempty sets 4.1. Product Sets and Partitions 7

8 School of Software  Example 5 A manufacture offers the following options for its refrigerators Doors: side-by-side(s) over-under(u), three (t) Icemaker: freezer(f), door(d) Finish: standard(r), metallic(m), custom(c) Let D={s,u,t} I={f,d} and F={r, m, c} then the Cartesian product D ×I ×F contains all the categories that describe refigerator options. There are 3 ×2 ×3=18 categories. 4.1. Product Sets and Partitions 8

9 School of Software  Employees  Select D[a i1 =required 1, a i2 =required 2,…, a ik =required k ] 4.1. Product Sets and Partitions 9 Employee IDLast NameDepartmentYears with company 8341CroftFront Office2 7984CottongimSales2 2086KingHuman Resources4 0340BoswellResearch3 … … 3465HarrisSales4

10 School of Software  Partition A partition or quotient set of a nonempty set A is a collection B of nonempty subsets of A such that 1. Each element of A belongs to one of the set in B 2. If A 1 and A 2 are distinct elements of B, then A 1 ∩ A 2 = { } A B={A 1, A 2, A 3, A 4, A 5, A 6 } 4.1. Product Sets and Partitions 10 A1A2 A3 A4 A5 A6 Blocks or cells

11 School of Software  Example 6 Let A={a, b, c, d, e, f, g, h}, consider the following subsets of A A 1 = {a, b, c, d} A 2 ={a, c, e, f, g, h} A 3 = {a, c, e, g} A 4 ={b, d} A 5 ={f, h} Then {A 1, A 2 } is not a partition, since A 1 ∩ A 2 is not an empty set. Also {A 1, A 5 } is not a partition since e is not in A 1 and A 5. The collection B={A 3 A 4 A 5 } is a partition of A 4.1. Product Sets and Partitions 11

12 School of Software  Homework Ex. 2, Ex. 10, Ex. 17, Ex. 32, Ex. 36, Ex. 37 4.1. Product Sets and Partitions 12

13 School of Software  Relation Let A and B be nonempty sets. A relation R from A to B is a subset of A × B. If R ⊆ A× B and (a, b) ∈ R, we say that a is related to b by R, write a R b, if a is not related to b by R, we write a b. If A and B are equal. We say that If R ⊆ A× A is a related on A, instead of a relation from A to A. 4.2 Relations and Digraphs 13

14 School of Software  Example 1 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.  Example 2 Let A and B be sets of real numbers. We define the following relation R(equals) from A to B 4.2 Relations and Digraphs 14 Y O X

15 School of Software  Example 3 Let A={1, 2, 3, 4}. Define the following relation R (less than) on A a R b if and only if a<b Then R= { (1,2) (1,3) (1,4) (2, 3) (2,4) (3,4) }  Example 4 Let A=Z+, the set of all positive integers. Define the following relation R on A: a R b if and only if a divides b Then 4 R 12, 6 R 30, but 5 7. 4.2 Relations and Digraphs 15

16 School of Software  Example 5 Let A be the set of all people in the world. We define the following relation R on A: a R b if any only if there is a sequence a 0, a 1, a 2, …,a n of people such that a 0 =a, a n =b and a i-1 knows a i, i=1,2,…,n (n will depend on a and b) 4.2 Relations and Digraphs 16 Small-world network http://en.wikipedia.org/wiki/Small-world_network

17 School of Software  Example 6 Let A=R, the set of real numbers. We define the following relation R on A x R y if and only if x and y satisfy the equation x 2 /4+y 2 /9=1 4.2 Relations and Digraphs 17 O X Y (0,3) (2,0)

18 School of Software  Example 9 C i R C j if and only if the cost of going from C i to C j defined and less than or equal to $180. 4.2 Relations and Digraphs 18 C1C2C3C4C5 C1140100150200 C2190200160220 C3110180190250 C4190200120150 C5200100200150

19 School of Software  Sets arising from relations Let R ⊆ A× B be a relation from A to B. a) The domain of R Denoted by Dom(R), is the set of all first elements in the pairs that make up R. (Dom(R) ⊆ A ) b) The range of R Denoted by Ran(R), is the set of all second elements in the pairs that make up R. (Ran(R) ⊆ B ) 4.2 Relations and Digraphs 19

20 School of Software  Example 12 Let R be the relation of Example 6 then Dom(R) = [-2, +2] Ran(R) = [-3, +3] 4.2 Relations and Digraphs 20 O X Y (0,3) (2,0)

21 School of Software  R-relative set of x If R is a relation from A to B and x ∈ A, we define R(x), the R-relative set of x, to be the set of all y in B with the property that x is R-related to y. R(x) = {y ∈ B | x R y} If A 1 ⊆ A, then R(A 1 ), the R-relative set of A 1, is the set of all y in B with the property that x is R-related to y for some x in A 1. R(A 1 ) = {y ∈ B | x R y for some x in A 1 } 4.2 Relations and Digraphs 21

22 School of Software  Example 13 Let A={a, b, c, d} and let R={(a,a), (a,b), (b,c), (c,a), (d,c), (c,b)}. Then R(a) = {a, b} R(b)={c} If A 1 ={c, d}, Then R(A 1 )= {a, b, c} 4.2 Relations and Digraphs 22

23 School of Software  Let R be the relation of Example 6 A 1 =[-∞, -2) U (+2, +∞], A 2 =[-2, +2] then R(A 1 )= ф, R(A 2 )= [-3, +3] R(-2)={0}, R(+2)={0}, R(0) = {-3, +3} 4.2 Relations and Digraphs 23 O X Y (0,3) (2,0)

24 School of Software  Theorem 1 Let R be a relation from A to B, and let A 1 and A 2 be subsets of A, then (a) If A 1 ⊆ A 2, then R(A 1 ) ⊆ R(A 2 ) (b) R(A 1 U A 2 ) = R(A 1 ) U R(A 2 ) (c) R (A 1 ∩ A 2 ) ⊆ R(A 1 ) ∩ R(A 2 ) 4.2 Relations and Digraphs 24

25 School of Software  (a) If A 1 ⊆ A 2, then R(A 1 ) ⊆ R(A 2 ) Proof: If y ∈ R(A 1 ), then x R y for some x in A 1, since A 1 ⊆ A 2, x ∈ A 2, thus y ∈ R(A 2 ) and therefore R(A 1 ) ⊆ R(A 2 ) 4.2 Relations and Digraphs 25

26 School of Software  (b) R(A 1 U A 2 ) = R(A 1 ) U R(A 2 ) Proof : (1) R(A 1 U A 2 ) ⊆ R(A 1 ) U R(A 2 ) If y ∈ R(A 1 U A 2 ), then x R y for some x in A 1 U A 2, then x in A 1 or A 2. If x in A 1, y ∈ R(A 1 ); if x in A 2. y ∈ R(A 2 ). In either cases, y ∈ R(A 1 ) U R(A 2 ), therefore R(A 1 U A 2 ) ⊆ R(A 1 ) U R(A 2 ) (2) R(A 1 ) U R(A 2 ) ⊆ R(A 1 U A 2 ) A 1 ⊆ A 1 U A 2, then R(A 1 ) ⊆ R(A 1 U A 2 ) A 2 ⊆ A 1 U A 2, then R(A 2 ) ⊆ R(A 1 U A 2 ) Thus R(A 1 ) U R(A 2 ) ⊆ R(A 1 U A 2 ) Therefore, we obtain R(A 1 U A 2 ) = R(A 1 ) U R(A 2 ) 4.2 Relations and Digraphs 26

27 School of Software  (c) R (A 1 ∩ A 2 ) ⊆ R(A 1 ) ∩ R(A 2 ) Proof: If y ∈ R (A 1 ∩ A 2 ), then x R y for some x in A 1 ∩ A 2, since x is in both A 1 and A 2, it follows that y is in both R(A 1 ) and R(A 2 ) ; that is, y ∈ R(A 1 ) ∩ R(A 2 ). Therefore R (A 1 ∩ A 2 ) ⊆ R(A 1 ) ∩ R(A 2 ) Note: R(A 1 ) ∩ R(A 2 ) ⊆ R (A 1 ∩ A 2 ) 4.2 Relations and Digraphs 27

28 School of Software  Example 15 Let A=Z, R be “≤” A 1 ={0,1,2} and A 2 ={9,13}. Then R(A 1 ) consists of all integers n such that 0 ≤n, or 1 ≤n, or 2 ≤ n, thus R(A 1 ) ={0, 1, 2,…}. Similarly R(A 2 )={9, 10, 11,…}, so R(A 1 ) ∩ R(A 2 )= R(A 2 )={9,10,11,…} On the other hand, A 1 ∩ A 2 = ф, therefore, R (A 1 ∩ A 2 ) = ф This shows that R(A 1 ) ∩ R(A 2 ) ⊆ R (A 1 ∩ A 2 ) 4.2 Relations and Digraphs 28

29 School of Software  Theorem 2 Let R and S be relations from A to B, If R(a) =S(a) for all a in A, then R=S Proof: If a R b, then b ∈ R(a). Therefore, b ∈ S(a) and a S b. A completely similar argument shows that, if a S b, then a R b. Thus R=S. 4.2 Relations and Digraphs 29

30 School of Software  The matrix of a Relation If A={a 1,a 2, …a m } and B={b 1,b 2,…b n } 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 M R =[m ij ], which is defined by m ij = 1 if (a i b j ) ∈ R = 0 otherwise The matrix M R is called the matrix of R. 4.2 Relations and Digraphs 30

31 School of Software  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 4.2 Relations and Digraphs 31

32 School of Software  Consider the matrix Since M is 3×4, we let A={a 1,a 2,a 3 } and B={b 1,b 2,b 3,b 4 } Then (a i,b j ) in R if and only if m ij =1, thus R={(a 1,b 1 ),(a 1,b 4 ),(a 2,b 2 ),(a 2,b 3 ),(a 3,b 1 ),(a 3,b 3 } 4.2 Relations and Digraphs 32

33 School of Software  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 a i to vertex a j if and only if a i R a j (Edge) The resulting pictorial representation of R is called a directed graph or digraphy of R. 4.2 Relations and Digraphs 33

34 School of Software  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)} 4.2 Relations and Digraphs 34

35 School of Software  Example 20 Find the relation determined by the following Figure. R={ (1,1), (1,3), (2,3), (3,3), (3,2), (4,3) } 4.2 Relations and Digraphs 35

36 School of Software  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 4.2 Relations and Digraphs 36

37 School of Software  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 4.2 Relations and Digraphs 37 abcd 2311 1132 In-degree Out-degree

38 School of Software  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)} 4.2 Relations and Digraphs 38

39 School of Software  Homework Ex. 2, Ex. 8, Ex.12, Ex.20 Ex.24, Ex. 28, Ex. 32 4.2 Relations and Digraphs 39

40 School of Software  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, x 1, x 2, …, x n-1, b beginning with a and ending with b, such that a R x 1, x 1 R x 2, …,x n-1 R b Note: A path of length n involves n+1 elements of A, although they are not necessarily distinct. 4.3 Paths in Relations and Digraphs 40

41 School of Software  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 ) 4.3 Paths in Relations and Digraphs 41

42 School of Software  If n is a fixed positive integer, we define a relation R n on A as follows: x R n 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.  R n (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 4.3 Paths in Relations and Digraphs 42

43 School of Software  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 R 2 b means that a and b have an acquaintance in common a R n b if a knows someone x 1, who knows x 2, …, who knows x n-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 ∞ 4.3 Paths in Relations and Digraphs 43

44 School of Software  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 R n 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 4.3 Paths in Relations and Digraphs 44

45 School of Software  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) R 2 (b) R ∞ 4.3 Paths in Relations and Digraphs 45 R

46 School of Software  Compute R 2 a R 2 a since a R a and a R a a R 2 b since a R a and a R b a R 2 c since a R b and b R c b R 2 e since b R c and c R e b R 2 d since b R c and c R d c R 2 e since c R d and d R e Hence R 2 ={(a,a), (a,b), (a,c), (b,e), (b,d), (c,e)} 4.3 Paths in Relations and Digraphs 46

47 School of Software  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 4.3 Paths in Relations and Digraphs 47 R R∞ = { (a,a), (a,b), (a,c), (a,d), (a,e), (b,c),(b,d), (b,e), (c,d), (c,e), (d,e) }. Note: If |R| is large, it can be tedious and perhaps difficult to compute R ∞

48 School of Software  Boolean Matrix (p.37) A Boolean Matrix is an m×n matrix whose entries are either 0 or 1. Let A=[a ij ] and B=[b ij ] be m×n matrix Boolean matrix. The Join of A and B : A V B = C = [c ij ] c ij =1 if a ij =1 or b ij =1 c ij =0 otherwise The meet of A and B: A ^ B = D = [d ij ] d ij =1 if a ij and b ij are both 1 d ij =0 otherwise 4.3 Paths in Relations and Digraphs 48

49 School of Software  Boolean Product (p.38) A = [a ij ] is an m×p Boolean matrix and B = [b ij ] is a p×n Boolean matrix. The Boolean product of A and B, denoted A ⊙ B, is the m ×n Boolean matrix C=[c ij ] defined by 4.3 Paths in Relations and Digraphs 49

50 School of Software  Example Let then 4.3 Paths in Relations and Digraphs 50

51 School of Software  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) 4.3 Paths in Relations and Digraphs 51

52 School of Software  Theorem 1 If R is a relation on A={a 1,a 2,…a n }, then Proof: Let M R =[m ij ] and M R 2 =[n ij ]. By definition, the i, j-th element of M R ⊙ M R is equal to 1 if only if row i of M R and column j of M R has a 1 in the same relative position, say position k. This means that m ik =1 and m kj =1 for some k, 1 ≤ k ≤ n. By definition of matrix M R, the preceding conditions mean that a i R a k, and a k R a j. Thus a i R 2 a j, and so n ij =1. Therefore, position i, j of M R ⊙ M R is 1 if and only if n ij =1. 4.3 Paths in Relations and Digraphs 52

53 School of Software  Example 6 Let A and R be as in Example 5. Then 4.3 Paths in Relations and Digraphs 53

54 School of Software  Theorem 2 For n ≥ 2 and R is a relation on a finite set A, we have Proof by Mathematical Induction (refer to p.138-139 for more details) 4.3 Paths in Relations and Digraphs 54

55 School of Software 4.3 Paths in Relations and Digraphs 55  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 M RUS =M R V M S

56 School of Software  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 4.3 Paths in Relations and Digraphs 56

57 School of Software  Composition Let п 1 = a, x 1, x 2, …, x n-1,b be a path in relation R of length n form a to b, and п 2 = b, y 1, y 2, …, y m-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, x 1, x 2, …, x n-1,b y 1, y 2, …, y m-1,c of length n+m denoted by п 2 O п 1 4.3 Paths in Relations and Digraphs 57

58 School of Software  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 4.3 Paths in Relations and Digraphs 58

59 School of Software  Homework Ex. 2, Ex. 6, Ex. 12, Ex. 18, Ex. 20, Ex. 26 4.3 Paths in Relations and Digraphs 59

60 School of Software  Reflexive & Irreflexive A relation R on a set A is reflexive if (a, a) ∈ R for all a ∈ A. A relation R on a set A is irreflexive if a R a for all a ∈ A 4.4 Properties of Relations 60 reflexive irreflexive Dom(R) =Ran(R) =A

61 School of Software  Example 1 (a) Δ = {(a,a) | a ∈ A} Reflexive (b) R = {(a,b) ∈ A×A | a ≠ b} Irreflexive (c) A={1,2,3} and R={(1,1), (1,2)} not Reflexive ((2,2) not in R), not Irreflexive ((1,1) in R) (d) A is a nonempty set. R=Ø ⊆ A×A, the empty relation. not Reflexive, Irreflexive 4.4 Properties of Relations 61

62 School of Software  Symmetric, Asymmetric & Antisymmetric Symmetric: if a R b, then b R a Asymmetric: if a R b, then b R a (must be irreflexive) Antisymmetric: if a ≠ b, a R b or b R a ( if a R b and b R a, then a=b ) not Symmetric: some a and b with a R b, but b R a not Asymmetric: some a and b with a R b, but b R a not Antisymmetric : some a and b with a ≠ b, but both a R b and b R a 4.4 Properties of Relations 62

63 School of Software  Example 2 Let A=Z, the set of integers, and let R={ (a,b) ∈ A×A | a < b } Is R symmetric, asymmetric, or antisymmetric? Solution: not symmetric: if a<b then b<a is not true. asymmetric: if a<b, then b<a must be true Antisymmetric: if a ≠ b, then a<b or b<a must be true 4.4 Properties of Relations 63

64 School of Software  Example 4 Let A={1,2,3,4} and let R={(1,2), (2,2), (3,4), (4,1)} R is not symmetric, since (1,2) ∈ R, but (2,1) ∈ R. R is not asymmetric, since (2,2) ∈ R R is antisymmeric, since if a ≠ b, either (a, b) ∈ R or (b,a) ∈ R 4.4 Properties of Relations 64

65 School of Software  Example 5 Let A=Z +, the set of positive integers, and let R={(a,b) ∈ A×A | a divides b } Is R symmetric, asymmetric, or antisymmetric? Solution: not symmetric: 3 | 9 but 9 | 3 not asymmetric: 2 | 2 antisymmetric: if a | b and b | a, then a=b (Section 1.4) 4.4 Properties of Relations 65

66 School of Software  The properties of symmetric matrix The matrix M R =[m ij ] of a symmetric relation on a finite set A= {a 1,a 2, …,a n } satisfies the following property if m ij =1 (a i R a j ) then m ji =1 (a j R a i ) Moreover, if m ij =0 (a i R a j ) then m ji =0 (a i R a j ) Therefore, we have 4.4 Properties of Relations 66

67 School of Software  The properties of asymmetric matrix The matrix M R =[m ij ] of an asymmetric relation on a finite set A= {a 1,a 2, …,a n } satisfies the following property : if m ij =1 (a i R a j ) then m ji =0 (a j R a i ) Moreover, if m ii =0 (a i R a i ) for all i=1,2, …,n 4.4 Properties of Relations 67

68 School of Software  The properties of antisymmetric matrix The matrix M R =[m ij ] of an antisymmetric relation on a finite set A= {a 1,a 2, …,a n } satisfies the following property if i ≠ j, ( a i ≠ a j ) then m ij =0 (a i R a j ) or m ji =0 (a j R a i ) 4.4 Properties of Relations 68

69 School of Software  Example 6 4.4 Properties of Relations 69 Symmetric Not Asymmetic Not Antisymmetric Symmetric Not Asymmetic Not Antisymmetric Not Symmetric Not Asymmetic Antisymmetric

70 School of Software  Example 6 4.4 Properties of Relations 70 Not Symmetric Not Asymmetic Not Antisymmetric Not Symmetric Not Asymmetic Antisymmetric Not Symmetric Asymmetic Antisymmetric

71 School of Software  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”. 4.4 Properties of Relations 71

72 School of Software  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) 4.4 Properties of Relations 72

73 School of Software  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)} 4.4 Properties of Relations 73 digraphs graphs Undirected edge Adjacent vertices

74 School of Software  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. 4.4 Properties of Relations 74

75 School of Software  Example 9 Let A=Z +, and R={(a,b) ∈ A×A | a divides b } Is R transitive? Solution: Suppose that a R b and b R c, so that a | b and b | c. It then does follow that a | c (See Theorem 2 of Section 1.4). Thus R is transitive. 4.4 Properties of Relations 75

76 School of Software  Example 10 Let A ={1,2,3,4} and let R={(1,2),(1,3),(4,2)} Is R transitive? Solution: Since there are no elements a, b and c in A such that a R b and b R c, but a R c, R is transitive. 4.4 Properties of Relations 76

77 School of Software  A sufficient condition of transitive A relation R is transitive if and only if its matrix M R =[m ij ] has the property if m ij =1 and m jk =1, then m ik =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 M R must have a 1 in the same position. Thus, in particular, if, then R is transitive. 4.4 Properties of Relations 77

78 School of Software  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. 4.4 Properties of Relations 78

79 School of Software  If R is transitive, may not equal to M R (Verify the Example 10) 4.4 Properties of Relations 79

80 School of Software  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 R 2 c. Therefore, we may rephrase the definition of transitivity as follows: If a R 2 c, then a R c, that is R 2 ⊆ R 4.4 Properties of Relations 80

81 School of Software  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 R n ⊆ R for all n >=1 How to Proof the Theorem? 4.4 Properties of Relations 81

82 School of Software  Theorem 2 Let R be a relation on a set A, then (a) Reflexivity of R means that a ∈ R(a) for all a in A. (b) Symmetry of R means that a ∈ R(b) iff b ∈ R(a). (c) Transitivity of R means that if b ∈ R(a) and c ∈ R(b), then c ∈ R(a). 4.4 Properties of Relations 82

83 School of Software  Homework Ex. 2, Ex. 14, Ex. 18, Ex. 26, Ex. 32, Ex. 38 4.4 Properties of Relations 83

84 School of Software  Equivalence Relation 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} ? 4.5 Equivalence Relations 84

85 School of Software  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. 4.5 Equivalence Relations 85

86 School of Software  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. 4.5 Equivalence Relations 86

87 School of Software  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 4.5 Equivalence Relations 87

88 School of Software  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 4.5 Equivalence Relations 88

89 School of Software  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)} 4.5 Equivalence Relations 89

90 School of Software  P is a partition of A and R is the equivalence relation determined by P If a in A i, i=1,2…6 then A i =R(a) Lemma 1*: a R b iff R(a)=R(b) 4.5 Equivalence Relations 90 A1A2 A3 A4 A5 A6

91 School of Software  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 4.5 Equivalence Relations 91

92 School of Software 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. 4.5 Equivalence Relations 92

93 School of Software  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) = ф 4.5 Equivalence Relations 93

94 School of Software  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) 4.5 Equivalence Relations 94

95 School of Software  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) 4.5 Equivalence Relations 95

96 School of Software  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}} 4.5 Equivalence Relations 96

97 School of Software  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. 4.5 Equivalence Relations 97

98 School of Software  The procedure of determining A/R is as follows: Support A={a 1,a 2,…} (finite or countable) Step 1: i=0; j=0; Step 2: i=i+1; Step 3: if a i ∈ A, then j=j+1; b j =a i and compute the equivalence class R(b j ), A= A- R(b j ) Step 4: if A become an empty set, then we obtain the equivalence classes R(b 1 ), R(b 2 ), … R(b j ) (Note: j may be finite or infinite) otherwise repeat step 2 ~ 4 4.5 Equivalence Relations 98

99 School of Software  Homework Ex. 4, Ex. 12, Ex. 14, Ex. 20, Ex. 23, Ex. 28 4.5 Equivalence Relations 99

100 School of Software  Let R and S be relations from a set A to a set B R and S are subsets of A×B. We can use set operations on the relations R and S Relations: (three representations) 1. the set of ordered pairs (finite or infinite) 2. digraph (finite) 3. matrix (finite) 4.7 Operations on Relations 100

101 School of Software  Complementary relation if and only if a R b  The intersection R ∩ S a (R ∩ S) b means that a R b and a S b  The union R U S a (R U S) b means that a R b or a S b 4.7 Operations on Relations 101

102 School of Software  Inverse Let R be a relation from A to B, the relation R -1 is a relation from B to A (reverse order from R) denoted by b R -1 a if and only if a R b Note: (R -1 ) -1 =R Dom(R -1 ) = Ran (R) Ran(R -1 ) = Dom(R) 4.7 Operations on Relations 102

103 School of Software  Example 1 Let A={1,2,3,4} and B= {a,b,c}. We Let R={(1,a), (1,b), (2,b),(2,c),(3,b),(4,a)} and S= {(1,b),(2,c),(3,b),(4,b)} Compute: (a) (b) R ∩ S (c) R U S (d) R -1 Solution: A×B = { (1,a), (1,b), (1,c), (2,a), (2,b), (2,c), (3,a), (3,b), (3,c), (4,a), (4,b), (4,c) } 4.7 Operations on Relations 103

104 School of Software  Example 1 R∩S = { (1,b), (3,b), (2,c) } R ∪ S = { (1,a), (1,b), (2,b), (2,c), (3,b), (4,a), (4,b) } R -1 = { (a,1), (b,1), (b,2), (c,2), (b,3), (a,4) } 4.7 Operations on Relations 104

105 School of Software  Example 2 Let A=R. Let R be the relation ≤ on A and let S be ≥ Then the complement of R is the relation >, since a ≤ b means a>b Similarly, the complement of S is the relation <. On the other hand, R -1 =S, since for any number a and b a R -1 b if and only if b R a if and only if b ≤ a if and only if a ≥ b if and only if a S b R ∩ S : “=” R U S : A×A 4.7 Operations on Relations 105

106 School of Software  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) } 4.7 Operations on Relations 106

107 School of Software  Example 4 4.7 Operations on Relations 107

108 School of Software  Operations on Boolean Matrix 4.7 Operations on Relations 108

109 School of Software  Theorem 1 Suppose that R and S are relations from A to B (a) If R ⊆ S, then R -1 ⊆ S -1. (b) If R ⊆ S, then S ⊆ R (c) (R∩S) -1 =R -1 ∩ S -1 and (R U S) -1 = R -1 U S -1 (d) (R∩S) = R U S and R U S = R ∩ S 4.7 Operations on Relations 109

110 School of Software  Theorem 2 Let R and S be relations on a set A (a) If R is reflexive, so is R -1 (b) If R and S are reflexive, then so are R∩S and R U S (c) R is reflexive if and only if R is irrflexive 4.7 Operations on Relations 110

111 School of Software  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) 4.7 Operations on Relations 111

112 School of Software  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 = Ø 4.7 Operations on Relations 112

113 School of Software  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 4.7 Operations on Relations 113

114 School of Software  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) 4.7 Operations on Relations 114

115 School of Software  Theorem 5 Let R and S be relations on A (a) (R ∩ S ) 2 ⊆ R 2 ∩ S 2 (b) If R and S are transitive, so is R ∩ S (c) If R and S are equivalence relations, so is R ∩ S 4.7 Operations on Relations 115

116 School of Software  Closure If R is a relation on a set A, and R lacks some relational properties (e.g. reflexivity, symmetry and transitivity). We try to add as few new pairs as possible to R, so that the resulting relation R 1 has the property we desired. If R 1 exists, we call it the closure of R with the respect to the property in question. 4.7 Operations on Relations 116

117 School of Software  Example 8 Support that R is a relation on A, and R is not reflexive. R 1 =R ∪ Δ is the smallest reflexive relation on A containing R. The reflexive closure of R is R ∪ Δ.  Example 9 Support that R is a relation on A, and R is not symmetric. R 1 =R ∪ R -1 is the smallest symmetric relation containing R. (Note: (R ∪ R -1 ) -1 = R -1 ∪ R ) 4.7 Operations on Relations 117

118 School of Software  The symmetric closure of R R= {(a,b), (b,c), (a,c), (c,d)} R ∪ R -1 = {(a,b), (b,a),(b,c), (c,b), (a,c), (c,a), (c,d), (d,c)} 4.7 Operations on Relations 118

119 School of Software  Composition Support A, B and C are sets, R is a relation from A to B, and S is a relation from B to C, the composition of R and S, written S o R is a relation from A to C If a is in A and c is in C, then a S o R c if and only if for some b in B, we have a R b, and b S c. 4.7 Operations on Relations 119 ABC R S SoRSoR

120 School of Software  Example 10 Let A= {1,2,3,4} and R={(1,2), (1,1), (1,3), (2,4),(3,2)} and S={(1,4), (1,3), (2,3),(3,1), (4,1)}. Since (1,2) in R, (2,3) in S, we must have (1,3) in S o R Similarly, we have S o R = {(1,4), (1,3), (1,1),(2,1), (3,3)} 4.7 Operations on Relations 120

121 School of Software  Theorem 6 Let R be a relation from A to B and let S be a relation from B to C. Then if A 1 is any subset of A, we have (S o R)(A 1 )= S(R(A 1 ) ) Proof: by the definition of composition and relative set 4.7 Operations on Relations 121

122 School of Software  Theorem 7 Let A, B, C and D be sets, R a relation from A to B, S a relation from B to C and T a relation from C to D. Then T o (S o R) = (T o S) o R Proof: by the definition of composition 4.7 Operations on Relations 122

123 School of Software  Example 13 Let A={a, b}, R={(a, a), (b, a), (b,b)} and S={ (a, b), (b, a), (b, b)}. Then S o R={(a,b), (b,a), (b,b)} R o S={(a,a), (a,b), (b,a),(b,b)} In general, S o R does not equal to R o S 4.7 Operations on Relations 123

124 School of Software  Theorem 8 Let A, B and C be sets, R a relation from A to B, and S a relation from B to C. Then (S o R) -1 = R -1 o S -1 Proof: by the definition of composition and inverse 4.7 Operations on Relations 124

125 School of Software  Homework Ex. 5, Ex. 12, Ex. 16, Ex. 22 Ex. 25, Ex. 29, Ex. 37 4.7 Operations on Relations 125

126 School of Software  Theorem 1 Let R be a relation on a set A. Then R ∞ is the transitive closure of R Proof (a)R ∞ is transitive. a R ∞ b, b R ∞ c, then a R ∞ c (b)R ∞ is the smallest transitive relation containing R. Support S is any transitive relation on A, and R ⊆ S, S is transitive  S n ⊆ S, for all n (P.146 Theorem 1) then S ∞ =S 1 U S 2 … ⊆ S R ∞ ⊆ S ∞ ⊆ S (why?) This means that R ∞ is the smallest one. 4.8 Transitive Closure and Warshall’s Algorithm 126

127 School of Software  Example 1 Let A={1,2,3,4} and let R ={(1,2), (2,3), (3,4), (2,1)}. Find the transitive closure of R Method # 1: 1  1, 2, 3, 4 2  1, 2, 3, 4 3  4 4  ф R ∞ = {(1,1), (1,2), (1,3), (1,4), (2,1), (2,2), (2,3), (2,4), (3,4)} 4.8 Transitive Closure and Warshall’s Algorithm 127

128 School of Software  Example 1 Method # 2 4.8 Transitive Closure and Warshall’s Algorithm 128

129 School of Software  Theorem 2 Let A be a set with |A|=n, and let R be a relation on A. Then Proof: If x 0 R ∞ x m, then there is a path from x 0 to x m with length m x 0, x 1, x 2, …, x m case #1: if 1≤ m≤ n, then x 0 R m x m 4.8 Transitive Closure and Warshall’s Algorithm 129

130 School of Software  Theorem 2 case #2: if m>n, there must have some vertex appearing two times in the path (why?), saying x i = x j, where i<j x 0, x 1, …, x i, …, x j, x j+1 … x m there must exists another path from x 0 to x m with length less than m (why?), x 0, x 1, …, x i, x j+1 … x m Therefore, if x 0 R ∞ x m, we can find the shortest path from x 0 to x m with length less than or equal to n (why?), namely x 0 R k x m 1≤ k≤ n Therefore, the theorem has been proofed. 4.8 Transitive Closure and Warshall’s Algorithm 130

131 School of Software  Let R be a relation on a set A={a 1,a 2,…,a n }. Interior vertices If x 1,x 2,…x m is a path in R, then any vertices other than x 1 and x m are called interior vertices of the path. Boolean matrix W k (n matrices with size n-by-n) For 1 ≤ k ≤n, W k has a 1 in position i, j if and only if there is a path from a i to a j in R whose interior vertices, if any, come from the set {a 1,a 2, …, a k } W n =M R ∞ Since any vertex must come from the set {a 1,a 2,…,a n }, it follows that the matrix W n has a 1 in position i, j if some path in R connects a i with a j 4.8 Transitive Closure and Warshall’s Algorithm 131

132 School of Software  How to compute W k k=1,2,…n Let W 0 =M R Support W k-1 =[s ij ] is known, let W k =[t ij ] then if t ij =1, then there must be a path from a i to a j whose interior vertices come from the set {a 1,a 2, …,a k }. Case #1: If a k is not an interior vertex of this path, then all interior vertices must actually come from the set {a 1,a 2,…a k-1 }, so s ij =1. Case #2: If a k is an interior vertex of this path, then s ik =1 and s kj =1 (refer to the proof of Theorem 2) 4.8 Transitive Closure and Warshall’s Algorithm 132 P 1, P 2 are subpaths with all interior vertices from {a 1,a 2, …, a k-1 } akak aiai ajaj P1P1 P2P2

133 School of Software  Warshall’s Algorithm Warshall’s Algorithm is a more efficient algorithm for computing transitive closure, the procedure of the algorithm is as follows: Step1: First transfer W k all 1’s in W k-1 Step 2: List the locations p 1,p 2,… in column k of W k-1, where the entry is 1 and the locations q 1,q 2,… in row k of W k-1, where the entry is 1 Step 3: Put 1’s in all the positions p i, q j of W k 4.8 Transitive Closure and Warshall’s Algorithm 133

134 School of Software  Example 2 Consider the relation R defined in Example 1. Then 4.8 Transitive Closure and Warshall’s Algorithm 134 pi: 2 qj: 2 pi: 1, 2 qj: 1, 2, 3 pi: 1, 2 qj: 4 pi: 1, 2 qj: ф

135 School of Software  Algorithm WARSHALL 1. CLOSURE  MAT 2. FOR K=1 THRU N a. FOR I=1 THRU N 1. FOR J=1 THRU N a. CLOSURE[I,J]  CLOSURE[I,J] V (CLOSURE[I,K] ^ CLOSURE[K,J] ) Warshall’s Algorithm: O(N 3 ) Boolean Matrix operations: O(N 4 ) 4.8 Transitive Closure and Warshall’s Algorithm 135

136 School of Software  Theorem 3 If R and S are equivalence relations on a set A, then the smallest equivalence relation containing both R and S is (R U S) ∞ Proof: 1.Reflexive. △ ⊆ R, △ ⊆ S, △ ⊆ R U S ⊆ (R U S) ∞ 2.Symmetric. R=R -1, S=S -1, (RUS) -1 =R -1 U S -1 =R U S all paths in RUS are two-way streets, and it follows from the definitions that (R U S) ∞ must be symmetric (why ? ) 3.Transitive. (R U S) ∞ is the transitive closure of R U S (Theorem 1). (the smallest ) 4.8 Transitive Closure and Warshall’s Algorithm 136

137 School of Software  Example 3 Let A={1,2,3,4,5}, R={(1,1), (1,2), (2,1), (2,2), (3,3), (3,4), (4,3), (4,4), (5,5)}, and S= { (1,1), (2,2), (3,3), (4,4), (4,5), (5,4), (5,5) }. Find the smallest equivalence relation containing R and S, and compute the partition of A that it produces 4.8 Transitive Closure and Warshall’s Algorithm 137 1 2 3 4 5 R S

138 School of Software 4.8 Transitive Closure and Warshall’s Algorithm 138 (R ∪ S)∞ = { (1,1), (1,2), (2,1), (2,2), (3,3), (3,4), (3,5), (4,3), (4,4), (4,5), (5,3), (5,4), (5,5 } 1 2 3 4 5 (RUS) ∞

139 School of Software  Homework Ex. 1, Ex. 2, Ex. 7, Ex. 13, Ex. 18, Ex. 25 4.8 Transitive Closure and Warshall’s Algorithm 139


Download ppt "Chapter 4 Relations and Digraphs Weiqi Luo ( 骆伟祺 ) School of Software Sun Yat-Sen University : Office : A309"

Similar presentations


Ads by Google