Presentation is loading. Please wait.

Presentation is loading. Please wait.

CSE 211 Discrete Mathematics Chapter 8.3 Representing Graphs and Graph Isomorphism.

Similar presentations


Presentation on theme: "CSE 211 Discrete Mathematics Chapter 8.3 Representing Graphs and Graph Isomorphism."— Presentation transcript:

1

2 CSE 211 Discrete Mathematics Chapter 8.3 Representing Graphs and Graph Isomorphism

3 §8.3: Graph Representations & Isomorphism Graph representations: –Adjacency lists. –Adjacency matrices. –Incidence matrices. Graph isomorphism: –Two graphs are isomorphic iff they are identical except for their node names.

4 Adjacency Lists A table with 1 row per vertex, listing its adjacent vertices. a b d c f e

5 Directed Adjacency Lists 1 row per node, listing the terminal nodes of each edge incident from that node. nodeTerminal nodes 03 10, 2, ,2

6 A simple graph G = (V,E) with n vertices can be represented by its adjacency matrix, A, where the entry a ij in row i and column j is: Adjacency Matrix

7 Adjacency Matrix Example a b c d e f abcdefabcdef From To W5W5 db a c e f {v1,v2}{v1,v2} rowcolumn

8 Adjacency Matrices Matrix A=[a ij ], where a ij is 1 if {v i, v j } is an edge of G, 0 otherwise. a b c d a b c d abcd

9 Adjacency Matrices Example 5: Use an adjacency matrix to represent the pseudograph shown in Figure 5. FIGURE A Pseudograph. 8

10 Incidence Matrix Let G = (V,E) be an undirected graph. Suppose v 1,v 2,v 3,…,v n are the vertices and e 1,e 2,e 3,…,e m are the edges of G. The incidence matrix w.r.t. this ordering of V and E is the n m matrix M = [m ij ], where

11 Incidence Matrix Example Represent the graph shown with an incidence matrix v1v2v3v4v5v1v2v3v4v5 vertices e 1 e 2 e 3 e 4 e 5 e 6 edges v 1 v 2 v 3 v 4 v 5 e1e1 e2e2 e3e3 e4e4 e5e5 e6e6

12 Incidence matrices Matrix M=[m ij ], where m ij is 1 when edge e j is incident with v i, 0 otherwise v1 v2 v3 v4 e1e2e3e4 v1 v4 v3 v2 e5 e1 e2 e5 e4 e3

13 Incidence Matrices Example 7: Represent the pseudograph shown in Figure 7 using an incidence matrix. FIGURE 7 A Pseudograph. 12

14 Isomorphism Two simple graphs are isomorphic if: –there is a one-to one correspondence between the vertices of the two graphs –the adjacency relationship is preserved

15 Isomorphism (Cont.) The simple graphs G 1 =(V 1,E 1 ) and G 2 =(V 2,E 2 ) are isomorphic if there is a one-to-one and onto function f from V 1 to V 2 with the property that a and b are adjacent in G 1 iff f(a) and f(b) are adjacent in G 2, for all a and b in V 1.

16 One to one and onto function

17

18 Example u1u1 u3u3 u4u4 u2u2 v1v1 v3v3 v4v4 v2v2 G H Are G and H isomorphic? f(u 1 ) = v 1, f(u 2 ) = v 4, f(u 3 ) = v 3, f(u 4 ) = v 2

19 Isomorphism Example If isomorphic, label the 2nd graph to show the isomorphism, else identify difference. a b c d e f b d a e f c

20 Are These Isomorphic? If isomorphic, label the 2nd graph to show the isomorphism, else identify difference. a b c d e * Same # of vertices * Same # of edges * Different # of vertices of degree 2! (1 vs 3) Example 11: a more general solution

21 Invariants Invariants – properties that two simple graphs must have in common to be isomorphic –Same number of vertices –Same number of edges –Degrees of corresponding vertices are the same –If one is bipartite, the other must be; if one is complete, the other must be; and others …

22 Graph isomorphism Example Graph G Graph HAn isomorphism between G and H ƒ(a) = 1 ƒ(b) = 6 ƒ(c) = 8 ƒ(d) = 3 ƒ(g) = 5 ƒ(h) = 2 ƒ(i) = 4 ƒ(j) = 7 The two graphs shown below are isomorphic, despite their different looking drawings.drawings

23 Example a e d c G H b a e d c b Are G and H isomorphic?

24 Example Are these two graphs isomorphic? –They both have 5 vertices –They both have 8 edges –They have the same number of vertices with the same degrees: 2, 3, 3, 4, 4. G H u 1 u 2 u 5 u 3 u 4 v 1 v 2 v 5 v 3 v 4

25 Example (Cont.) u 1 u 2 u 3 u 4 u 5 u u u u u v 1 v 2 v 3 v 4 v 5 v v v v v –G and H dont appear to be isomorphic. –However, we havent tried mapping vertices from G onto H yet. v 1 v 3 v 2 v 5 v 4 v 1 v 3 v 2 v 5 v 4 GH H G?

26 Example (Cont.) Start with the vertices of degree 2 since each graph only has one: deg(u 3 ) = deg(v 2 ) = 2 therefore f(u 3 ) = v 2 G H u 1 u 2 u 5 u 3 u 4 v 1 v 2 v 5 v 3 v 4

27 Example (Cont.) Now consider vertices of degree 3 deg(u 1 ) = deg(u 5 ) = deg(v 1 ) = deg(v 4 ) = 3 therefore we must have either one of f(u 1 ) = v 1 and f(u 5 ) = v 4 f(u 1 ) = v 4 and f(u 5 ) = v 1 G H u 1 u 2 u 5 u 3 u 4 v 1 v 2 v 5 v 3 v 4

28 Example (Cont.) Now try vertices of degree 4: deg(u 2 ) = deg(u 4 ) = deg(v 3 ) = deg(v 5 ) = 4 therefore we must have one of: f(u 2 ) = v 3 and f(u 4 ) = v 5 or f(u 2 ) = v 5 and f(u 4 ) = v 3 G H u 1 u 2 u 5 u 3 u 4 v 1 v 2 v 5 v 3 v 4

29 Example (Cont.) There are four possibilities (this can get messy!) f(u 1 ) = v 1, f(u 2 ) = v 3, f(u 3 ) = v 2, f(u 4 ) = v 5, f(u 5 ) = v 4 f(u 1 ) = v 4, f(u 2 ) = v 3, f(u 3 ) = v 2, f(u 4 ) = v 5, f(u 5 ) = v 1 f(u 1 ) = v 1, f(u 2 ) = v 5, f(u 3 ) = v 2, f(u 4 ) = v 3, f(u 5 ) = v 4 f(u 1 ) = v 4, f(u 2 ) = v 5, f(u 3 ) = v 2, f(u 4 ) = v 3, f(u 5 ) = v 1 G H u 1 u 2 u 5 u 3 u 4 v 1 v 2 v 5 v 3 v 4

30 Example (Cont.) u 1 u 2 u 3 u 4 u 5 u u u u u v 1 v 2 v 3 v 4 v 5 v v v v v We permute the adjacency matrix of H (per function choices above) to see if we get the adjacency of G. Lets try: f(u 1 ) = v 1, f(u 2 ) = v 3, f(u 3 ) = v 2, f(u 4 ) = v 5, f(u 5 ) = v 4 Does G = H? Yes! v 1 v 3 v 2 v 5 v 4 v v v v v GH H

31 Example (Cont.) u 1 u 2 u 3 u 4 u 5 u u u u u v 1 v 2 v 3 v 4 v 5 v v v v v It turns out that f(u 1 ) = v 4, f(u 2 ) = v 3, f(u 3 ) = v 2, f(u 4 ) = v 5, f(u 5 ) = v 1 also works. v 4 v 3 v 2 v 5 v 1 v v v v v GH H

32 Isomorphism of Graphs Example 10: Determine whether the graphs shown in below are isomorphic. FIGURE 10 The Graphs G and H. 31

33 Isomorphism of Graphs FIGURE 11 The Subgraphs of G and H Made Up of Vertices of Degree Three and the Edges Connecting Them. 32

34 Isomorphism of Graphs Example 11: Determine whether the graphs G and H displayed in below are isomorphic. FIGURE 12 Graphs G and H. 33

35 CSE 211 Discrete Mathematics Chapter 8.4 Connectivity

36 Paths in Undirected Graphs There is a path from vertex v 0 to vertex v n if there is a sequence of edges from v 0 to v n –This path is labeled as v 0,v 1,v 2,…,v n and has a length of n. The path is a circuit if the path begins and ends with the same vertex. A path is simple if it does not contain the same edge more than once.

37 Graph Theoretic Foundations Paths and Cycles: Walk in a graph G is v 0, e 1, v 1, …, v l-1, e l, v l

38 Graph Theoretic Foundations Paths and Cycles: IF v 0, v 1, …, v l are distinct (except possible v 0,v l ) then the walk is a path. Denoted by v 0, v 1, …, v l or e 1, e 2, …, e l Length of path is l

39 Paths, Cycles, and Trails A trail is a walk with no repeated edge.

40 Graph Theoretic Foundations Paths and Cycles: A path or walk is closed if v 0 = v l A closed path containing at least one edge is called a cycle.

41 Paths in Undirected Graphs A path or circuit is said to pass through the vertices v 0, v 1, v 2, …, v n or traverse the edges e 1, e 2, …, e n.

42 Example u 1, u 4, u 2, u 3 –Is it simple? –yes –What is the length? –3–3 –Does it have any circuits? –no u 1 u 2 u 5 u 4 u 3

43 Example u 1, u 5, u 4, u 1, u 2, u 3 –Is it simple? –yes –What is the length? –5–5 –Does it have any circuits? –Yes; u 1, u 5, u 4, u 1 u 1 u 2 u 5 u 3 u 4

44 Example u 1, u 2, u 5, u 4, u 3 –Is it simple? –yes –What is the length? –4–4 –Does it have any circuits? –no u 1 u 2 u 5 u 3 u 4

45 Connectedness An undirected graph is called connected if there is a path between every pair of distinct vertices of the graph. There is a simple path between every pair of distinct vertices of a connected undirected graph.

46 Example Are the following graphs connected? c e f a d b g e c a f b d YesNo

47 Connectedness (Cont.) A graph that is not connected is the union of two or more disjoint connected subgraphs (called the connected components of the graph).

48 Example What are the connected components of the following graph? b a c d e h g f

49 Example What are the connected components of the following graph? b a c d e h g f {a, b, c}, {d, e}, {f, g, h}

50 Cut edges and vertices If one can remove a vertex (and all incident edges) and produce a graph with more connected components, the vertex is called a cut vertex. If removal of an edge creates more connected components the edge is called a cut edge or bridge.

51 Example Find the cut vertices and cut edges in the following graph. a b c d f e h g

52 Example Find the cut vertices and cut edges in the following graph. a b c d f e h g Cut vertices: c and e Cut edge: (c, e)

53 Graph Theoretic Foundations Connectivity: Connectivity (G) of graph G is … G is k connected if (G) k Separator or vertex-cut Cut vertex Separation pair

54 Graph Theoretic Foundations Trees and Forests: Tree – connected graph without any cycle Forest – a graph without any cycle

55 Connectedness in Directed Graphs A directed graph is strongly connected if there is a directed path between every pair of vertices. A directed graph is weakly connected if there is a path between every pair of vertices in the underlying undirected graph.

56 Example Is the following graph strongly connected? Is it weakly connected? a b c e d This graph is strongly connected. Why? Because there is a directed path between every pair of vertices. If a directed graph is strongly connected, then it must also be weakly connected.

57 Example Is the following graph strongly connected? Is it weakly connected? a b c e d This graph is not strongly connected. Why not? Because there is no directed path between a and b, a and e, etc. However, it is weakly connected. (Imagine this graph as an undirected graph.)

58 Connectedness in Directed Graphs The subgraphs of a directed graph G that are strongly connected but not contained in larger strongly connected subgraphs (the maximal strongly connected subgraphs) are called the strongly connected components or strong components of G.

59 Example What are the strongly connected components of the following graph? a b c e d This graph has three strongly connected components: The vertex a The vertex e The graph consisting of V = {b, c, d} and E = { (b, c), (c, d), (d, b)}

60 Consider a connected graph G. The distance between vertices u and v in G, written d(u, v), is the length of the shortest path between u and v. The distance of G, written diam(G), is the maximum distance between any two points in G. For example, in Fig. 1-8(a), d(A,F) = 2 and diam(G) = 3, whereas in Fig. 1-8(b), d(A, F) = 3 and diam(G) = 4 Distance in Trees and Graphs

61 If G has a u, v-path, then the distance from u to v, written d G (u, v) or simply d(u, v), is the least length of u, v-path. The diameter (diam G) is max u,v V(G) d(u,v) The eccentricity [ (u)] of a vertex u is max v V(G) d(u,v) The radius of G (rad G) is min u V(G) (u) A vertex with minimum eccentricity in G is called a center of G.

62 Distance in Trees and Graphs Find the diameter, eccentricity, radius and center of the given G.


Download ppt "CSE 211 Discrete Mathematics Chapter 8.3 Representing Graphs and Graph Isomorphism."

Similar presentations


Ads by Google