Chapter 4 Relations and Digraphs

Slides:



Advertisements
Similar presentations
Representing Relations
Advertisements

CSCI 115 Chapter 6 Order Relations and Structures.
Representing Relations Rosen 7.3. Using Matrices For finite sets we can use zero-one matrices. Elements of each set A and B must be listed in some particular.
CSE115/ENGR160 Discrete Mathematics 04/26/12 Ming-Hsuan Yang UC Merced 1.
8.3 Representing Relations Connection Matrices Let R be a relation from A = {a 1, a 2,..., a m } to B = {b 1, b 2,..., b n }. Definition: A n m  n connection.
Chapter 3 Relations. Section 3.1 Relations and Digraphs.
Chapter 4 Relations and Digraphs Weiqi Luo ( 骆伟祺 ) School of Software Sun Yat-Sen University : Office : A309
Chap6 Relations Def 1: Let A and B be sets. A binary relation from A
Representing Relations Using Matrices
Chapter 7 Relations : the second time around
1 Relations: The Second Time Around Chapter 7 Equivalence Classes.
Relations binary relations xRy on sets x  X y  Y R  X  Y Example: “less than” relation from A={0,1,2} to B={1,2,3} use traditional notation 0 < 1,
Chapter 9 1. Chapter Summary Relations and Their Properties n-ary Relations and Their Applications (not currently included in overheads) Representing.
Applied Discrete Mathematics Week 10: Equivalence Relations
Properties of Relations In many applications to computer science and applied mathematics, we deal with relations on a set A rather than relations from.
Chapter 9. Chapter Summary Relations and Their Properties Representing Relations Equivalence Relations Partial Orderings.
Lecture 14 Relations CSCI – 1900 Mathematics for Computer Science Fall 2014 Bill Pine.
Chapter 9. Chapter Summary Relations and Their Properties n-ary Relations and Their Applications (not currently included in overheads) Representing Relations.
Discrete Math for CS Binary Relation: A binary relation between sets A and B is a subset of the Cartesian Product A x B. If A = B we say that the relation.
CSCI 115 Chapter 7 Trees. CSCI 115 §7.1 Trees §7.1 – Trees TREE –Let T be a relation on a set A. T is a tree if there exists a vertex v 0 in A s.t. there.
1 CS104 : Discrete Structures Chapter V Graph Theory.
Chapter 9. Section 9.1 Binary Relations Definition: A binary relation R from a set A to a set B is a subset R ⊆ A × B. Example: Let A = { 0, 1,2 } and.
8.3 Representing Relations Directed Graphs –Vertex –Arc (directed edge) –Initial vertex –Terminal vertex.
Sets Define sets in 2 ways  Enumeration  Set comprehension (predicate on membership), e.g., {n | n  N   k  k  N  n = 10  k  0  n  50} the set.
1 Closures of Relations: Transitive Closure and Partitions Sections 8.4 and 8.5.
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Relations.
Discrete Mathematics Relation.
Relations and their Properties
§ 每周五交作业,作业成绩占总成绩的 10% ; § 平时不定期的进行小测验,占总成绩的 20% ; § 期中考试成绩占总成绩的 20% ;期终考 试成绩占总成绩的 50% § 每周五下午 1 ; 00—3 : 00 ,答疑 § 地点:软件楼 301.
CHAPTER 3 FUZZY RELATION and COMPOSITION. 3.1 Crisp relation Product set Definition (Product set) Let A and B be two non-empty sets, the product.
Mathematical Preliminaries
Sets and Subsets Set A set is a collection of well-defined objects (elements/members). The elements of the set are said to belong to (or be contained in)
Relations. Important Definitions We covered all of these definitions on the board on Monday, November 7 th. Definition 1 Definition 2 Definition 3 Definition.
CSCI 115 Chapter 8 Topics in Graph Theory. CSCI 115 §8.1 Graphs.
Relation. Combining Relations Because relations from A to B are subsets of A x B, two relations from A to B can be combined in any way two sets can be.
Problem Statement How do we represent relationship between two related elements ?
Chapter 9. Chapter Summary Relations and Their Properties n-ary Relations and Their Applications (not currently included in overheads) Representing Relations.
4. Relations and Digraphs Binary Relation Geometric and Algebraic Representation Method Properties Equivalence Relations Operations.
Unit II Discrete Structures Relations and Functions SE (Comp.Engg.)
Representing Relations Using Matrices A relation between finite sets can be represented using a zero-one matrix Suppose R is a relation from A = {a 1,
Chapter Relations and Their Properties
GRAPHS. Graph Graph terminology: vertex, edge, adjacent, incident, degree, cycle, path, connected component, spanning tree Types of graphs: undirected,
Relations Section 9.1, 9.3—9.5 of Rosen Spring 2012
Chapter 8: Relations. 8.1 Relations and Their Properties Binary relations: Let A and B be any two sets. A binary relation R from A to B, written R : A.
8.5 Equivalence Relations
RelationsCSCE 235, Spring Introduction A relation between elements of two sets is a subset of their Cartesian products (set of all ordered pairs.
Relations and Functions ORDERED PAIRS AND CARTESIAN PRODUCT An ordered pair consists of two elements, say a and b, in which one of them, say a is designated.
CSCI 115 Course Review.
Section 7.3: Representing Relations In this section, we will cover two ways to represent a relation over a finite set other than simply listing the relation.
Section 9.3. Section Summary Representing Relations using Matrices Representing Relations using Digraphs.
1 CMSC 250 Discrete Structures CMSC 250 Lecture 41 May 7, 2008.
Chapter8 Relations 8.1: Relations and their properties.
Representing Relations Using Digraphs
Relations and Their Properties
Citra Noviyasari, S.Si, MT
Relations.
Relations Binary relations represent relationships between the elements of two sets. A binary relation R from set A to set B is defined by: R  A 
Relations Chapter 9.
Basic Concepts Graphs For more notes and topics visit:
Relations and Digraphs
Representing Relations
Dr. Ameria Eldosoky Discrete mathematics
Dr. Ameria Eldosoky Discrete mathematics
CSNB 143 Discrete Mathematical Structures
Relations and Their Properties
Relations (sections 7.1 – 7.5)
Graphs G = (V, E) V are the vertices; E are the edges.
Relations: The Second Time Around
Agenda Lecture Content: Relations (Relasi)
4.4 Properties of Relations
Presentation transcript:

Chapter 4 Relations and Digraphs CSCI 115 Chapter 4 Relations and Digraphs

§4.1 Product Sets and Partitions CSCI 115 §4.1 Product Sets and Partitions

§4.1 – Product Sets and Partitions 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 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

§4.2 Relations and Digraphs CSCI 115 §4.2 Relations and Digraphs

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

§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

§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.

§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)  R 0 if (ai, bj)  R

§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 aj iff aiRaj (these are called edges) In-degrees and out-degrees

§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).

§4.3 Paths in Relations and Digraphs CSCI 115 §4.3 Paths in Relations and Digraphs

§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

§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

§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)

§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

§4.4 Properties of Relations CSCI 115 §4.4 Properties of Relations

§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

§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.

§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)

§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

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

§4.5 Equivalence Relations CSCI 115 §4.5 Equivalence Relations

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

§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.

§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.

§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.

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

§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

§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)

§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