Download presentation

Presentation is loading. Please wait.

Published byCamron Murphy Modified over 2 years ago

1
Chapter 3 Relations

2
Section 3.1 Relations and Digraphs

3
Relations A relation from set A to set B is a set of ordered pairs (a,b) with a ε A and b ε B. A is called the domain of the relation and B is the range. Ex: A= {1,2,3} B={1,5,6} - The less than relation from A to B …… - The less than or equal relation ……. - The greater than relation ……. Note: We say “ a relation R on set C ” if C is both the range and the domain of the relation.

4
Relations Ex: The “imply” relation on the set { p, q, p^q, pVq} Ex: S= { {a}, { }, {a,b,c}, {b,c}} Find the strict subset relation on S. Exercise: S= {1,2,4,8} (x,y) ε R if y is divisible by x. Find R.

5
Cartesian Product The Cartesian product of 2 sets A,B is the set of all ordered pairs (a,b) with a ε A and b ε B Ex: A= {1,2} B= { a,b,c} AxB= { (1,a), (1,b), (1,c), (2,a), (2,b), (2,c) } Any relation from A to B is a subset of AxB

6
Directed Graphs (digraphs) A digraph consists of a set of nodes (representing the domain and range) and a set of edges (representing the ordered pairs). Ex: The directed graph for R= { (1,1), (1,2), (3,3)} Ex: A digraph representing the less than relation on N={1,2,3,4}

7
Adjacency Lists We can also represent digraphs by adjacency lists. Ex: Digraph and adjacency list of the relation R= { (1,H), (2,A), (3,A), (4,B)}

8
Reachability We say that node x is adjacent from y if there is an edge from y to x. We say node x is adjacent to y if there is an edge from x to y. Given a directed graph, we define a path from node x to node y as a sequence of edges (x,e1),(e1,e2),(e2,e3),…..,(en,y).

9
Reachability Ex: a path from 1 to 8 could be: (1,2),(2,3),(3,8) Or (1,8) 1 238

10
Reachability A node x is said to be reachable from node y if there is a path from y to x. F is reachable from A A F

11
Reachability Ex: F is reachable from A F is reachable from B D is reachable from E F G CD A BE

12
Reach Algorithm Given a graph, and a certain node x in this graph, the following algorithm finds the set of all reachable nodes from x. Input: A directed graph G and a node x ε G Output: A list of nodes reachable from x Steps: - Put each vertex adjacent from x on the list. - Starting with the first vertex on the list, process each vertex z on the list as follows: - for reach vertex y adjacent from z, if y is not already on the list, put it on the list.

13
Reach Algorithm Ex: Input: D B A DF C

14
Transitivity We say a relation T on set x is transitive if whenever (a,b) and (b,c) are in T, then (a,c) is in T as well. Ex: The less than relation on S= {1,2,3}, is it transitive?

15
Transitivity Ex: Are the following relations transitive? a bc bc a

16
Transitivity Ex: ab c a b c

17
Theorem If R is a relation and T(R) stands for its reachability relation, T(R) is transitive. Note: We also call the reachability relation T(R) of a relation R the transitive closure of R.

18
Section 3.2 Symmetric Relations: A relation R is symmetric if whenever (x,y) is in the relation then (y,x) is in the relation too. Ex: Is the less than relation symmetric? Is the equal relation symmetric?

19
Symmetric Relations Ex: Symmetric? ab

20
Symmetric Relations Ex: Symmetric? ab

21
Symmetric Relations If a directed graph represents a symmetric relation, it can be drawn without arrows. a b

22
Connectivity Given a graph, we say that x is connected to y if y is reachable from x. A set S of nodes is called connected if every 2 nodes in S are connected. Ex: some connected sets: {A,B} {A,B,C} {D,E} {B,C} A B C D E

23
Connectivity A connected set is called a connectivity class if there is no other connected set that contains it. Ex: {A,B} is not a connectivity class {A,B,C} is a connectivity class {D,E} is a connectivity class

24
Connectivity A graph consisting of a connectivity class and all edges of G connecting 2 vertices in the class is called a connected component of G.

25
Connectivity {G,M} is not a connectivity class but {G,M,L,A} with the edge set {{G,M},{G,L},{L,M},{A,L}} is a connected component. G L M A

26
Connectivity A graph is called connected if it contains only one connected component. Ex: 2 connected components but not a connected graph. AB C GH

27
Connectivity Note: Connectivity class is a set. Connected component is a graph.

28
Equivalence Relations A relation R on set S is called reflexive if each element in S is related to itself. ( (x,x) ε R for every x ε S). Ex: Consider the following relations on S={1,2,3} R= { (1,1),(1,2),(2,3),(2,2),(3,3)} is reflexive R= { (1,1),(2,2),(2,3)} is not reflexive

29
Equivalence Relations Ex: - The less than relation is not reflexive - The equal relation is reflexive

30
Equivalence Relations A relation that is reflexive, symmetric and transitive is called equivalence relation. Ex: Let S= { 50, 55, 60, 100, 30, 25, 35} Define R as follows: (x,y) ε R if | x-y | <=5 Is it an equivalence relation?

31
Equivalence Relations Ex: Show that the relationship of equivalence among statements is an equivalence relation.

32
Equivalence in graphs A graph is a graph of an equivalence relation if and only if each vertex is connected to itself by an edge and each 2 vertices lying in the same connected component are connected by and edge. Ex: Given in class

33
Section 3.3 Congruence Modulo m For any integer m>0, we say x is equivalent to y mod m (x Ξ y mod m) if y-x is an integer multiple of m. (m is called modulus)

34
Congruence Modulo m Ex: 7 Ξ 19 mod 12 7 Ξ 31 mod 12 7 Ξ 43 mod 12

35
Congruence Modulo m We define a congruence relation, given an integer m>0, (x,y) is in the relation if x Ξ y mod m. Ex: M=12 (7,19) ε R (8,20) ε R (9,21) ε R

36
Congruence Modulo m Ex: Is 87 congruent to 3 mod 12? Solution: 87-3 = 84 = 7 x 12 So 87 Ξ 3 mod 12 Ex: Is 26 congruent to -13 mod 7? 26 – (-13) = 39 is not multiple of 7

37
Theorem The relation of congruence modulo m is an equivalence relation. Proof: 1- Reflexive since x-x=0, or x-x=m.0 2- If x-y= nm, then y-x= -nm 3- If x-y=nm and y-z=km Then x-z = x-y+y-z = nm+km = (n+k)m Therefore it is transitive

38
Theorem Suppose that x Ξ y mod m and n is an integer, then x+n Ξ y+n mod m and x.n Ξ y.n mod m Proof: If x Ξ y mod m, then x-y = km for integer k (x+n) – (y+n) = x-y = km

39
Congruence Modulo m Ex: solve 2x + 4 Ξ x-1 mod 7 Answer: x Ξ -5 mod 7 x ε { …..,-12,-5,2,9,16, …..} Principal solution: x Ξ 2 mod 7

40
Congruence Modulo m The principal solution is the solution that lies between 0 and m-1. 0 <= principal solution <=m-1

41
Theorem If ax Ξ ay mod m, and a and m have no common factors, then x Ξ y mod m.

42
Congruence Modulo m Ex: solve 2x + 4 Ξ 14 mod 3 Answer: Principal solution: x Ξ 2 mod 3 X ε { ….., -4, -1, 2, 5, 8, …… }

43
Congruence Modulo m Ex: Solve 2x Ξ 1 mod 7 Solution: X Ξ 4 mod 7 x ε { …..,-10,-3,4,11,18, …..}

44
Congruence Modulo m Ex: solve 4x Ξ 2 mod 7 Solution: x Ξ 4 mod 7

45
Section 3.4 Partial Orderings

46
Partial Ordering Irreflexive: A relation R on set S is called irreflexive if (x,x) is not in R for any x in S. Ex: The less than relation is irreflexive. Note: Irreflexive ≠ Not reflexive

47
Partial Ordering A relation is called partial ordering relation if it is transitive and irreflexive. Ex: Show that the less than relation is partial ordering. Ex: Show that the strict subset relation is partial ordering. Note: The partial ordering relation is antisymmetric, why?

48
Total Ordering (Linear Ordering) A relation R is called total ordering if: - R is transitive - R is irreflexive - For each distinct x,y, either (x,y) ε R or (y,x) ε R. - Antisymmetric (if (x,y) is in R, (y,x) is not in R).

49
Total Ordering Ex: Show than the less than relation on {1,2,3} is total ordering. Ex: Show that the strict subset relation on the subsets of {a,b} is not total ordering. - Show graphs of R for both examples and note the linear form of the less than relation graph.

Similar presentations

OK

Problem Statement How do we represent relationship between two related elements ?

Problem Statement How do we represent relationship between two related elements ?

© 2017 SlidePlayer.com Inc.

All rights reserved.

Ads by Google