Presentation is loading. Please wait.

Presentation is loading. Please wait.

Lecture 5.3: Graph Isomorphism and Connectivity CS 250, Discrete Structures, Fall 2011 Nitesh Saxena *Adopted from previous lectures by Zeph Grunschlag.

Similar presentations


Presentation on theme: "Lecture 5.3: Graph Isomorphism and Connectivity CS 250, Discrete Structures, Fall 2011 Nitesh Saxena *Adopted from previous lectures by Zeph Grunschlag."— Presentation transcript:

1 Lecture 5.3: Graph Isomorphism and Connectivity CS 250, Discrete Structures, Fall 2011 Nitesh Saxena *Adopted from previous lectures by Zeph Grunschlag

2 HW1 Submitted yesterday Grading now – expect results in about a week Solution to be posted soon Lecture 5.3 -- Graph Isomorphism and Connectivity

3 Course Admin -- Final Exam Thursday, December 8, 10:45am- 1:15pm, lecture room Heads up! Please mark the date/time/place Emphasis on post mid-term 2 material Coverage: 65% post mid-term 2 (lectures 4.*, 5.*, 6.*), and 35% pre mid-term 2 (lecture 1.*. 2.* and 3.*) Our last lecture will be on December 6 We plan to do a final exam review then Lecture 5.3 -- Graph Isomorphism and Connectivity

4 Course Admin -- Homework 5 Heads up: will be posted by the coming weekend Due in 10 days after the day of posting Covers the chapter on Graphs (lecture 5.*) Lecture 5.3 -- Graph Isomorphism and Connectivity

5 Outline Graph Isomorphism Paths and Connectivity

6 Warm-up Exercise Theorem: No. of edges in an n-cube is n2 n-1 Proof: Use mathematical induction. Let’s use the whiteboard. Lecture 5.3 -- Graph Isomorphism and Connectivity

7 Graph Isomorphism Various mathematical notions come with their own concept of equivalence, as opposed to equality: Equivalence for sets is bijectivity: EG {23, 12, 43}  {12, 23, 43} Equivalence for graphs is isomorphism: EG  Lecture 5.3 -- Graph Isomorphism and Connectivity

8 Graph Isomorphism Intuitively, two graphs are isomorphic if can bend, stretch and reposition vertices of the first graph, until the second graph is formed. Etymologically, isomorphic means “same shape”. EG: Can twist or relabel: to obtain: Lecture 5.3 -- Graph Isomorphism and Connectivity

9 Graph Isomorphism Undirected Graphs DEF: Suppose G 1 = (V 1, E 1 ) and G 2 = (V 2, E 2 ) are pseudographs. Let f :V 1  V 2 be a function s.t.: 1) f is bijective 2) for all vertices u,v in V 1, the number of edges between u and v in G 1 is the same as the number of edges between f (u) and f (v ) in G 2. Then f is called an isomorphism and G 1 is said to be isomorphic to G 2. Lecture 5.3 -- Graph Isomorphism and Connectivity

10 Graph Isomorphism Digraphs DEF: Suppose G 1 = (V 1, E 1 ) and G 2 = (V 2, E 2 ) are directed multigraphs. Let f :V 1  V 2 be a function s.t.: 1) f is bijective 2) for all vertices u,v in V 1, the number of edges from u to v in G 1 is the same as the number of edges between f (u) and f (v ) in G 2. Then f is called an isomorphism and G 1 is said to be isomorphic to G 2. Note: Only difference between two definitions is the italicized “from” in no. 2 (was “between”).

11 Graph Isomorphism -Example EG: Prove that is isomorphic to First label the vertices : 1 2 3 54 1 2 3 54 Lecture 5.3 -- Graph Isomorphism and Connectivity

12 Graph Isomorphism -Example Next, set f (1) = 1 and try to walk around clockwise on the star. 1 2 3 54 1 2 3 54 Lecture 5.3 -- Graph Isomorphism and Connectivity

13 Graph Isomorphism -Example Next, set f (1) = 1 and try to walk around clockwise on the star. The next vertex seen is 3, not 2 so set f (2) = 3. 2 3 54 2 3 54 1 1 Lecture 5.3 -- Graph Isomorphism and Connectivity

14 Graph Isomorphism -Example Next, set f (1) = 1 and try to walk around clockwise on the star. The next vertex seen is 3, not 2 so set f (2) = 3. Next vertex is 5 so set f (3) = 5. 3 54 2 5 4 2 3 1 1 Lecture 5.3 -- Graph Isomorphism and Connectivity

15 Graph Isomorphism -Example Next, set f (1) = 1 and try to walk around clockwise on the star. The next vertex seen is 3, not 2 so set f (2) = 3. Next vertex is 5 so set f (3) = 5. In this fashion we get f (4) = 2 5 4 2 4 3 5 2 3 1 1 Lecture 5.3 -- Graph Isomorphism and Connectivity

16 Graph Isomorphism -Example Next, set f (1) = 1 and try to walk around clockwise on the star. The next vertex seen is 3, not 2 so set f (2) = 3. Next vertex is 5 so set f (3) = 5. In this fashion we get f (4) = 2, f (5) = 4. 4 2 3 5 2 3 1 1 5 4 Lecture 5.3 -- Graph Isomorphism and Connectivity

17 Graph Isomorphism -Example Next, set f (1) = 1 and try to walk around clockwise on the star. The next vertex seen is 3, not 2 so set f (2) = 3. Next vertex is 5 so set f (3) = 5. In this fashion we get f (4) = 2, f (5) = 4. If we would continue, we would get back to f (1) =1 so this process is well defined and f is a isomorphism. 1 2 3 54 1 2 3 54 Lecture 5.3 -- Graph Isomorphism and Connectivity

18 Graph Isomorphism -Example Next, set f (1) = 1 and try to walk around clockwise on the star. The next vertex seen is 3, not 2 so set f (2) = 3. Next vertex is 5 so set f (3) = 5. In this fashion we get f (4) = 2, f (5) = 4. If we would continue, we would get back to f (1) =1 so this process is well defined and f is a morphism. Finally since f is bijective, f is an isomorphism. 1 2 3 54 1 2 3 54

19 Properties of Isomorphims Since graphs are completely defined by their vertex sets and the number of edges between each pair, isomorphic graphs must have the same intrinsic properties. I.e. isomorphic graphs have the same… number of vertices and edges degrees at corresponding vertices types of possible subgraphs Lecture 5.3 -- Graph Isomorphism and Connectivity

20 Exercise Is “isomorphism” on graphs an equivalence relation? If so, what are the equivalence classes? Let’s use the whiteboard! Lecture 5.3 -- Graph Isomorphism and Connectivity

21 Graph Isomorphism -Negative Examples To show that two graphs are non-isomorphic need to show that no function can exist that satisfies defining properties of isomorphism. In practice, you try to find some intrinsic property that differs between the 2 graphs in question. Lecture 5.3 -- Graph Isomorphism and Connectivity

22 Graph Isomorphism -Negative Examples Q: Why are the following non-isomorphic? u1u1 u2u2 u3u3 u5u5 u4u4 v1v1 v2v2 v3v3 v4v4 Lecture 5.3 -- Graph Isomorphism and Connectivity

23 Graph Isomorphism -Negative Examples A: 1 st graph has more vertices than 2 nd. Q: Why are the following non-isomorphic? u1u1 u2u2 u3u3 u5u5 u4u4 v1v1 v2v2 v3v3 v5v5 v4v4 Lecture 5.3 -- Graph Isomorphism and Connectivity

24 Graph Isomorphism -Negative Examples A: 1 st graph has more edges than 2 nd. Q: Why are the following non-isomorphic? u1u1 u2u2 u3u3 u5u5 u4u4 v1v1 v2v2 v3v3 v5v5 v4v4 Lecture 5.3 -- Graph Isomorphism and Connectivity

25 Graph Isomorphism -Negative Examples A: 2 nd graph has vertex of degree 1, 1 st graph doesn't. Q: Why are the following non-isomorphic? u1u1 u2u2 u3u3 u6u6 u4u4 u5u5 u7u7 u9u9 v1v1 v2v2 v3v3 v6v6 v4v4 v5v5 v7v7 v8v8 v9v9 u8u8 Lecture 5.3 -- Graph Isomorphism and Connectivity

26 Graph Isomorphism -Negative Examples A: 1 st graph has 2 degree 1 vertices, 4 degree 2 vertex and 2 degree 3 vertices. 2 nd graph has 3 degree 1 vertices, 3 degree 2 vertex and 3 degree 3 vertices. Q: Why are the following non-isomorphic? u1u1 u2u2 u3u3 u6u6 u4u4 u5u5 u7u7 u8u8 v1v1 v2v2 v3v3 v6v6 v4v4 v5v5 v7v7 v8v8 Lecture 5.3 -- Graph Isomorphism and Connectivity

27 Graph Isomorphism -Negative Examples A: None of the previous approaches work as there are the same no. of vertices, edges, and same no. of vertices per degree. LEMMA: If G and H are isomorphic, then any subgraph of G will be isomorphic to some subgraph of H. Q: Find a subgraph of 2 nd graph which isn’t a subgraph of 1 st graph. u1u1 u2u2 u3u3 u6u6 u4u4 u5u5 u7u7 u8u8 v1v1 v2v2 v3v3 v6v6 v4v4 v5v5 v7v7 v8v8

28 Graph Isomorphism -Negative Examples A: This subgraph is not a subgraph of the left graph. Why not? Deg. 3 vertices must map to deg. 3 vertices. Since subgraph and left graph are symmetric, can assume v 2 maps to u 2. Adjacent deg. 1 vertices to v 2 must map to degree 1 vertices, forcing the deg. 2 adjacent vertex v 3 to map to u 3. This forces the other vertex adjacent to v 3, namely v 4 to map to u 4. But then a deg. 3 vertex has mapped to a deg. 2 vertex. u1u1 u2u2 u3u3 u6u6 u4u4 u5u5 u7u7 u8u8 v1v1 v2v2 v3v3 v6v6 v4v4 v5v5 v7v7 v8v8

29 Paths A path in a graph is a continuous way of getting from one vertex to another by using a sequence of edges. EG: could get from 1 to 3 circuitously as follows: 1-e 1  2-e 1  1-e 3  3-e 4  2-e 6  2-e 5  2-e 4  3 12 34 e1e1 e3e3 e2e2 e4e4 e5e5 e6e6 e7e7

30 Paths A path in a graph is a continuous way of getting from one vertex to another by using a sequence of edges. EG: could get from 1 to 3 circuitously as follows: 1-e 1  2-e 1  1-e 3  3-e 4  2-e 6  2-e 5  2-e 4  3 12 34 e1e1 e3e3 e2e2 e4e4 e5e5 e6e6 e7e7

31 Paths 1 A path in a graph is a continuous way of getting from one vertex to another by using a sequence of edges. EG: could get from 1 to 3 circuitously as follows: 1- e 1  2-e 1  1-e 3  3-e 4  2-e 6  2-e 5  2-e 4  3 2 34 e1e1 e3e3 e2e2 e4e4 e5e5 e6e6 e7e7

32 Paths A path in a graph is a continuous way of getting from one vertex to another by using a sequence of edges. EG: could get from 1 to 3 circuitously as follows: 1-e 1  2- e 1  1-e 3  3-e 4  2-e 6  2-e 5  2-e 4  3 12 34 e1e1 e3e3 e2e2 e4e4 e5e5 e6e6 e7e7

33 Paths A path in a graph is a continuous way of getting from one vertex to another by using a sequence of edges. EG: could get from 1 to 3 circuitously as follows: 1-e 1  2-e 1  1- e 3  3-e 4  2-e 6  2-e 5  2-e 4  3 12 34 e1e1 e3e3 e2e2 e4e4 e5e5 e6e6 e7e7

34 Paths A path in a graph is a continuous way of getting from one vertex to another by using a sequence of edges. EG: could get from 1 to 3 circuitously as follows: 1-e 1  2-e 1  1-e 3  3- e 4  2-e 6  2-e 5  2-e 4  3 12 34 e1e1 e3e3 e2e2 e4e4 e5e5 e6e6 e7e7

35 Paths A path in a graph is a continuous way of getting from one vertex to another by using a sequence of edges. EG: could get from 1 to 3 circuitously as follows: 1-e 1  2-e 1  1-e 3  3-e 4  2- e 6  2-e 5  2-e 4  3 12 34 e1e1 e3e3 e2e2 e4e4 e5e5 e6e6 e7e7

36 Paths A path in a graph is a continuous way of getting from one vertex to another by using a sequence of edges. EG: could get from 1 to 3 circuitously as follows: 1-e 1  2-e 1  1-e 3  3-e 4  2-e 6  2- e 5  2-e 4  3 12 34 e1e1 e3e3 e2e2 e4e4 e5e5 e6e6 e7e7

37 Paths A path in a graph is a continuous way of getting from one vertex to another by using a sequence of edges. EG: could get from 1 to 3 circuitously as follows: 1-e 1  2-e 1  1-e 3  3-e 4  2-e 6  2-e 5  2- e 4  3 12 34 e1e1 e3e3 e2e2 e4e4 e5e5 e6e6 e7e7

38 Paths DEF: A path of length n in an undirected graph is a sequence of n edges e 1, e 2, …,e n such that each consecutive pair e i, e i+1 share a common vertex. In a simple graph, one may instead define a path of length n as a sequence of n+1 vertices v 0, v 1, v 2, …,v n such that each consecutive pair v i, v i+1 are adjacent. Paths of length 0 are also allowed according to this definition. Q: Why does the second definition work for simple graphs? Lecture 5.3 -- Graph Isomorphism and Connectivity

39 Paths A: For simple graphs, any edge is unique between vertices so listing the vertices gives us the edge-sequence as well. DEF: A simple path contains no duplicate edges (though duplicate vertices are allowed). A cycle (or circuit) is a path which starts and ends at the same vertex. Note: Simple paths need not be in simple graphs. E.g., may contain loops. Lecture 5.3 -- Graph Isomorphism and Connectivity

40 Paths Q: Find a longest possible simple path in the following graph: 12 34 e1e1 e3e3 e2e2 e4e4 e5e5 e6e6 e7e7 Lecture 5.3 -- Graph Isomorphism and Connectivity

41 Paths A: The following path from 1 to 2 is a maximal simple path because simple: each of its edges appears exactly once maximal: because it contains every edge except the unreachable edge e 7 The maximal path: e 1,e 5,e 6,e 2,e 3,e 4 12 34 e1e1 e3e3 e2e2 e4e4 e5e5 e6e6 e7e7 Lecture 5.3 -- Graph Isomorphism and Connectivity

42 Paths in Directed Graphs One can define paths for directed graphs by insisting that the target of each edge in the path is the source of the next edge: DEF: A path of length n in a directed graph is a sequence of n edges e 1, e 2, …,e n such that the target of e i is the source e i+1 for each i. In a digraph, one may instead define a path of length n as a sequence of n+1 vertices v 0, v 1, v 2, …,v n such that for each consecutive pair v i, v i+1 there is an edge from v i to v i+1. Lecture 5.3 -- Graph Isomorphism and Connectivity

43 Paths in Directed Graphs Q: Consider digraph adjacency matrix: 1. Find a path from 1 to 4. 2. Is there a path from 4 to 1? Lecture 5.3 -- Graph Isomorphism and Connectivity

44 Paths in Directed Graphs A: 1. 1  3. 2. There’s no path from 4 to 1. From 4 must go to 2, from 2 must stay at 2 or return to 4. In other words 2 and 4 are disconnected from 1. Lecture 5.3 -- Graph Isomorphism and Connectivity

45 Paths in Directed Graphs A: 1. 1  3  2. 2. There’s no path from 4 to 1. From 4 must go to 2, from 2 must stay at 2 or return to 4. In other words 2 and 4 are disconnected from 1. Lecture 5.3 -- Graph Isomorphism and Connectivity

46 Paths in Directed Graphs A: 1. 1  3  2  4. 2. There’s no path from 4 to 1. From 4 must go to 2, from 2 must stay at 2 or return to 4. In other words 2 and 4 are disconnected from 1. Lecture 5.3 -- Graph Isomorphism and Connectivity

47 Connectivity DEF: Let G be a pseudograph. Let u and v be vertices. u and v are connected to each other if there is a path in G which starts at u and ends at v. G is said to be connected if all vertices are connected to each other. Note: Any vertex is automatically connected to itself via the empty path. Lecture 5.3 -- Graph Isomorphism and Connectivity

48 Q: Which of the following graphs are connected? Connectivity 12 3 4 Lecture 5.3 -- Graph Isomorphism and Connectivity

49 A: First and second are disconnected. Last is connected. Connectivity 12 3 4 Lecture 5.3 -- Graph Isomorphism and Connectivity

50 A: First and second are disconnected. Last is connected. Connectivity 12 3 4 Lecture 5.3 -- Graph Isomorphism and Connectivity

51 A: First and second are disconnected. Last is connected. Connectivity 12 3 4 Lecture 5.3 -- Graph Isomorphism and Connectivity

52 A: First and second are disconnected. Last is connected. Connectivity 12 3 4 Lecture 5.3 -- Graph Isomorphism and Connectivity

53 A: First and second are disconnected. Last is connected. Connectivity 12 3 4 Lecture 5.3 -- Graph Isomorphism and Connectivity

54 A: First and second are disconnected. Last is connected. Connectivity 12 3 4 Lecture 5.3 -- Graph Isomorphism and Connectivity

55 English Connectivity Puzzle Can define a puzzling graph G as follows: V = {3-letter English words} E : two words are connected if we can get one word from the other by changing a single letter. One small subgraph of G is: Q: Is “fun” connected to “car” ? jobrobjab Lecture 5.3 -- Graph Isomorphism and Connectivity

56 English Connectivity Puzzle A: Yes: fun  fan  far  car Or: fun  fin  bin  ban  bar  car Lecture 5.3 -- Graph Isomorphism and Connectivity

57 Connected Components DEF: A connected component (or just component) in a graph G is a set of vertices such that all vertices in the set are connected to each other and every possible connected vertex is included. Q: What are the connected components of the following graph? 62 4 35 1 7 8 Lecture 5.3 -- Graph Isomorphism and Connectivity

58 Connected Components A: The components are {1,3,5},{2,4,6},{7} and {8} as one can see visually by pulling components apart: 62 4 7 8 35 1 Lecture 5.3 -- Graph Isomorphism and Connectivity

59 Connected Components A: The components are {1,3,5},{2,4,6},{7} and {8} as one can see visually by pulling components apart: 62 4 7 8 35 1 Lecture 5.3 -- Graph Isomorphism and Connectivity

60 Connected Components A: The components are {1,3,5}, {2,4,6}, {7} and {8} as one can see visually by pulling components apart: 62 4 7 8 35 1 Lecture 5.3 -- Graph Isomorphism and Connectivity

61 Degree of Connectivity Not all connected graphs are treated equal! Q: Rate following graphs in terms of their design value for computer networks: 1) 2) 3) 4)

62 Degree of Connectivity A: Want all computers to be connected, even if 1 computer goes down: 1) 2 nd best. However, there’s a weak link— “cut vertex” 2) 3 rd best. Connected but any computer can disconnect 3) Worst! Already disconnected 4) Best! Network dies only with 2 bad computers Lecture 5.3 -- Graph Isomorphism and Connectivity

63 Degree of Connectivity The network is best because it can only become disconnected when 2 vertices are removed. In other words, it is 2-connected. Formally: DEF: A connected simple graph with 3 or more vertices is 2-connected if it remains connected when any vertex is removed. When the graph is not 2-connected, we call the disconnecting vertex a cut vertex. Lecture 5.3 -- Graph Isomorphism and Connectivity

64 Degree of Connectivity There is also a notion of N-Connectivity where we require at least N vertices to be removed to disconnect the graph. Lecture 5.3 -- Graph Isomorphism and Connectivity

65 Connectivity in Directed Graphs In directed graphs may be able to find a path from a to b but not from b to a. However, Connectivity was a symmetric concept for undirected graphs. So how to define directed Connectivity is non- obvious: 1) Should we ignore directions? 2) Should we insist that can get from a to b in actual digraph? 3) Should we insist that can get from a to b and that can get from b to a? Lecture 5.3 -- Graph Isomorphism and Connectivity

66 Connectivity in Directed Graphs Resolution: Don’t bother choosing which definition is better. Just define to separate concepts: 1) Weakly connected : can get from a to b in underlying undirected graph 2) Semi-connected (my terminology): can get from a to b OR from b to a in digraph 3) Strongly connected : can get from a to b AND from b to a in the digraph DEF: A graph is strongly (resp. semi, resp. weakly) connected if every pair of vertices is connected in the same sense. Lecture 5.3 -- Graph Isomorphism and Connectivity

67 Connectivity in Directed Graphs Q: Classify the connectivity of each graph. Lecture 5.3 -- Graph Isomorphism and Connectivity

68 Connectivity in Directed Graphs A: semi weakstrong Lecture 5.3 -- Graph Isomorphism and Connectivity

69 Today’s Reading Rosen 10.3 and 10.4


Download ppt "Lecture 5.3: Graph Isomorphism and Connectivity CS 250, Discrete Structures, Fall 2011 Nitesh Saxena *Adopted from previous lectures by Zeph Grunschlag."

Similar presentations


Ads by Google