1 / 31

CSCI 115

CSCI 115. Chapter 4 Relations and Digraphs. CSCI 115. §4 .1 Product Sets and Partitions. §4 .1 – Product Sets and Partitions. Product Set Ordered pair Cartesian Product Theorem 4.1.1 For any 2 finite non-empty sets A and B, |A x B| = |A||B|. §4 .1 – Product Sets and Partitions.

rasha
Download Presentation

CSCI 115

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. CSCI 115 Chapter 4 Relations and Digraphs

  2. CSCI 115 §4.1 Product Sets and Partitions

  3. §4.1 – Product Sets and Partitions • Product Set • Ordered pair • Cartesian Product • Theorem 4.1.1 • For any 2 finite non-empty sets A and B, |A x B| = |A||B|

  4. §4.1 – Product Sets and Partitions • Partitions • A partition (quotient set) of A is a set P of nonempty subsets of A such that: • Each element of A belongs to a set in P • If A1 and A2 are elements of P, then A1A2 = {} • Each element of P is called a cell or a block

  5. CSCI 115 §4.2 Relations and Digraphs

  6. §4.2 – Relations and Digraphs • Relations • Relation from A to B • Subset of A x B • Relation on A • Subset of A x A

  7. §4.2 – Relations and Digraphs • Sets arising from relations • Domains • Domain of relation • Ranges • Range of relation • Range of an element • Range of a subset

  8. §4.2 – Relations and Digraphs • Theorem 4.2.1 • Let R be a relation from A to B, and let A1 and A2 be subsets of A. Then: • If A1 A2, then R(A1)  R(A2) • R(A1 A2) = R(A1)  R(A2) • R(A1 A2)  R(A1)  R(A2) • Theorem 4.2.2 • Let R and S be Relations from A to B. If R(a) = S(a)  a  A, then R = S.

  9. §4.2 – Relations and Digraphs • The matrix of a relation • If A = {a1, a2, …, am} and B = {b1, b2, …, bn}, then a relation R from A to B can be represented by an m x n boolean matrix (MR) constructed as follows: mij = { 1 if (ai, bj)  R0 if (ai, bj)  R

  10. §4.2 – Relations and Digraphs • The Digraph of a relation • Let R be a relation on A. The Digraph of R is constructed as follows: • Draw a circle for each element in A, and label the circles accordingly (these are called vertices) • Draw an arrow from ai to ajiffaiRaj(these are called edges) • In-degrees and out-degrees

  11. §4.2 – Relations and Digraphs • Relation Restriction • Let R be a relation on a set A, with B  A. The restriction of R to B is R  (B x B).

  12. CSCI 115 §4.3 Paths in Relations and Digraphs

  13. §4.3 – Paths in Relations and Digraphs • Path of length n from a to b: • aRx1, x1Rx2, x2Rx3, …, xn-1Rb • Geometric path in digraph • Cycle: A path that begins and ends at the same vertex

  14. §4.3 – Paths in Relations and Digraphs • New relations from paths • Rn: xRny iff there is a path of length n from x to y • R: xRy iff there is any path from x to y • Connectivity Relation • R*: xR*y iff there is a path from x to y, or x = y • Reachability Relation

  15. §4.3 – Paths in Relations and Digraphs • Theorem 4.3.1 • If R is a relation on A = {a1, a2, …, an}, then MR2 = MR MR = ((MR))2 • Theorem 4.3.2 • For n  2 and R a relation on a finite set A, we have MRn = MR MR...  MR (n factors)

  16. §4.3 – Paths in Relations and Digraphs • Path composition •  is used as a variable for paths • Assume we have: • 1: a, x1, x2, …, xn-1, b • 2: b, y1, y2, …, ym-1, c • Then, we can compose 1 and 2 as follows: • 21: a, x1, x2, …, xn-1, b, y1, y2, …, ym-1, c • 21 is a path of length n + m • 12 does not make sense

  17. CSCI 115 §4.4 Properties of Relations

  18. §4.4 – Properties of Relations • A relation R on a set A is: • Reflexive iff (a,a)  Ra  A • Irreflexive iff (a,a)  R a  A • Symmetric iff (a,b)  R  (b,a)  R • Asymmetric iff (a,b)  R  (b,a)  R • Antisymmetric iff (a,b)  R and (b,a)  R  a = b • Transitive iff (a,b)  R and (b,c)  R  (a,c)  R

  19. §4.4 – Properties of Relations • Theorem 4.4.1 • A relation R is transitive iff 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 (i.e. aRb). In other words, R is transitive iff Rn  R  n > 1.

  20. §4.4 – Properties of Relations • Theorem 4.4.2 • Let R be a relation on a set A. Then: • Reflexivity of R means a  R(a)  a  A • Symmetry of R means a  R(b) iff b  R(a) • Transitivity of R means b  R(a) and c  R(b) implies c  R(a)

  21. §4.4 – Properties of Relations • Other properties: • The digraph of a reflexive relation has a cycle of length 1 at every vertex • The digraph of an irreflexive relation has no cycles of length 1 • If R is reflexive then the Domain(R) = Range(R) = A • The matrix of a reflexive relation has all 1s on the diagonal • The matrix of an irreflexive relation has all 0s on the diagonal • The matrix of a symmetric relation has mij = mjii,j (MR = MRT) • The matrix of an asymmetric relation meets the following 2 criteria: • mij = 1  mji = 0 AND the diagonal must be all 0s • The matrix of an antisymmetric relation meets the following criteria: • If ij, then mij = 0 or mji = 0 • The Matrix of a transitive relation meets the following criteria: • MR must have a 1 everywhere ((MR))2 has a 1

  22. §4.4 – Properties of Relations • Graph of a symmetric relation • Undirected edge • Adjacent vertices • Connected graphs • Disconnected graphs

  23. CSCI 115 §4.5 Equivalence Relations

  24. §4.5 – Equivalence Relations • Equivalence Relation • A relation R on a set A is an equivalence relation if it is reflexive, symmetric, and transitive

  25. §4.5 – Equivalence Relations • Theorem 4.5.1 • Let P be a partition of a set A such that P = {A1, A2, …, An}. Define a relation R on A as follows:aRb iff aAi and bAi (i  {1, 2, …, n}). Then R is an equivalence relation on A. • Here R is called the equivalence relation determined by P.

  26. §4.5 – Equivalence Relations • Lemma 4.5.1 • Let R be an equivalence relation on A. Let a, b  A. Then aRb iff R(a) = R(b). • Theorem 4.5.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. • Note: When R is an equivalence relation on A, the sets R(a) are called equivalence classes. The partition constructed in Theorem 4.5.2 is denoted A/R.

  27. §4.5 – Equivalence Relations Procedure to determine A/R (A finite or countable): • Choose any aA and find R(a). • If R(a)  A, choose bA, bR(a) and find R(b). • If A is not the union of the computed equivalence classes, choose xA such that x is not in any of the equivalence classes, and find R(x). • Repeat step 3 until A is accounted for, or a pattern emerges which describes the equivalence classes. • A/R is the partition formed by using each equivalence class as a cell.

  28. CSCI 115 §4.6 Data Structures for Relations and Digraphs

  29. §4.6 – Data Structures for Relations and Digraphs • Linked list data structure • Storage cell • Data • Pointer • Implementations • Structures • Arrays • We will use the array implementation

  30. §4.6 – Data Structures for Relations and Digraphs • Implementation 1 – Start, Tail, Head, Next • Fill in tail and head arrays • Fill in start variable • Fill in next array • The tail, head and next arrays have as many elements as the digraph has edges • Start is a simple variable (not an array)

  31. §4.6 – Data Structures for Relations and Digraphs • Implementation 2 – Vert, Tail, Head, Next • Fill in tail and head arrays • Fill in next array (within vertex) • Fill in vert array. The data in vert is the first subscript in tail that corresponds to the current vertex • The tail, head and next arrays have as many elements as the digraph has edges • The vert array has as many elements as the digraph has vertices

More Related