rec22 - CS 3110 Recitation 22 Graph algorithms Graph...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
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 high-level 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.
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 10/25/2009 for the course PHYS 2214 at Cornell University (Engineering School).

Page1 / 3

rec22 - CS 3110 Recitation 22 Graph algorithms Graph...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online