Graph Coloring. Margaret M. Fleck. 3 May This lecture discusses the graph coloring problem (section 9.8 of Rosen).

Similar documents
(x 2)(3x + 1) = 3x + 1

Lecture outline. Graph coloring Examples Applications Algorithms

Using Euler s Theorem

Lecture 6: Graph Properties

Week 10: Colouring graphs, and Euler s paths. 14 and 16 November, 2018

CS 2336 Discrete Mathematics

Greedy algorithms is another useful way for solving optimization problems.

Math 443/543 Graph Theory Notes 5: Planar graphs and coloring

DSATUR. Tsai-Chen Du. December 2, 2013

Week 10: Colouring graphs, and Euler s paths. 14 and 16 November, 2018

Simple Graph. General Graph

A Practical 4-coloring Method of Planar Graphs

Graphs and trees come up everywhere. We can view the internet as a graph (in many ways) Web search views web pages as a graph

Introduction to Graph Theory

Lecture 20 : Trees DRAFT

Chapter 12 and 11.1 Planar graphs, regular polyhedra, and graph colorings

Discrete mathematics

Chapter 8 Independence

Senior Math Circles November 25, 2009 Graph Theory II

Basics of Graph Theory

MITOCW watch?v=penh4mv5gag

Discrete Wiskunde II. Lecture 6: Planar Graphs

Instant Insanity Instructor s Guide Make-it and Take-it Kit for AMTNYS 2006

Relations I. Margaret M. Fleck. 7 November 2008

Solutions to In-Class Problems Week 4, Fri

Discrete Mathematics I So Practice Sheet Solutions 1

Math.3336: Discrete Mathematics. Chapter 10 Graph Theory

Grades 7 & 8, Math Circles 31 October/1/2 November, Graph Theory

Computer Science 280 Fall 2002 Homework 10 Solutions

Class Six: Coloring Planar Graphs

Scheduling, Map Coloring, and Graph Coloring

CPS 102: Discrete Mathematics. Quiz 3 Date: Wednesday November 30, Instructor: Bruce Maggs NAME: Prob # Score. Total 60

The Konigsberg Bridge Problem

Topology and the Four Color Theorem

CSE 331: Introduction to Algorithm Analysis and Design Graphs

Eulerian Tours and Fleury s Algorithm

Ma/CS 6b Class 11: Kuratowski and Coloring

How many colors are needed to color a map?

Treewidth and graph minors

Math 776 Graph Theory Lecture Note 1 Basic concepts

Brief History. Graph Theory. What is a graph? Types of graphs Directed graph: a graph that has edges with specific directions

Greedy Algorithms 1. For large values of d, brute force search is not feasible because there are 2 d

MC 302 GRAPH THEORY 10/1/13 Solutions to HW #2 50 points + 6 XC points

Chapter 3: Paths and Cycles

Graph Theory Part Two

Artificial Intelligence

Elements of Graph Theory

MATH10001 Mathematical Workshop. Graphs, Trees and Algorithms Part 2. Trees. From Trees to Prüfer Codes

Week 9: Planar and non-planar graphs. 1st and 3rd of November, 2017

Massachusetts Institute of Technology 6.042J/18.062J, Fall 02: Mathematics for Computer Science Professor Albert Meyer and Dr. Radhika Nagpal.

MAT 145: PROBLEM SET 6

HW Graph Theory SOLUTIONS (hbovik) - Q

Notes slides from before lecture. CSE 21, Winter 2017, Section A00. Lecture 9 Notes. Class URL:

GRAPH ALGORITHMS Lecture 19 CS 2110 Spring 2019

CHAPTER 2. Graphs. 1. Introduction to Graphs and Graph Isomorphism

Definition 1.1. A matching M in a graph G is called maximal if there is no matching M in G so that M M.

Final Exam Math 38 Graph Theory Spring 2017 Due on Friday, June 2, at 12:50 pm. Good Luck!!

1 Introduction. 1. Prove the problem lies in the class NP. 2. Find an NP-complete problem that reduces to it.

Grades 7 & 8, Math Circles 31 October/1/2 November, Graph Theory

Graph Theory Questions from Past Papers

Register Allocation. Lecture 16

Example of a Demonstration that a Problem is NP-Complete by reduction from CNF-SAT

Puzzling and Apuzzling Graphs 1

Ma/CS 6a Class 9: Coloring

Solving NP-hard Problems on Special Instances

Master Theorem, Introduction to Graphs

γ(ɛ) (a, b) (a, d) (d, a) (a, b) (c, d) (d, d) (e, e) (e, a) (e, e) (a) Draw a picture of G.

Recitation 4: Elimination algorithm, reconstituted graph, triangulation

Problem set 2. Problem 1. Problem 2. Problem 3. CS261, Winter Instructor: Ashish Goel.

GRAPH THEORY: AN INTRODUCTION

Discrete Structures for Computer Science. Feodor F. Dragan Spring 2012

Multi-edges, loops, and two or more pieces are all allowed. Example 4 (Not Graphs). None of the following are graphs.

On Two Short Proofs About List Coloring Graphs

Small Survey on Perfect Graphs

Solutions to In Class Problems Week 5, Wed.

List Colouring Squares of Planar Graphs

Graph Algorithms. Chromatic Polynomials. Graph Algorithms

Graphs and Discrete Structures

Notes for Lecture 24

12.1 Formulation of General Perfect Matching

Homework 3 Solutions

UCSD CSE 21, Spring 2014 [Section B00] Mathematics for Algorithm and System Analysis

Bipartite Roots of Graphs

CS70 - Lecture 6. Graphs: Coloring; Special Graphs. 1. Review of L5 2. Planar Five Color Theorem 3. Special Graphs:

CS612 Algorithms for Electronic Design Automation

CSE101: Design and Analysis of Algorithms. Ragesh Jaiswal, CSE, UCSD

Exam 3 Practice Problems

HANDSHAKING AND CHASING KIDS

List Coloring Graphs

CS2 Algorithms and Data Structures Note 10. Depth-First Search and Topological Sorting

ECS 20 Lecture 17b = Discussion D8 Fall Nov 2013 Phil Rogaway

15-451/651: Design & Analysis of Algorithms November 4, 2015 Lecture #18 last changed: November 22, 2015

W4231: Analysis of Algorithms

Ma/CS 6b Class 5: Graph Connectivity

Notebook Assignments

Solutions to Quiz 1. (a) (3 points) Vertices x and y are in the same connected component. Solution. P (x, y)

Name: Lirong TAN 1. (15 pts) (a) Define what is a shortest s-t path in a weighted, connected graph G.

CHAPTER 3. Register allocation

CS103 Handout 13 Fall 2012 May 4, 2012 Problem Set 5

2. CONNECTIVITY Connectivity

Transcription:

Graph Coloring Margaret M. Fleck 3 May 2010 This lecture discusses the graph coloring problem (section 9.8 of Rosen). 1 Announcements Makeup quiz last day of classes (at the start of class). Your room for the final exam (Friday the 7th, 7-10pm) is based on the first letter of your last name: A-H Roger Adams Lab 116 I-W Business Instructional Facility (515 E. Gregory opposite Armory) 1001 X-Z Roger Adams Lab 116 The conflict exam (Monday the 10th, 1:30-4:30pm) is in 269 Everett Lab. 2 The problem We re only going to talk about simple undirected graphs. Remember that two vertices are adjacent if they are directly connected by an edge. 1

A coloring of a graph G assigns a color to each vertex of G, with the restriction that two adjacent vertices never have the same color. The chromatic number of G, written χ(g), is the smallest number of colors needed to color G. For example, only three colors are required for this graph: R G R G B But K 4 requires 4: R G B Y 3 Computing colorings For certain classes of graphs, we can easily compute the chromatic number. For example, the chromatic number of K n is n, for any n. Notice that we have to argue two separate things to establish that this is its chromatic number: K n can be colored with n colors. K n cannot be colored with less than n colors For K n, both of these facts are fairly obvious. Assigning a different color to each vertex will always result in a well-formed coloring (though it may be 2

a waste of colors). Since each vertex in K n is adjacent to every other vertex, no two can share a color. So fewer than n colors can t possibly work. Similar, the chromatic number for K n,m is 2. We color one side of the graph with one color and the other side with a second color. In general, however, coloring requires exponential time. There s a couple specific versions of the theoretical problem. I could give you a graph and ask you for its chromatic number. Or I could give you a graph and an integer k and ask whether k colors is enough to be able to color G. These problems are all NP-complete or NP-hard. That is, they apparently require exponential time to compute, even though in some cases it s easy to check that their output is correct. (They are exponential if the P and NP classes of algorithms are actually different, which is one of the big outstanding problems in computer science.) So, except for small examples and special cases, coloring problems can t be solved exactly. 4 Why should I care? However, graph coloring is required for solving a wide range of practical problems. For example, there is a coloring algorithm embedded in most compilers. Because the general problem can t be solved efficiently, the implemented algorithms use limitations or approximations of various sorts so that they can run in a reasonable amount of time. For example, suppose that we want to allocate broadcast frequencies to local radio stations. In the corresponding graph problem, each station is a vertex and the frequencies are the colors. Two stations are connected by an edge if they are geographically too close together, so that they would interfere if they used the same frequency. This graph should not be too bad to color in practice, so long as we have a large enough supply of frequencies compared to the numbers of stations clustered near one another. We can model a sudoku puzzle by setting up one vertex for each square. The colors are the 9 numbers, and some are pre-assigned to certain vertices. Two vertices are connected if their squares are in the same block or row or column. The puzzle is solvable if we can 9-color this graph, respecting the pre-assigned colors. 3

Probably the oldest sort of coloring problem is coloring the different countries on a map. In this case, the original map is a graph, in which the regions are the countries. To set up the coloring problem, we need to convert this to the dual graph, where each region is a vertex and two regions are connected by an edge exactly when they share a border. 1 In this case, the graph is planar, which makes coloring much easier to do (see below). We can model exam scheduling as a coloring problem. The exams for two courses should not be put at the same time if there is a student who is in both courses. So we can model this as a graph, in which each course is a vertex and courses are connected by edges if they share students. The question is then whether we can color the graph with k colors, where k is the number of exam times in our schedule. In the exam scheduling problem, we actually expect the answer to be no, because eliminating conflicts would require an excessive number of exam times. So the real practical problem is: how few students do we have to take out of the picture (i.e. give special conflict exams to) in order to be able to solve the coloring problem with a reasonable value for k. We also have the option of splitting a course (i.e. offering a scheduled conflict exam) to simplify the graph. A particularly important use of coloring in computer science is register allocation. A large java or C program contains many named variables. But a computer has a smallish number (e.g. 32) of fast registers which can feed basic operations such as addition. So variables must be allocated to specific registers. The vertices in this coloring problem are variables. The colors are registers. Two variables are connected by an edge if they are in use at the same time and, therefore, cannot share a register. As with the exam scheduling problem, we actually expect the raw coloring problem to fail. The compiler then uses so-called spill operations to break up the dependencies and create a colorable graph. The goal is to use as few spills as possible. 1 Two regions touching at a point are not considered to share a border. 4

5 Planar graphs Planar graphs are an important special case, because they are much easier to color than some other graphs. Way back in 1852, Francis Guthrie hypothesized that any planar graph could be colored with only four colors. This is, in fact, correct, but it took a very long time to prove it. Alfred Kempe thought he had proved it in 1879 and it took 11 years for another mathematician to find an error in his proof. It was finally proved by Kenneth Appel and Wolfgang Haken at UIUC in 1976. They reduced the problem mathematically, but were left with 1936 specific graphs that needed to be checked exhaustively, using a computer program. It s much easier to show that all simple planar graphs can be 6-colored. 6 A fact about degrees Before launching into the proof that any planar graph can be 6-colored, recall from Friday s lecture that if G is a connected simple planar graph with v vertices and e edges, v 3, then e 3v 6. From this, we can deduce that G has a vertex of degree no more than five. Proof: This is clearly true if G has one or two vertices. If G has at least three vertices, we know that e 3v 6. So 2e 6v 12. By the handshaking theorem, 2e is the sum of the degrees of the vertices. Suppose that the degree of each vertex was at least 6. Then we would have 2e 6v. But this contradicts the fact that 2e 6v 12. If our graph G isn t connected, the result still holds, because we can apply our proof to each connected component individually. 5

7 Proof of 6-colorability We can now prove the 6-colorability result, using the fact that every simple graph has a vertex of degree no more than 5. We ll use induction on the number of vertices in the graph. Base: The graph with just one vertex can clearly be 6-colored. Induction: Suppose that all graphs with k vertices can be 6-colored. Let G be a graph with k + 1 vertices. In G, find a vertex v with degree 5. Remove v (and its edges) to create a smaller graph G. G can be 6-colored by the inductive hypothesis. Because v has only 5 neighbors, we can always choose a color for it which will extend this coloring to a coloring of G. I have it on good authority that 5-colorability can be proved without a computer search, but the proof is difficult. The proof of 6-colorability can be generalized to other types of graphs. If a graph G has vertices whose degrees are all D, then G can be colored with D + 1 colors. This limits what G s chromatic number could be, but doesn t pin it down exactly. It might be that D can be colored with fewer colors. For example, W 8 (recall: 8 vertices in a circle, one in the center) can be colored with three colors. Alternate two colors around rim of the wheel, then assign a third color to the central vertex. 8 Greedy coloring This insight motivates a class of good coloring algorithms for practical applications, called greedy coloring algorithms. We take our graph G and remove vertices one-by-one, creating a series of smaller and smaller graphs. The goal is to ensure that each vertex has a low degree when removed. So we remove low-degree vertices first in hopes that this will simplify the graph structure around vertices with high degree. We start by coloring the smallest graph and add the vertices back one-byone, each time extending the coloring to the new vertex. If each vertex has degree d at the point when it s added to the graph, then we can complete the whole coloring with d + 1 colors. 6

This algorithm is quite efficient. Its output might use more colors than the optimal coloring, but it apparently works quite well for problems such as register allocation. 7