Presentation is loading. Please wait.

Presentation is loading. Please wait.

Euler and Hamilton Cycles; Planar Graphs; Coloring.

Similar presentations


Presentation on theme: "Euler and Hamilton Cycles; Planar Graphs; Coloring."— Presentation transcript:

1 Euler and Hamilton Cycles; Planar Graphs; Coloring.
Zeph Grunschlag Copyright © Zeph Grunschlag,

2 Agenda Euler paths and cycles Hamilton paths and cycles Planar graphs
Regions Euler characteristic Edge-Face Handshaking Girth Graph Coloring Dual Graph Scheduling L25

3 Euler and Hamilton Paths -Motivation
An pictorial way to motivate the graph theoretic concepts of Eulerian and Hamiltonian paths and circuits is with two puzzles: The pencil drawing problem The taxicab problem L25

4 Pencil Drawing Problem -Euler Paths
Which of the following pictures can be drawn on paper without ever lifting the pencil and without retracing over any segment? L25

5 Pencil Drawing Problem -Euler Paths
Graph Theoretically: Which of the following graphs has an Euler path? L25

6 Pencil Drawing Problem -Euler Paths
Answer: the left but not the right. 1 2 3 start finish 4 6 5 L25

7 Euler Paths and Circuits Definition
DEF: An Euler path in a graph G is a simple path containing every edge in G. An Euler circuit (or Euler cycle) is a cycle which is an Euler path. NOTE: The definition applies both to undirected as well as directed graphs of all types. L25

8 Taxicab Problem -Hamilton Paths
Can a taxicab driver milk his hapless customer by visiting every intersection exactly once, when driving from point A to point B ? A L25 B

9 Taxicab Problem -Hamilton Paths
Graph Theoretically: Is there a Hamilton path from A to B in the following graph? (NO in this case) A L25 B

10 Hamilton Paths and Circuits Definition
DEF: A Hamilton path in a graph G is a path which visits ever vertex in G exactly once. A Hamilton circuit (or Hamilton cycle) is a cycle which visits every vertex exactly once, except for the first vertex, which is also visited at the end of the cycle. NOTE: Again, the definition applies both to undirected as well as directed graphs of all types. L25

11 Implications to CS Finding Hamilton paths is a very important problem in CS. EG: Visit every city (vertex) in a region using the least trips (edges) as possible. EG: Encode all bit strings of a certain length as economically as possible so that only change one bit at a time. (Gray codes). L25

12 Implications to CS Analyzing difficulty of Euler vs. Hamilton paths is a great CS case study. Finding Euler paths can be done in O (n) time Finding Hamilton paths is NP-complete! Slight change in definition can result in dramatic algorithmic bifurcation! L25

13 Finding Euler Paths To find Euler paths, we’ll first give an algorithm for finding Euler cycles and then modify it to give Euler paths. THM: An undirected graph G has an Euler circuit iff it is connected and every vertex has even degree. NOTE: for directed graphs the condition is that G be weakly connected and that every vertex has same in-degree as out-degree. L25

14 Finding Euler Circuits
Q: Why does the following graph have no Euler circuit? L25

15 Finding Euler Circuits
A: It contains a vertex of odd degree. L25

16 Finding Euler Circuits
Let’s prove the theorem constructively. Constructive means that the proof will actually contain an algorithm for constructing the Euler path, when it exists. Part 1) Suppose G is connected and each vertex has even degree. Construct an Euler cycle. We prove this by strong induction on m –the number of edges in G. Base case m = 0: Since G is connected and contains no edges, it must consist of a single vertex. The empty path is an Euler cycle.1 1If m=0 freaks you out, start with another base case, such as m=1. L25

17 Finding Euler Circuits
Induction step for m+1 edges, assuming proved this up to m  0. CLAIM: G contains a simple cycle. Consider an edge e (since m+1 > 0). If e is a self-loop, then is a simple cycle. So can assume that e is a loopless edge: v v’ Since deg(v’ ) > 1 (all degrees are even), another edge e’ must be incident with v’ : 1If m=0 freaks you out, start with another base case, such as m=1. e L25 v’ v’’

18 Finding Euler Circuits
So can continue adding edges until we find an edge whose new endpoint has already been encountered during the process. This endpoint is a vertex which is seen twice so at which a simple cycle is based! (This proves claim) 1If m=0 freaks you out, start with another base case, such as m=1. Simple cycle L25

19 Finding Euler Circuits
Gives rise to a recursive proof/algorithm: Find a simple cycle in connected graph with m+1 edges. Delete all the edges from the cycle and find Euler cycles in each resulting component Amalgamate Euler cycles together using the simple cycle obtaining wanted Euler cycle. Let’s see how the amalgamation process works: L25

20 Finding Euler Circuits Mohammed’s Scimitars

21 Finding Euler Circuits Mohammed’s Scimitars
Found a cycle after starting from middle vertex. Delete the cycle: L25

22 Finding Euler Circuits Mohammed’s Scimitars
Found a cycle after starting from middle vertex. Delete the cycle: L25

23 Finding Euler Circuits Mohammed’s Scimitars
Found a cycle after starting from middle vertex. Delete the cycle: L25

24 Finding Euler Circuits Mohammed’s Scimitars
Found a cycle after starting from middle vertex. Delete the cycle: L25

25 Finding Euler Circuits Mohammed’s Scimitars
Found a cycle after starting from middle vertex. Delete the cycle: L25

26 Finding Euler Circuits Mohammed’s Scimitars
Now try again (say from middle vertex): L25

27 Finding Euler Circuits Mohammed’s Scimitars
This time, found a cycle starting and ending at middle vertex: Amalgamate these cycles together from a point of intersection, and delete from graph: L25

28 Finding Euler Circuits Mohammed’s Scimitars
Find another cycle from middle vertex: 1 L25

29 Finding Euler Circuits Mohammed’s Scimitars
Find another cycle from middle vertex: 1 2 L25

30 Finding Euler Circuits Mohammed’s Scimitars
Find another cycle from middle vertex: 1 2 3 L25

31 Finding Euler Circuits Mohammed’s Scimitars
Find another cycle from middle vertex: 1 2 3 4 L25

32 Finding Euler Circuits Mohammed’s Scimitars
Find another cycle from middle vertex: 1 2 5 3 4 L25

33 Finding Euler Circuits Mohammed’s Scimitars
Find another cycle from middle vertex: 1 2 6 5 3 4 L25

34 Finding Euler Circuits Mohammed’s Scimitars
Find another cycle from middle vertex: 7 1 2 6 5 3 4 L25

35 Finding Euler Circuits Mohammed’s Scimitars
Find another cycle from middle vertex: 8 7 1 2 6 5 3 4 L25

36 Finding Euler Circuits Mohammed’s Scimitars
Find another cycle from middle vertex: 9 8 7 1 2 6 5 3 4 L25

37 Finding Euler Circuits Mohammed’s Scimitars
Find another cycle from middle vertex: 9 8 10 7 1 2 6 5 3 4 L25

38 Finding Euler Circuits Mohammed’s Scimitars
Find another cycle from middle vertex: 9 8 10 7 1 2 11 6 5 3 4 L25

39 Finding Euler Circuits Mohammed’s Scimitars
Amalgamate it to Euler cycle of deleted graph, and delete it. Need to insert cycle between former edges 10 & 11: 9 8 10 7 1 2 11 6 5 3 4 L25

40 Finding Euler Circuits Mohammed’s Scimitars
Finally, need to add the triangle. Use same naïve approach looking for cycle in remaining component: 9 8 10 7 1 2 ?? 6 5 3 4 L25

41 Finding Euler Circuits Mohammed’s Scimitars
Finally, need to add the triangle. Use same naïve approach looking for cycle in remaining component: 9 8 10 7 1 11 2 ?? 6 5 3 4 L25

42 Finding Euler Circuits Mohammed’s Scimitars
Finally, need to add the triangle. Use same naïve approach looking for cycle in remaining component: 9 8 10 7 1 12 11 2 ?? 6 5 3 4 L25

43 Finding Euler Circuits Mohammed’s Scimitars
Finally, need to add the triangle. Use same naïve approach looking for cycle in remaining component: 9 8 10 7 13 1 12 11 2 ?? 6 5 3 4 L25

44 Finding Euler Circuits Mohammed’s Scimitars
Finally, need to add the triangle. Use same naïve approach looking for cycle in remaining component: 9 8 10 7 14 13 1 12 11 2 ?? 6 5 3 4 L25

45 Finding Euler Circuits Mohammed’s Scimitars
Finally, need to add the triangle. Use same naïve approach looking for cycle in remaining component: 9 8 10 7 14 13 1 12 11 2 15 6 5 3 4 L25

46 Finding Euler Circuits Mohammed’s Scimitars
Amalgamate the triangle cycle between edges formerly labeled 9 & 10: 9 8 10 7 14 13 1 12 11 2 15 6 5 3 4 L25

47 Finding Euler Circuits Mohammed’s Scimitars
Amalgamate the triangle cycle between edges formerly labeled 9 & 10: 9 8 ?? 7 ?? ?? 1 ?? ?? 2 ?? 6 5 3 4 L25

48 Finding Euler Circuits Mohammed’s Scimitars
We found the Euler circuit! 9 10 8 11 13 7 12 17 16 1 15 14 2 18 6 5 3 4 L25

49 Euler Circuit  All Degrees Even
2nd half of theorem says that an Euler circuit in a graph implies that all degrees are even: In a simple cycle, whenever path enters vertex, must come out on different edge. Thus every visit of v contributes 2 to deg(v). Thus, if keep only edges which were on the simple cycle, degrees of resulting graph are all even. But in an Eulerian graph G, can find a simple cycle containing all vertices and consequently graph resulting from cycle is G itself!  L25

50 Generalizing to Euler Paths
Q: Does the following have an Euler circuit? L25

51 Generalizing to Euler Paths
A: No, vertices of odd degree: Q: But why does it have an Euler path? L25

52 Generalizing to Euler Paths
A: YES! Because exactly 2 vertices of odd degree. So can add a phantom edge between odd degree vertices: L25

53 Generalizing to Euler Paths
All degrees now even so find Euler cycle: L25

54 Generalizing to Euler Paths
Now remove phantom edge obtaining: 1 2 3 7 4 6 5 L25

55 Generalizing to Euler Paths
Generalize: 1 2 3 4 6 5 L25

56 Generalizing to Euler Paths
THM: An undirected connected graph has an Euler path iff there are exactly two vertices of odd degree. L25

57 Blackboard Exercises for 7.5
Prove by induction that Qn always has a Hamilton cycle for n > 1. (This gives a Gray code). Prove that the following graph has no Hamilton cycle: L25

58 Planar Graphs Planar graphs are graphs that can be drawn in the plane without edges having to cross. Understanding planar graph is important: Any graph representation of maps/ topographical information is planar. graph algorithms often specialized to planar graphs (e.g. traveling salesperson) Circuits usually represented by planar graphs L25

59 Planar Graphs -Common Misunderstanding
Just because a graph is drawn with edges crossing doesn’t mean its not planar. Q: Why can’t we conclude that the following is non-planar? L25

60 Planar Graphs -Common Misunderstanding
A: Because it is isomorphic to a graph which is planar: L25

61 Planar Graphs -Common Misunderstanding
A: Because it is isomorphic to a graph which is planar: L25

62 Planar Graphs -Common Misunderstanding
A: Because it is isomorphic to a graph which is planar: L25

63 Planar Graphs -Common Misunderstanding
A: Because it is isomorphic to a graph which is planar: L25

64 Planar Graphs -Common Misunderstanding
A: Because it is isomorphic to a graph which is planar: L25

65 Planar Graphs -Common Misunderstanding
A: Because it is isomorphic to a graph which is planar: L25

66 Planar Graphs -Common Misunderstanding
A: Because it is isomorphic to a graph which is planar: L25

67 Planar Graphs -Common Misunderstanding
A: Because it is isomorphic to a graph which is planar: L25

68 Planar Graphs -Common Misunderstanding
A: Because it is isomorphic to a graph which is planar: L25

69 Proving Planarity To prove that a graph is planar amounts to redrawing the edges in a way that no edges will cross. May need to move vertices around and the edges may have to be drawn in a very indirect fashion. E.G. show that the 3-cube is planar: L25

70 Proving Planarity 3-Cube

71 Proving Planarity? 4-Cube
Seemingly not planar, but how would one prove this! L25

72 Disproving Planarity The book gives several methods. I’ll describe one method that will always work in examples that you’ll get on the final. You may also use any of the methods that the book mentions. (One method –Kuratowski’s theorem– in principle always works, though in practice can be quite unwieldy.) L25

73 Disproving Planarity The idea is to try to find some invariant quantities possessed by graphs which are constrained to certain values, for planar graphs. Then to show that a graph is non-planar, compute the quantities and show that they do not satisfy the constraints on planar graphs. L25

74 Regions The first invariant of a planar graph will be the number of regions that the graph defines in the plane. A region is a part of the plane completely disconnected off from other parts of the plane by the edges of the graph. EG: the car graph has 4 regions: 4 3 1 2 L25

75 Regions Q: How many regions does the 3-cube have? L25

76 Regions A: 6 regions 3 6 4 1 2 5 L25

77 Regions THM: The number of regions defined by a connected planar graph is invariant of how it is drawn in the plane and satisfies the formula involving edges and vertices: r = |E | - |V | + 2 EG: Verify formula for car and 3-cube: 4=6-4+2 3 3 6=12-8+2 4 1 2 5 1 2 L25

78 Euler Characteristic The formula is proved by showing that the quantity (chi) c = r - |E | + |V | must equal 2 for planar graphs. c is called the Euler characteristic. The idea is that any connected planar graph can be built up from a vertex through a sequence of vertex and edge additions. For example, build 3-cube as follows: L25

79 Euler Characteristic L25

80 Euler Characteristic Thus to prove that c is always 2 for planar graphs, one calculate c for the trivial vertex graph: c = = 2 and then checks that each possible move does not change c . L25

81 Euler Characteristic Check that moves don’t change c :
Adding a degree 1 vertex: r is unchanged. |E | increases by 1. |V | increases by 1. c += (0-1+1) 2) Adding an edge between pre-existing vertices: r increases by 1. |E | increases by 1. |V | unchanged. c += (1-1+0) EG: EG: L25

82 Animated Invariance of Euler Characteristic
r - |E | + |V | 1 2 L25

83 Animated Invariance of Euler Characteristic
r - |E | + |V | 2 1 L25

84 Animated Invariance of Euler Characteristic
r - |E | + |V | 3 2 1 L25

85 Animated Invariance of Euler Characteristic
r - |E | + |V | 4 3 1 2 L25

86 Animated Invariance of Euler Characteristic
r - |E | + |V | 4 2 L25

87 Animated Invariance of Euler Characteristic
r - |E | + |V | 5 2 L25

88 Animated Invariance of Euler Characteristic
r - |E | + |V | 6 2 L25

89 Animated Invariance of Euler Characteristic
r - |E | + |V | 7 2 L25

90 Animated Invariance of Euler Characteristic
r - |E | + |V | 8 2 L25

91 Animated Invariance of Euler Characteristic
r - |E | + |V | 8 9 3 2 L25

92 Animated Invariance of Euler Characteristic
r - |E | + |V | 8 10 4 2 L25

93 Animated Invariance of Euler Characteristic
r - |E | + |V | 8 11 5 2 L25

94 Animated Invariance of Euler Characteristic
r - |E | + |V | 8 12 6 2 L25

95 Face-Edge Handshaking
For all graphs handshaking theorem relates degrees of vertices to number of edges. For planar graphs, can relate regions to edges in similar fashion: EG: There are two ways to count the number of edges in 3-cube: Count directly: 12 Count no. of edges around each region; divide by 2: ( )/2 = 12 (2 triangles per edge)

96 Face-Edge Handshaking
DEF: The degree of a region F is the number of edges at its boundary, and is denoted by deg(F ). THM: Let G be a planar graph with region set R. Then: L25

97 Girth The girth of a graph is the length of the smallest simple cycle in the graph. Q: What the girth of each of the following? L25

98 Girth A: g = 2 g = 4 g = 4 Q: What the smallest possible girth for simple bipartite graphs? L25

99 Girth A: g = 4 is the smallest possible girth: Any cycle must start and end in the same color, so must have even length. Since simple, cannot have a 2-cycle, so 4-cycle is shortest possible. L25

100 Proving that Q4 is Non-Planar
Now we have enough invariants to prove that the 4-cube is non-planar. Count the number of vertices and edges: |V | = 16 (twice the number for 3-cube) |E | = 32 (twice the number for 3-cube plus number of vertices in 3-cube) Suppose 4-cube were planar so by Euler’s formula number of regions would be: r = =18 L25

101 Proving that Q4 is Non-Planar
3) Calculate the girth: g = 4 4) Apply handshaking theorem to get a lower bound on the number of edges, since the degree of each face must be at least as large as the girth: In our case, this give |E |  ½·18·4=36 contradicting |E | = 32 ! Thus 4-cube cannot be planar.  L25

102 Blackboard exercises for 7.7
Show that the following graphs are non-planar: K5 K3,3 Qn for n  4 L25

103 Graph Coloring Consider a fictional continent. L25

104 Map Coloring Suppose removed all borders but still wanted to see all the countries. 1 color insufficient. L25

105 Map Coloring So add another color. Try to fill in every country with one of the two colors. L25

106 Map Coloring So add another color. Try to fill in every country with one of the two colors. L25

107 Map Coloring So add another color. Try to fill in every country with one of the two colors. L25

108 Map Coloring So add another color. Try to fill in every country with one of the two colors. L25

109 Map Coloring PROBLEM: Two adjacent countries forced to have same color. Border unseen. L25

110 Map Coloring So add another color: L25

111 Map Coloring Insufficient. Need 4 colors because of this country. L25

112 Map Coloring With 4 colors, could do it. L25

113 4-Color Theorem THM: Any planar map of regions can be depicted using 4 colors so that no two regions that share a positive-length border have the same color. Proof by Haaken and Appel used exhaustive computer search. L25

114 From Map Coloring to Graph Coloring
The problem of coloring a map, can be reduced to a graph-theoretic problem: L25

115 From Map Coloring to Graph Coloring
For each region introduce a vertex: L25

116 From Map Coloring to Graph Coloring
For each pair of regions with a positive-length common border introduce an edge: L25

117 From Maps to Graphs to Dual Graphs
Really, could think of original map as a graph, and we are looking at dual graph: L25

118 From Maps to Graphs to Dual Graphs
1) Put vertex inside each region: L25

119 From Maps to Graphs to Dual Graphs
2) Connect vertices across common edges: L25

120 Definition of Dual Graph
DEF: The dual graph G ^ of a planar graph G = (V, E, R) [Vertices, Edges, Regions] is the graph obtained by setting Vertices of G ^: V (G ^ ) = R Edges of G ^: E (G ^ ) = set of edges of the form {F1,F2} where F1 and F2 share a common edge. L25

121 From Maps to Graphs to Dual Graphs
So take dual graph: L25

122 From Map Coloring to Graph Coloring
Coloring regions is equivalent to coloring vertices of dual graph. L25

123 Definition of Colorable
DEF: Let n be a positive number. A simple graph is n -colorable if the vertices can be colored using n colors so that no two adjacent vertices have the same color. The chromatic number of a graph is smallest number n for which it is n -colorable. EG: A graph is bipartite iff it is 2-colorable. Formal definition: There is a function f : V  {1,2,3,…,n} such that for edges e with endpoints u,v (so e = {u,v}) f (u) is not equal to f (v). L25

124 From Map Coloring to Graph Coloring
Map not 2-colorable, so dual graph not 2-colorable: L25

125 From Map Coloring to Graph Coloring
Map not 3-colorable, so graph not 3-colorable: L25

126 From Map Coloring to Graph Coloring
Graph is 4-colorable, so map is as well: L25

127 4-Color Theorem –Graph Theory Version
THM: Any planar graph is 4-colorable. L25

128 Graph Coloring and Schedules
EG: Suppose want to schedule some final exams for CS courses with following call numbers: 1007, 3137, 3157, 3203, 3261, 4115, 4118, 4156 Suppose also that there are no common students in the following pairs of courses because of prerequisites: , , , , , , , , , How many exam slots are necessary to schedule exams? Assume that in all other pairs there are students. L25

129 Graph Coloring and Schedules
Turn this into a graph coloring problem. Vertices are courses, and edges are courses which cannot be scheduled simultaneously because of possible students in common: 3203 3261 3137 4115 1007 4118 3157 4156 L25

130 Graph Coloring and Schedules
One way to do this is to put edges down where students mutually excluded… 3203 3261 3137 4115 1007 4118 3157 4156 L25

131 Graph Coloring and Schedules
…and then compute the complementary graph: 3203 3261 3137 4115 1007 4118 3157 4156 L25

132 Graph Coloring and Schedules
…and then compute the complementary graph: 3203 3261 3137 4115 1007 4118 3157 4156 L25

133 Graph Coloring and Schedules
Redraw: 3137 3203 3261 4115 1007 3157 4118 4156 L25

134 Graph Coloring and Schedules
Not 1-colorable because of edge 3137 3203 3261 4115 1007 3157 4118 4156 L25

135 Graph Coloring and Schedules
Not 2-colorable because of triangle 3137 3203 3261 4115 1007 3157 4118 4156 L25

136 Graph Coloring and Schedules
Is 3-colorable. Try to color by Red, Green, Blue. 3137 3203 3261 4115 1007 3157 This method is also would have discovered if graph were not 3-colorable and given a proof by contradiction. 4118 4156 L25

137 Graph Coloring and Schedules
WLOG Red, 3157-Blue, 4118-Green: 3137 3203 3261 4115 1007 3157 4118 4156 L25

138 Graph Coloring and Schedules
So 4156 must be Blue: 3137 3203 3261 4115 1007 3157 4118 4156 L25

139 Graph Coloring and Schedules
So 3261 and 4115 must be Red. 3137 3203 3261 4115 1007 3157 4118 4156 L25

140 Graph Coloring and Schedules
3137 and 1007 easy to color. 3137 3203 3261 4115 1007 3157 4118 4156 L25

141 Graph Coloring and Schedules
So need 3 exam slots: Slot 2 3137 3203 3261 Slot 1 4115 1007 3157 4118 Slot 3 4156 L25


Download ppt "Euler and Hamilton Cycles; Planar Graphs; Coloring."

Similar presentations


Ads by Google