CS 3110 Recitation 22
Graph algorithms
Graph coloring algorithms
Given an undirected graph, a graph coloring is an assignment of labels traditionally called "colors" to each
vertex. A graph coloring must have a special property: given two adjacent vertices, i.e., such that there exists
an edge between them, they must not share the same color. The origin of the problem comes from the
problem of coloring a map, where two countries (or states) must have different colors when they are adjacent.
Here is a map of the United States colored with only 4 colors:
Below is a coloring of the Peterson graph using only three colors:
Graph colorings have a number of applications:
•
Scheduling algorithms: imagine having a set of jobs to do, and a number of workers, you need to
assign each worker a job during some time slot (for simplification, assume each job requires one time
slot). Jobs can be scheduled in any order, but pairs of jobs may be in conflict in the sense that they
may not be assigned to the same time slot, for example because they both rely on a shared resource.
The corresponding graph contains a vertex for every job and an edge for every conflicting pair of
jobs. If you have an unlimited number of workers, the chromatic number of the graph is exactly the
optimal time to finish all jobs without conflicts.
•
Register allocation: a compiler is a computer programs that transforms source code from a highlevel
language (such as C, Java or OCaml) to machine code. This is usually done is several steps, and one
of the last steps consists in allocating registers to the most frequently used values of the program,
while putting the other ones in memory. We can model this as a graph coloring problem: the compiler
constructs an interference graph, where vertices are symbolic registers and an edge connects two
nodes if they are needed at the same time. If the graph can be colored with k colors then the variables
can be stored in k registers.
•
This preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
This is the end of the preview.
Sign up
to
access the rest of the document.
 '07
 GIAMBATTISTA,A
 Graph Theory, Graph coloring, PageRanks

Click to edit the document details