Presentation is loading. Please wait.

Presentation is loading. Please wait.

Relations and Digraphs

Similar presentations


Presentation on theme: "Relations and Digraphs"— Presentation transcript:

1 Relations and Digraphs

2 Contents 1.Relations and Directed Graphs
2.Special Properties of Binary Relations 3.Equivalence Relations 4.Ordering Relations,Lattices,Enumeration 5.Operations on relations

3 Introduction Applications of relations are found throughout computer science and engineering, including relations between the inputs and outputs of computer programs, relations between data attributes in databases, and relations between symbols in computer languages.

4 Representing Relations using Digraphs
Def 1. A directed graph (digraph) consists of a set V of vertices (or nodes) together with a set E of ordered pairs of elements of V called edges (or arcs). Example. Show the digraph of the relation R={(1,1),(1,3),(2,1),(2,3),(2,4), (3,1),(3,2),(4,1)} on the set {1,2,3,4}. Sol : 1 2 4 3 vertex : 1, 2, 3, 4 edge : (1,1), (1,3), (2,1), (2,3), (2,4), (3,1), (3,2), (4,1)

5 or or or ※ The relation R is reflexive iff for every vertex,
(loop) x y ※ The relation R is symmetric iff for any vertices x≠y, either or x y ※ The relation R is antisymmetric iff for any x≠y, or or x y x y x y

6 ※ The relation R is transitive iff for a, b, c A, (a, b)R and (b, c)R  (a, c)R.
This means: a b d c a b d c

7 Example. Determine whether the relations R and S are reflexive, symmetric, antisymmetric, and/or transitive a b c d S Sol : a b c R : reflexive, not symmetric, not antisymmetric, not transitive (a→b, b→c, a→c) not reflexive, symmetric not antisymmetric not transitive (b→a, a→c, b→c) irreflexive (a,a)R, aA

8 Equivalence Relations
Def 1. A relation R on a set A is called an equivalence relation if it is reflexive, symmetric, and transitive. Example 1. Let R be the relation on the set of integers such that aRb if and only if a=b or a=-b. Then R is an equivalence relation. Example 2. Let R be the relation on the set of real numbers such that aRb if and only if a-b is an integer. Then R is an equivalence relation.

9 Example. (Congruence Modulo m)
Let m  Z and m > 1. Show that the relation R={ (a,b) | a≡b (mod m) } is an equivalence relation on the set of integers. ( a is congruent to b modulo m) Sol : Note that a≡b(mod m) iff m | (a-b). ∵ a≡a (mod m)  (a, a)R  reflexive  If a≡b(mod m), then a-b=km, kZ  b-a= (-k)m  b≡a (mod m)  symmetric  If a≡b(mod m), b≡c(mod m) then a-b=km, b-c=lm  a-c=(k+l)m  a≡c(mod m)  transitive ∴ R is an equivalence relation.

10 Let l(x) denote the length of the string x. Suppose that the relation
Example. Let l(x) denote the length of the string x. Suppose that the relation R={(a,b) | l(a)=l(b), a,b are strings of English letters } Is R an equivalence relation? Sol :  (a,a)R string a  reflexive  (a,b)R  (b,a)R  symmetric Yes.  (a,b)R,(b,c)R  (a,c)R  transitive Ch8-10 10

11  xRx x since x- x =0  reflexive
Example. Let R be the relation on the set of real numbers such that xRy if and only if x and y differ by less than 1, that is |x- y| < 1. Show that R is not an equivalence relation. Sol :  xRx x since x- x =  reflexive  xRy  |x- y| < 1  |y- x| < 1  yRx  symmetric  xRy, yRz  |x- y| < 1, |y- z| < 1  |x- z| <  Not transitive Ch8-11 11

12 Representing Relations using Digraphs
Def 1. A directed graph (digraph) consists of a set V of vertices (or nodes) together with a set E of ordered pairs of elements of V called edges (or arcs).

13 A pair of sets G = (V, E) is a directed graph (digraph) if
A pair of sets G = (V, E) is a directed graph (digraph) if The elements of V are called vertices and the elements of E are called edges. An edge (x,y) is said to be from x to y, and is represented in a diagram by an arrow with the tail at x and the head at y. Such an edge is said to be incident from x, incident to y, and incident on both x and y. If there is an edge in E from x to y we say x is adjacent to y. The number of edges incident from a vertex is called the out-degree of the vertex and the number of edges incident to a vertex is called the in-degree. An edge from a vertex to itself is called a loop, and will ordinarily be permitted. A digraph with no loops is called loop-free or simple.

14 Identify Vertices, Edges of the below digraph
Sarai, Abram, Isaac Edges (Sarai, Isaac), (Abram,Isaac) Identify in degree and out degree of each of those vertices Sarai In-0, out-1 Abram In-0, Out-1 Isaac In-2, Out-0

15 Out-degree – the number of edges incident from a vertex In-degree – the number of edges incident to a vertex Loop-free (or) simple digraph – a digraph with no loops

16 Find the in-degree and out-degree of

17

18 Paths in Directed Graphs
Def 1. A path from a to b in the digraph G is a sequence of edges (x0, x1), (x1, x2), …, (xn-1, xn) in G, where nZ+, and x0= a, xn= b. This path is denoted by x0, x1, x2, …, xn and has length n. Ex. 1 3 5 2 4 A path from 1 to 5 of length 4 Theorem 1 Let R be a relation on a set A. There is a path of length n, where nZ+, from a to b if and only if (a, b)  Rn. Ch8-18 18

19 Proper Subgraph

20 Subgraphs Definition: if G is a graph, a subgraph H of G consists of a subset V of the vertices of G, and a subset of the edges of G with endpoints in V. c d e f n a b c d e f g h i j k l m o A graph G i l j k h g m Two subgraphs of G 1/25/2005 Tucker, Sec. 1.2

21 Induced subgraphs Choose a subset of the vertices of G, then include only the edges among those vertices. a b g f c e d e h j k d e h j k d h j k i l m o n Subgraph induced by the vertices of degree 4. A graph G 1/25/2005 Tucker, Sec. 1.2

22

23 Representing Graphs a b c d a b c d a, d b c a, b, c d b, c, d a
Adjacent Vertices Vertex a b c a, b, c d Terminal Vertices Initial Vertex

24 Definition of Isomorphism
Two graphs G and are isomorphic if : There exists a one-to-one correspondence between vertices in G and , such that There is an edge between a and b in G if and only if there is an edge between the corresponding vertices and in The definition for oriented graphs is the same, except the head and tail of each edge of G must correspond to the head and tail in . 1/25/2005 Tucker, Sec. 1.2

25 Example of isomorphic graphs
b 1 2 3 f 4 e 6 5 d c G An isomorphism between G and : a d b 1 e 2 c 3 f 4 Graph isomorphism is both very important and very intractable— Important: matching to known structures (eg chemical molecules, circuits, organizational solutions, visualizations) Intractable—no known good algorithms for determining if two graphs are isomorphic—brute force methods (eg start with one vertex, try all the ones it could match too, then try the next, etc) grow exponentially with the number of vertices. 1/25/2005 Tucker, Sec. 1.2

26 Isomorphic Graphs The two graphs below look different.
Are from a graph theoretic point of view structurally the ‘same’? 2 b 1 3 a The renaming function f is an isomorphism. f.a = 1, f.b=3... Cycles and degree are preserved. c d 5 4 e

27 Graph Morphisms The two graphs below look different but are structurally the ‘same’. f.c 2(c) b f.a 1(a) 3(e) a c f.d The renaming function f is an isomorphism. f.a = 1, f.b=3... Cycles and degree are preserved. d 5(d) 4(b) e f.b f.e They are the ‘same’ up to the renaming of the vertices. These graphs are isomorphic.

28 Elementary properties of isomorphic graphs
Edge and vertex counts Isomorphic graphs have the same number of edges and vertices. Vertex sequence (the list of vertex degrees) Isomorphic graphs have the same vertex sequences. Warning!! These can be used to show two graphs are not isomorphic, but can not show that two graphs are isomorphic. 1/25/2005 Tucker, Sec. 1.2

29 Two non-isomorphic graphs
Vertices: 6 Edges: 7 Vertex sequence: 4, 3, 3, 2, 2, 0. Vertices: 6 Edges: 7 Vertex sequence: 5, 3, 2, 2, 1, 1. 1/25/2005 Tucker, Sec. 1.2

30 Subgraph properties of isomorphic graphs
Isomorphic graphs have the same sets of subgraphs: there is a one-to-one correspondence between the subgraphs such that corresponding subgraphs are isomorphic. Typically check induced subgraphs, or number of a specific kind of subgraphs such as cycles or cliques. Warning!! These can be used to show two graphs are not isomorphic, but can not show that two graphs are isomorphic. Both edge reconstruction and vertex reconstruction are still open problems, The set of subgraphs you get by deleting each of the vertices (edges) singly is called the vertex (edge) deck of the graph. Can you prove that if two graphs have the same vertex/edge deck they must be isomorphic, or can you find a counter example? 1/25/2005 Tucker, Sec. 1.2

31 Two non-isomorphic graphs
1 4 a d 5 b e f g h 8 7 2 6 3 c 3 Vertices: 8 Edges: 10 Vertex sequence: 3, 3, 3, 3, 2, 2, 2, 2. Vertices: 8 Edges: 10 Vertex sequence: 3, 3, 3, 3, 2, 2, 2, 2. However, induced subgraphs on degree 3 vertices are NOT isomorphic! 1/25/2005 Tucker, Sec. 1.2

32 An approach to checking isomorphism:
Count the vertices. The graphs must have an equal number. Count the edges. The graphs must have an equal number. Check vertex degree sequence. Each graph must have the same degree sequence. Check induced subgraphs for isomorphism. If the subgraphs are not isomorphic, then the larger graphs are not either. Count numbers of cycles/cliques. If these tests don’t help, and you suspect the graphs actually are isomorphic, then try to find a one-to-one correspondence between vertices of one graph and vertices of the other. Remember that a vertex of degree n in the one graph must correspond to a vertex of degree n in the other. 1/25/2005 Tucker, Sec. 1.2

33 For the class to try: Are these pairs of graphs isomorphic?
3 Isomorphic: a-1, b-5, c-4, d-3, e-2, f-6. a e 5 1 #1 c d b f 2 6 4 d Not Isomorphic: 5 K3’s on left, 4 K3’s on right. 1 2 a b c 5 6 #2 7 3 e g 4 f 1/25/2005 Tucker, Sec. 1.2

34

35 Problems

36 Solution for 1(a)

37 Solution for 1(b)

38 Solution for 1(c)

39

40 Example for Transitive relation

41 Example for not a Transitive relation

42 Example for Reflexive relation

43 Example for Irreflexive relation

44 Example for Symmetric relation

45 Example for Antisymmetric relation

46 Equivalence relation –
A binary relation that is transitive, reflexive and symmetric is called an equivalence relation Partial ordering relation – A binary relation that is transitive, reflexive and antisymmetric is called a partial ordering relation

47 Problem

48 Solution


Download ppt "Relations and Digraphs"

Similar presentations


Ads by Google