Presentation is loading. Please wait.

Presentation is loading. Please wait.

Graphs. Representations of graphs : undirected graph An undirected graph G have five vertices and seven edges An adjacency-list representation of G The.

Similar presentations


Presentation on theme: "Graphs. Representations of graphs : undirected graph An undirected graph G have five vertices and seven edges An adjacency-list representation of G The."— Presentation transcript:

1 Graphs

2 Representations of graphs : undirected graph An undirected graph G have five vertices and seven edges An adjacency-list representation of G The adjacency-matrix representation of G 12 3 45 vertex edge 12 2 5/ 1 324/ 42 54 12345 1 2 3 4 5 01001 10111 01010 01101 11000 534/ 53/ 11/

3 Representations of graphs : directed graph An directed graph G have six vertices and eight edges An adjacency-list representation of G The adjacency-matrix representation of G 123 54 12 2 4/ 5/ 365/ 42/ 54/ 66/ 12345 1 2 3 4 5 01010 00001 00001 01000 00010 6 600000 6 0 0 1 0 0 1

4 p4. A graph is simple when it has no loops and no two distinct edges have the same pair of ends. Problems about graphs: 1. Matching 2. Spelling Check 3. Network Reliability 4. Street Surveillance 5. Scheduling Meetings 6. ……..

5 p5. Two graphs are isomorphic if there is a 1-1 correspondence between the vertex sets such that if two vertices are joined by an edge in one graph, then the corresponding vertices are joined by an edge in the other graph. 1 23 1 2 3

6 p6. A permutation σ of the vertex set of a graph G with the property that {a, b} is an edge iff {σ(a), σ(b)} is an edge, is called an automorphism of G A complete graph K n on n vertices is the simple graph that has all n(n-1)/2 edges. Γ(x) denotes the set of all vertices adjacent to a given vertex x. The number of edges incident with a vertex x is called the degree or the valency of x. A regular graph has all its vertices with the same degree.

7 p7. Thm 1.1. A finite graph G has an even number of vertices with odd degree. Proof:

8 p8. Mountain Climbers Puzzle Two people start at A and Z at The same elevation on opposite sides of a mountain range whose summit is at M. Puzzle: is it possible for the people to meet at M in a fashion so that they are always at the same altitude every moment? Assume that there is no point lower than A (or Z) and no point is higher than M. A Z M

9 p9. Mountain Climbers Puzzle Range Graph: Vertex: a pair of points (P L, P R ) at the same altitude with P L on the left of M and P R on the right, such that one of the 2 points is a local peak or valley. Edge: (P L, P R ) and (P’ L, P’ R ) forms an edge, if 2 people can move constantly in the same direction from P L to P’ L and from P R to P’ R, respectively. Range graphMountain Range

10 p10. Mountain Climbers Puzzle Observation: (A, Z) and (M,M) have degree 1. Every other vertex has degree 2 or 4. What would happen if there were no path from (A, Z) to (M, M)? Range graphMountain Range

11 p11. Planar graphs We say a graph is planar if it can be drawn on a plane without edges crossing. K5K5 K 3,3

12 p12. Kuratowski's Theorem A graph is non-planar if and only if it contains a subgraph homeomorphic to K 3,3 or K 5. Or equivalently, a graph is planar if and only if it does not contains subgraph that is K 3,3 or K 5.

13 p13. Euler's Formula (1752) If G=(V,E) is a connected planar simple graph with e=|E| and v=|V|, and let r be the number of regions that are created when drawing a planar representation of the graph, then r = e – v + 2.

14 p14. Proof of r = e – v + 2 Prove by induction on the number of edges Choose successive edges so that at every stage the subgraph is connected. For e=1, we can only have this graph, which has v=2 and r=1, so the theorem holds. Assume the conclusion it true for e-1 edges. Adding an edge to get our planar graph, there are only two possibilities to consider.

15 p15. Corollary

16 p16. K 5 is nonplanar Proof: The graph K 5 has v = 5, e = 10. 3 v – 6 = 5 < 10 = e. But for a planar graph e is at most 3v – 6. Thus K 5 is nonplanar.

17 p17. K 3,3 is nonplanar

18 p18. Bipartite graph A bipartite graph is a graph where the vertices can be partitioned into two sets where there are no edges within a partition. Theorem: A graph G is bipartite if and only if every cycle in G has even length.

19 p19. A graph G is bipartite if and only if every cycle in G has even length. Proof: It is sufficient to prove the theorem for connected bipartitie graph. If G is bipartite, consider a cycle X 1 -X 2 -X 3-...-X k -X 1, where X 1 is a left vertex. Then X k is a right vertex. Thus k is even and the cycle length is even. Suppose G has an odd cycle V 1 -V 2 -...-V n -V 1, where n is odd. Partition the vertices into A and B by putting V 1 in A, V 2 into B, and so on. Then V n is in A. There is an edge in A. Thus G is non-bipartite.

20

21 p21. A polygon is a finite connected graph that is regular of degree 2. A closed path through a graph using every edge once is called an Eulerian circuit. A graph with such a path is called an Eulerian graph. Theorem: (Euler 1736) A finite graph G with no isolated vertices (but possibly with multiple edges) is Eulerian if and only if it is connected and every vertex has even degree.

22 Proof : (1) If G is Eulerian, then G must be connected. Since the path enters a vertex through some edge and leaves by another edge, it is clear that all degrees must be even. (2) Start from a vertex x and begin making a path. Keep going and never use the same edge twice, until we cannot go further. Since every vertex has even degree, this can only happen when we return to x and all edges from x have been used. If there are unused edges, then consider the subgraph formed by these edges. Use the same procedure on the remaining subgraph and produce 2nd closed path. These two paths share at least one vertex, then they can be combined to a longer closed path from x to x.

23 Corollary: A graph has an Eulerian path but no Eulerian circuit if and only if it has exactly two vertices with odd degree. Pf: If we add an edge between the two odd-degree vertices, the graph will have an Eulerian circuit. If we remove the edge, then what remains is an Eulerian path. Suppose a graph with a different number of odd-degree vertices has an Eulerian path. Add an edge between the two ends of the path. This is a graph with an odd-degree vertex and a Euler circuit. As the above theorem shows, this is a contradiction. ∎

24 A Hamiltonian circuit in a graph G is a simple closed path that passes through each vertex exactly once. It is very difficult to determine if a graph G has a Hamiltonian circuit efficiently. Indeed it is proved to be NP-complete. What is NP-complete anyway?

25 p25. Theorem If a simple graph G on n vertices has all vertices of degree at least n/2, then it contains a Hamiltonian circuit. Pf: By contradiction, suppose it is not true. Let G be such a counterexample with the maximum number of edges. Let y and z be two non-adjacent vertices. Since adding {y, z} creates a Hamiltonian circuit, there exists a simple path from y to z with vertices y=x 1, x 2,...,x n =z, say. {i: y is adjacent to x i+1 } and {i: z is adjacent to x i } each have at least n/2 neighbors and are in {1,2,...,n-1}, so they must intersect at some element {i 0 }. Then y=x 1, x 2,...,x i 0, z=x n, x n-1,...,x i 0 +1, x 1 =y is Ham circuit. Contradiction! y=x 1 x2x2 xi0xi0 x i0+1 x n =z

26 p26. NP: the class of problems whose answer can be verified in “polynomial time”. P: the class of problems which can be solved in “polynomial time”.. NP-complete: A problem B is NP-complete if it satisfies: 1. B is in NP, and 2. Every A in NP is polynomial time reducible to B. It is worth 1 million US dollars to prove P = NP or not. Want to try? http://www.claymath.org/millennium/P_vs_NP/

27 p27. Instant Insanity puzzle Consider 4 cubes with faces colored red, blue, green and yellow. Suppose each cube uses all the 4 colors. The problem is to make a stack of these cubes so that all 4 colors appears on each of the 4 sides of the stack. RYB R B R B R B R B G Y G Y

28 Now arrange the blocks according to the subgraphs we constructed. The arrow points to the block face that faces right. G G B B Y Y R R 12 3 4 12341234

29 G B B G Y Y R R 1 2 3 4 12341234

30 p30. Instant Insanity puzzle R B R B R B R B G Y G Y R B G Y 11 1 2 2 2 3 3 3 4 4 4 4 4 4 1 1 1 2 2 2 3 3 3


Download ppt "Graphs. Representations of graphs : undirected graph An undirected graph G have five vertices and seven edges An adjacency-list representation of G The."

Similar presentations


Ads by Google