6.042/18.] Mathematics for Computer Science March 3, 2005 Srini devadas and Eric Lehman Lecture notes Graph Theory II 1 Coloring Graphs Each term, the MIT Schedules Office must assign a time slot for each final exam. This is not easy, because some students are taking several classes with finals, and a student can take only one test during a particular time slot. The Schedules Office wants to avoid all conflicts, but to make the exam period as short as possible We can recast this scheduling problem as a question about coloring the vertices of a graph. Create a vertex for each course with a final exam. Put an edge between two vertices if some student is taking both courses. For example, the scheduling graph might look like this Next, identify each time slot with a color. For example, monday morning is red, Mon day afternoon is blue tuesday morning is green et Assigning an exam to a time slot is now equivalent to coloring the corresponding ver- tex. The main constraint is that adjacent vertices must get different colors; otherwise, some student has two exams at the same time. Furthermore in order to keep the exam period short, we should try to color all the vertices using as few different colors as possi ble. For our example graph, three colors suffice: blue green green
6.042/18.062J Mathematics for Computer Science March 3, 2005 Srini Devadas and Eric Lehman Lecture Notes Graph Theory II 1 Coloring Graphs Each term, the MIT Schedules Office must assign a time slot for each final exam. This is not easy, because some students are taking several classes with finals, and a student can take only one test during a particular time slot. The Schedules Office wants to avoid all conflicts, but to make the exam period as short as possible. We can recast this scheduling problem as a question about coloring the vertices of a graph. Create a vertex for each course with a final exam. Put an edge between two vertices if some student is taking both courses. For example, the scheduling graph might look like this: Next, identify each time slot with a color. For example, Monday morning is red, Monday afternoon is blue, Tuesday morning is green, etc. Assigning an exam to a time slot is now equivalent to coloring the corresponding vertex. The main constraint is that adjacent vertices must get different colors; otherwise, some student has two exams at the same time. Furthermore, in order to keep the exam period short, we should try to color all the vertices using as few different colors as possible. For our example graph, three colors suffice: red green blue green blue
This coloring corresponds to giving one final on Monday morning(red), two Monday afternoon(blue), and two Tuesday morning(green) 1.1 k-Coloring Many other resource allocation problems boil down to coloring some graph. In general, graph G is k-colorable if each vertex can be assigned one of k colors so that adjacent ver- tices get different colors. The smallest sufficient number of colors is called the chromatic number of G. The chromatic number of a graph is generally difficult to compute, but the following theorem provides an upper bound Theorem 1. A graph with maximum degree at most k is(k+ 1)-colorable Proof. We use induction on the number of vertices in the graph, which we denote by n Let P(n) be the proposition that an n-vertex graph with maximum degree at most k is (k 1)-colorable. A l-vertex graph has maximum degree 0 and is l-colorable, so P(1)is true Now assume that P()is true, and let g be an(n+ 1)-vertex graph with maximum degree at most k. Remove a vertex v, leaving an n-vertex graph G. The maximum degree of G is at most k, and so G is(k 1)-colorable by our assumption P(n). Now add back vertex U. We can assign v a color different from all adjacent vertices, since v has degree at most k and k +1 colors are available. Therefore, G is(k+ 1)-colorable. The theorem follows by induction 1.2 Bipartite graphs The 2-colorable graph ohs are important enough to merit a special name; they are called bipartite graphs. Suppose that G is bipartite. This means we can color every vertex in G either black or white so that adjacent vertices get different colors. Then we can put all the black vertices in a clump on the left and all the white vertices in a clump on the right Since every edge joins differently-colored vertices, every edge must run between the two clumps. Therefore, every bipartite graph looks something like this
2 Graph Theory II This coloring corresponds to giving one final on Monday morning (red), two Monday afternoon (blue), and two Tuesday morning (green). 1.1 kColoring Many other resource allocation problems boil down to coloring some graph. In general, a graph G is kcolorable if each vertex can be assigned one of k colors so that adjacent vertices get different colors. The smallest sufficient number of colors is called the chromatic number of G. The chromatic number of a graph is generally difficult to compute, but the following theorem provides an upper bound: Theorem 1. A graph with maximum degree at most k is (k + 1)colorable. Proof. We use induction on the number of vertices in the graph, which we denote by n. Let P(n) be the proposition that an nvertex graph with maximum degree at most k is (k + 1)colorable. A 1vertex graph has maximum degree 0 and is 1colorable, so P(1) is true. Now assume that P(n) is true, and let G be an (n + 1)vertex graph with maximum degree at most k. Remove a vertex v, leaving an nvertex graph G� . The maximum degree of G� is at most k, and so G� is (k + 1)colorable by our assumption P(n). Now add back vertex v. We can assign v a color different from all adjacent vertices, since v has degree at most k and k + 1 colors are available. Therefore, G is (k + 1)colorable. The theorem follows by induction. 1.2 Bipartite Graphs The 2colorable graphs are important enough to merit a special name; they are called bipartite graphs. Suppose that G is bipartite. This means we can color every vertex in G either black or white so that adjacent vertices get different colors. Then we can put all the black vertices in a clump on the left and all the white vertices in a clump on the right. Since every edge joins differentlycolored vertices, every edge must run between the two clumps. Therefore, every bipartite graph looks something like this:
Graph Theory Il Bipartite graphs are both useful and common. For example, every path, every tree, and every even-length cycle is bipartite. In turns out, in fact, that every graph not containing an odd cycle is bipartite and vice verse Theorem 2. A graph is bipartite if and only if it contains no odd cycle 2 The King chicken Theorem There are n chickens in a farmyard. For each pair of distinct chickens, either the first pecks the second or the second pecks the first, but not both. We say that chicken u virtually pecks chicken v if either Chicken u pecks chicken u Chicken u pecks some other chicken w who in turn pecks chicken u a chicken that virtually pecks every other chicken is called a king chicken We can model this situation with a tournament digraph. The vertices are chickens, and an edge u- v indicates that chicken u pecks chicken u. In the tournament be elow. three of the four chickens are kings Now were going to prove a theorem about chicken tournaments. The result is not very useful, but the proof involves both induction and digraphs, two of the most common mathematical tools in computer science Theorem 3(King Chicken Theorem). Every n-chicken tournament has a king, where n 1 Proof. The proof is by induction on n, the number of chickens in the tournament. Let P(n) be the proposition that in every n-chicken tournament, there is at least one king irst, we prove P(1). In this case, we can safely say that the lone chicken virtually pecks every other chicken, since there are no others. Therefore, the only chicken in the tournament is a king, and so P(1)is true Next, we must show that P(n)implies P(n+ 1)whenever n >1. Suppose there is a chicken tournament with chickens v1,..., Un+1. If we ignore the last chicken for the 'But if a chicken is a king, isn t it male? And if it is male, isn t it a rooster? Oh well
Graph Theory II 3 Bipartite graphs are both useful and common. For example, every path, every tree, and every evenlength cycle is bipartite. In turns out, in fact, that every graph not containing an odd cycle is bipartite and vice verse. Theorem 2. A graph is bipartite if and only if it contains no odd cycle. 2 The King Chicken Theorem There are n chickens in a farmyard. For each pair of distinct chickens, either the first pecks the second or the second pecks the first, but not both. We say that chicken u virtually pecks chicken v if either: • Chicken u pecks chicken v. • Chicken u pecks some other chicken w who in turn pecks chicken v. A chicken that virtually pecks every other chicken is called a king chicken1. We can model this situation with a tournament digraph. The vertices are chickens, and an edge u v → indicates that chicken u pecks chicken v. In the tournament below, three of the four chickens are kings. king not a king king king Now we’re going to prove a theorem about chicken tournaments. The result is not very useful, but the proof involves both induction and digraphs, two of the most common mathematical tools in computer science. Theorem 3 (King Chicken Theorem). Every nchicken tournament has a king, where n ≥ 1. Proof. The proof is by induction on n, the number of chickens in the tournament. Let P(n) be the proposition that in every nchicken tournament, there is at least one king. First, we prove P(1). In this case, we can safely say that the lone chicken virtually pecks every other chicken, since there are no others. Therefore, the only chicken in the tournament is a king, and so P(1) is true. Next, we must show that P(n) implies P(n + 1) whenever n ≥ 1. Suppose there is a chicken tournament with chickens v1, . . . , vn+1. If we ignore the last chicken for the 1But if a chicken is a king, isn’t it male? And if it is male, isn’t it a rooster? Oh well
moment, then we are left with a tournament among the first n chickens. By our induction hypothesis, P(n), this tournament has a king chicken, Uk Let Di be the set of chickens pecked by the king, Uk. Let D2 be the set of chickens vir- tually pecked by the king, but not pecked directly. Thus, each chicken in D2 was pecked by some chicken in D1. Since Uk is a king, this accounts for all the chickens; that is, UkJ, DI, and D2 form a partition of the set of chickens u1,..., Un). The situation is represented schematically below Now we reintroduce the last chicken, Un+l, and show that the full tournament on n+1 chickens has a king. TH ng here are two cases: 1. Suppose that Uk pecks Un+1. Then Uk is a king of the full tournament 2. Otherwise, Un+1 pecks Uk. There are then two subcases (a) If some chicken in Di pecks Un+1, then Uk virtually pecks Un+1 and so uk is ag a king of the full tournament (b)Otherwise, Un+1 pecks every chicken in D1. In this case, Un+1 is a king of the full tournament; he directly pecks uk and all the chickens in Di and he virtually pecks all the chickens in D2 In every case, a chicken tournament with n+ l chickens has a king, and so P(n+1) holds Thus, by the principle of induction, the claim is proved 3 Planar graphs Here are three dogs and three houses
4 Graph Theory II moment, then we are left with a tournament among the first n chickens. By our induction hypothesis, P(n), this tournament has a king chicken, vk. Let D1 be the set of chickens pecked by the king, vk. Let D2 be the set of chickens virtually pecked by the king, but not pecked directly. Thus, each chicken in D2 was pecked by some chicken in D1. Since vk is a king, this accounts for all the chickens; that is, {vk}, D1, and D2 form a partition of the set of chickens {v1, . . . , vn}. The situation is represented schematically below. k 1 2 D D n+1 v v Now we reintroduce the last chicken, vn+1, and show that the full tournament on n + 1 chickens has a king. There are two cases: 1. Suppose that vk pecks vn+1. Then vk is a king of the full tournament. 2. Otherwise, vn+1 pecks vk. There are then two subcases: (a) If some chicken in D1 pecks vn+1, then vk virtually pecks vn+1 and so vk is again a king of the full tournament. (b) Otherwise, vn+1 pecks every chicken in D1. In this case, vn+1 is a king of the full tournament; he directly pecks vk and all the chickens in D1, and he virtually pecks all the chickens in D2. In every case, a chicken tournament with n+ 1 chickens has a king, and so P(n+ 1) holds. Thus, by the principle of induction, the claim is proved. 3 Planar Graphs Here are three dogs and three houses
Graph TheoryⅡ Dog Can you find a path from each dog to each house such that no two paths intersect? A quadapus is a little-known animal similar to an octopus, but with four arms. Here are five quadapi resting on the seafloor Can each quadapus simultaneously shake hands with every other in such a way that no arms cross Informally, a planar graph is a graph that can be drawn in the plane so that no edges ross. Thus, these two puzzles are asking whether the graphs below are planar; that is whether they can be redrawn so that no edges cross In each case, the answer is, " No-but almost! "In fact, each drawing would be possible if le edge were removed More precisely, graph is planar if it has a planar embedding (or drawing ) This ly of associating each vertex with a distinct point in the plane and each edge with continuous, non-self-intersecting curve such that The endpoints of the curve associated with an edge(u, u)are the points associated with vertices u and u
Graph Theory II 5 Dog Dog Dog Can you find a path from each dog to each house such that no two paths intersect? A quadapus is a littleknown animal similar to an octopus, but with four arms. Here are five quadapi resting on the seafloor: Can each quadapus simultaneously shake hands with every other in such a way that no arms cross? Informally, a planar graph is a graph that can be drawn in the plane so that no edges cross. Thus, these two puzzles are asking whether the graphs below are planar; that is, whether they can be redrawn so that no edges cross. In each case, the answer is, “No— but almost!” In fact, each drawing would be possible if any single edge were removed. More precisely, graph is planar if it has a planar embedding (or drawing). This is a way of associating each vertex with a distinct point in the plane and each edge with a continuous, nonselfintersecting curve such that: • The endpoints of the curve associated with an edge (u, v) are the points associated with vertices u and v