Download presentation

Presentation is loading. Please wait.

Published byZakary Winford Modified over 3 years ago

1
Chapter 3

2
Relations Definitions Relations Binary relations Domain Range Vertex Direct edge Loops Reflective Relations Sympatric Relations Anti Symmetric Relations

3
Metrics of Relations Reflective Relations Symmetric Relations Matrix multiplications

4
Relations A set of ordered pairs. The existence or the presence of the order pair (a, b) indicates that there is a relationship from a to b. The relational Dbase among records in a data base is based on the Relations concept.

5
A relation from one set to another can be thought of as which element of the first set is related to which element in the second set StudentCourse BillComputer Science MaryMath BillArt Beth History Computer Science DaveMath Student col is the Domain, Course Col is the Range

6
Binary Relation R A binary relation R from a set X to a set Y is subset of the Cartesian product X* Y If (x, y) R, we write x R y and we say x related to y. If x = y we say R is Binary relation on X. A function is a special type of Relation, a function f from X to Y is a Relation from X to Y with the properties: The Domain f equals X For each x X, there is exactly y Y such that (x,y) f If X = { Bill, Mary, Beth, Dave} and Y = {Computer Science, Math, Art, History} Then Our Relation from the previous table R = { (Bill, Computer Science), (Mary, Math),(Bill, Art) (Beth, History,), (Beth, Computer Science ),(Dave. Math)}. Since the order pair (Beth, History) R, we can write Beth R History This shows that a Relation can b given by specifying which ordered pair belongs to the Relation

7
Defining a Relation by giving a Rule for membership in the Relation X = {2, 3, 4} an Y = {3, 4, 5, 6, 7} If we define a relation R from X to Y by (x, y) R if x divides by y. We obtain R ={(2,4), (2,6), (3,3), (3,6), (4,4) And if we Write R as a table we obtain XY 24 26 33 36 44 The Domain of R is the set {2,3,4} The Range of the set R is {3, 4, 6}

8
Graphs Let R be the Relation on X = {1,2,3,4} defined by the order pair (x, y) R if x y and x, y X The Relation R can be written as R = {(1,1),(1,2,),(1,3), (1,4), (2,2),(2,3),(2,4), (3,3),(3,4),(4,4)} The Relation R can be drawn as a graph, we call it a digraph (direct graph and will be covered in Chapter 8 1 3 4 2 1, 2, 3, 4 are called vertices The Arrows are called edges If there is a relation between vertices we draw an arrow to represent the relation Element(vertices) with the form off (x, x) are called lops

9
Digraph of Relation The Relation R on X = {a, b, c, d} given by the Digraph R = {(a,b),(a,d),(d,c), (c,d), (b,b)} a b c d

10
Reflective relation R A Relation R on the set X is called reflective if (x, x) R for every x X The relation R on the set X ={1,2,3,4}is reflective for each x X, (x, x) R Specifically: {(1,1,), (2,2), (3,3),(4,4)} are each in R The Digraph of reflective Relation has a loop on every vertex THE GRAPH ON SLIDE 8 IS REFLEXSIVE

11
Not a reflective The Relation R R = {(a,b),(a,d),(d,c), (c,d), )} on X = {a, b, c, d} given by the Digraph a b c d Is not a reflective relation because none of the Vertices have a loop, there is no (b,b), (c,c).. (b,b) and (c,c) R

12
Not a reflective The Relation R on X = {a, b, c, d} given by the Digraph R = {(a,a),(b,c),(c,b), (d,d), )} Is not a reflective relation is b X, c X But there is no loop on (b,b), (c,c) Vertices have a loop a d cb No Loop

13
symmetric A relation R on set X is called Symmetric if for all x, y X, if (x, y) R then (y, x) R The Relation R = {(a,a), (b,c),(c,b), (d,d) } on X = {a, b, c, d} Is symmetric because for all x, y if (x,y) R then (y, x) R example ((b,c) is in R and (c,b) is in also in R The diagraph of a symmetric relation has the property that whenever there is a direct edge from v to w there is also a direct edge from w to v bc a d

14
NOT Symmetric example The Relation R on X = {1,2,3,4} defined by (x, y) R if x y, x,y X R = {(1,1),(1,2,),(1,3), (1,4), (2,2),(2,3),(2,4), (3,3),(3,4),(4,4)} is Not Symmetric. (2,3) R but (3,2) R. The digraph of this relation has a direct edge from 2 to 3 but no direct edge between 3 and 2 1 3 2 4

15
AntiSymmetric The relation R on X is antisymmetric if for all x,y X, if (x,y) R and (y, x) R then x =y Example: The relation R on X = {1,2,3,4} defined by (x,y) R if x y, x,y X is antisymmetric because for all X,Y, IF (x,y) R and (y, x) R x = y We also can say if (x, y) R and (y, x) R then x = y.

16
Antisymmetric If a relation R has no members of the form (x, y), x y The relation is called Anti Symmetric for all x, y X, if x y then (x, y) R or (y, x) R Example R ={(a, a),(b, b),(c, c) on X = {a, b, c} is an antisymmetric a d c Also we can say, the digraph of antisymmetic relation has at most one directed edge between any two distinct vertices This graph is also symmetric and Reflexive

17
Metrics of Relations A matrix is a convent way to represent a relation. R from X to Y, such a representation can be used by computers to a analyze a relation. Row elements of X are labeled in some order and the column elements of Y are labeled. Entries in Row X and Column Y are set to 1 if there is R from X to Y otherwise it is set to 0 This type of matrix is called Matrix of relations from X to Y

18
Example. The matrix of the Relation R when R ={(1, b),(1, d), (2, c), (3, c),(3, b),(4, a)} From X={1, 2,3,4} to Y ={a, b, c, d} IS: abcd 10101 20010 30110 41000 The matrix is dependent on the ordering of x, y. How would the Matrix for the Relation R look like if: X= {4, 3,2, 1} and Y = {d, c, b, a} … next slide

19
R ={(1, b),(1, d), (2, c), (3, c),(3, b),(4, a)} From X={4,3,2,1} to Y ={d, c, b, a} IS: dcba 40001 30110 20100 11010

20
Example 2 The matrix of the Relation R from X ={2,3,4} to Y={5,6,7,8}is defined by X R Y if x divides y Note: no remainder 5678 20101 30100 40001

21
Reflective Relations The matrix of the Relation R = {(a,a), (b, b), (c, c), (d, d),(b, c), (c, b) } on {a, b, c, d} relative to the ordering {a, b, c, d} abcd a1000 b0110 c0110 d1011 Matrix diagonal The Relation R is Reflective if and ONLY if A has only ones on the main diagonal. The main diagonal is the line from the upper left corner to the lower right corner. In other words the Relation R is Reflective if and only if (x, x) R for every x R.

22
Symmetric Relation If the Entry of R,C = the entry of C,R then the relation is symmetric, otherwise it is anti-symmetric. We can quickly determine if the relation is symmetric by checking the main diagonal Look at all entries for all R,C or (i, j) Look at all entries for all C,R or (j,i) If they are all 1 s then it is Symmetric Based on the above: for the previous example the Relation R is Symmetric

23
How Matrix Multiplication Relate to the composition of Relations and how can we test for Transitivity by using Matrix Relations?

24
What is Transitivity Transitivity: Transitive means whenever a none Zero entry in A ( entry (i, j) 0) there is also a none Zero in A 2 ( entry (i, j) 0)

25
Example Let R be the Relation from X to Y X ={1, 2,3} to Y ={a, b} defined by R1 ={(1,a),(2,b), (3,a), (3,b) and R2= the Relation from Y to Z where Z ={x, y, z} And the Relation is defined R2 ={(a,x), (a,y), (b,y), (b,z)} The matrix for R1 Relative to the ordering of 1,2,3 and a,b ab 1 1 0 201 311 x y z a 1 10 b1 1 1 The Matrix of R2 relative to the ordering of (a,b) on (x, y, z) A1 = A2 = 110 A1.A2 = 01 1 121

26
Transitivity IF A is the matrix of R (relative to some ordering) We compute A 2 Then we compare A and A 2 The relation R is Transitive if and only if whenever an entry i,j in A is a non zero, an entry i,j in A^2 is also a none zero.

27
Determine if the Relation R is transitive The matrix of Relation: R = {(a,a),(b,b),(c,c),(d,d), (b,c),(c.b)} On. (a,b,c,d) relative to the order a, b, c, d a b c d abcd 0 0 0 1 1000 0 1 1 0 0220 0 0 0 1 0001 abcdabcd abcdabcd A=A^2 = Every none Zero i,j in A is matched with a none zero entry in i,j in A^2 Transitive Relation R

28
R2 O R1 To obtain the Matrix of the Relation R2 O R1 Compute the Matrix product A1*A2 Change all none zero entries to 1

29
Adjacency Matrix Will be covered in chapter 11

Similar presentations

OK

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.

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.

© 2017 SlidePlayer.com Inc.

All rights reserved.

Ads by Google

Ppt online examination project in php Ppt on programmable logic device Ppt on bank lending statistics Ppt on regular expression Ppt on games and sports Ppt on object-oriented concepts tutorial Ppt on solar thermal electric conversion Ppt on history of olympics for kids Ppt on obesity and nutrition Ppt on depth first search graph