Presentation is loading. Please wait.

Presentation is loading. Please wait.

Relations and Graphs Relations and Graphs Sanjay Jain, Lecturer, School of Computing.

Similar presentations


Presentation on theme: "Relations and Graphs Relations and Graphs Sanjay Jain, Lecturer, School of Computing."— Presentation transcript:

1 Relations and Graphs Relations and Graphs Sanjay Jain, Lecturer, School of Computing

2 Relations as Directed Graphs Symmetric Relations as Undirected Graphs Directed Walks Paths and Circuits Partial Order and DAGs Connected Component and Equivalence Relation Main Menu Main Menu (Click on the topics below) Sanjay Jain, Lecturer, School of Computing

3 Relations and Directed Graphs Suppose R is a relation on a set A. We can associate with R a directed graph G as follows: V(G)=A D(G)={(a,b) | aRb}

4 Relations and Directed Graphs A={a,b,c} R={(a,b), (b,c)}... a c b

5 Relations and Directed Graphs Suppose G is a directed graph such that for any pair of vertices, u and v, there is at most one edge with endpoints (u,v). (In other words there are no parallel directed edges) Then we can associate a relation with G as follows: A=V(G) R on A is defined as follows: uRv iff (u,v) is an edge. Note that, for graphs without parallel edges, we identify edges with their endpoints.

6 Relations and Directed Graphs A={a,b,c,d} R={(a,b), (b,c), (a,c), (c,d)}... a c b. d

7 END OF SEGMENT

8 Symmetric Relations and Undirected Graphs Suppose R is symmetric relation on set A. Then we can associate an undirected graph with R as follows: V(G)=A {u,v} is an edge in E(G) iff uRv. Note that above is valid definition since {v,u}  E(G)  {u,v}  E(G)  uRv  vRu

9 Theorem Suppose G is an undirected graph. Define R (on V(G)) as follows for u,v  V(G), uRv iff {u,v}  E(G). Then R is a symmetric relation on V(G). Proof: We need to show uRv  vRu Suppose uRv. Then {u,v}  E(G). Thus, {v,u}  E(G). Hence vRu is true.

10 Relations Directed graphs Symmetric relations undirected graphs (No parallel edges. Loops are allowed. Name of edges are not important)

11 END OF SEGMENT

12 Directed Walks/Paths/Circuits Suppose G is a directed graph. Suppose u, v  V(G). A directed walk (in G) from u to v is a sequence of vertices and edges v 0 e 1 v 1 e 2 v 2 e 3……….. e k v k, where v i and e i are vertices and edges in the graph G, u=v 0, v=v k and for any e i, endpoints(e i )=(v i-1, v i ). Note that the order is important. Trivial walk from u to u consists of just u Length of a walk: number of edges in the walk, where we count different appearance of an edge in the walk separately.

13 Directed Walks/Paths/Circuits A directed path in G is a directed walk that does not have repeated edges. A closed walk in G is a directed walk that starts and ends in the same vertex. A closed walk is a circuit iff it does not have repeated edges. A closed walk is a simple circuit iff it does not have repeated vertices except for the first and last vertices being the same.

14 END OF SEGMENT

15 Directed Acyclic Graphs A directed graph G is called a directed acyclic graph (dag) iff it has no non-trivial circuits.

16 END OF SEGMENT

17 Partial Order and DAGs Suppose R is a partial order and G is its associated directed graph. Then G does not have any simple circuit which has at least 2 distinct vertices. Proof: Suppose otherwise. That is G has a simple circuit containing at least two distinct vertices. Let it be v 0 e 1 v 1 e 2 …e k v k (where v k =v 0 and e i is an edge from v i-1 to v i ) But then v 0 Rv 1, v 1 Rv 2, …, v k-1 Rv k =v 0 This is a contradiction to R being a partial order.

18 END OF SEGMENT

19 Partial Order and DAGs Suppose G is a dag. Let R be a relation on V(G) defined as follows: for u,v  V(G), uRv iff there is a directed walk from u to v. Then R is a partial order.

20 Proof Reflexive: uRu for all u (since “u” is a directed walk from u to u). Antisymmetric: Suppose uRv and vRu. Then there is a walk of the form u….v...u. This is a closed walk. Since G is a dag, we must have u=v. Transitive: Suppose uRv and vRw. Then there is a walk of the form u….v…..w. Thus, uRw

21 END OF SEGMENT

22 Theorem: Suppose G is an undirected graph. Define R on V(G) as follows: for u,v  V(G), uRv iff u and v are connected in G. Then R is an equivalence relation. The connected components of G are precisely the equivalence classes of R. Connected Component and Equivalence Relation

23 Reflexive: For each u in V(G) clearly, u is connected to u. Thus uRu. Symmetric: Suppose u,v are in V(G). Suppose uRv. Thus u is connected to v. Since G is undirected graph, this means that v is connected to u. Thus vRu. Transitive: Suppose uRv and vRw. Thus there is a walk from u to v and from v to w. Hence there is a walk from u to w (by going from u to v, and then to w) Hence uRw. Proof:

24 END OF SEGMENT

25 Theorem: Suppose R is an equivalence relation. Represent R using undirected graph G. Then the connected components of G are precisely the equivalence classes of R. Furthermore, every connected component of G is a complete graph + loops on each of vertices. Connected Component and Equivalence Relation

26 Informal Proof: If a and b are in the same equivalence class, then aRb. Thus there is an edge from a to b in G. Thus a and b are in the same connected component. If a and b are in the same connected component, then there exist v 0,v 1,v 2,….,v k such that a v 0 v 1 v 2 ….v k b is a walk in G (where we ignore the edges, since G does not have parallel edges). Thus, a Rv 0, v 0 Rv 1, v 1 Rv 2, ….v k Rb Thus, by transitivity, aRb. Which means that a and b are in the same equivalence class. Connected Component and Equivalence Relation

27 END OF SEGMENT


Download ppt "Relations and Graphs Relations and Graphs Sanjay Jain, Lecturer, School of Computing."

Similar presentations


Ads by Google