graph coloring - utkweb.eecs.utk.edu/.../coloring_pres.pdf · vertex coloring proper vertex...
TRANSCRIPT
Vertex Coloring● Proper vertex coloring - Labeling of all vertices
in a graph such that no two vertices sharing an edge share the same color
Edge Coloring● Proper coloring of edges - labeling of edges
such that no two edges that share the same vertex share the same color.
Total Coloring● Proper total coloring - Coloring of a graph such
that no adjacent vertices or adjacent edges share the same color.
Brooks’ Theorem● A connected, simple graph’s chromatic
number is no larger than the maximum vertex degree[1]
● Exception: complete and odd cycle graphs[1]
Chromatic Polynomial● Used to count the possible number of ways of
properly vertex coloring a graph.● Example:
P3 can be colored in 12 ways using 3 colors
Chromatic Equivalence Two graphs are chromatically equivalent if they share the same the same chromatic polynomial
History● First presented as a map coloring problem● The problem: Given a planar graph, what is the
minimum number of colors that one can use to color all vertices?
History: 4 vs 5 Coloring● In 1852, Francis Guthrie postulated the four
color conjecture when coloring the counties of England.[2]
● Interestingly, this theorem is not used by map makers.[3]
History: 4 vs 5 ColoringAlfred Kempe followed this up in 1879 by publishing a paper claiming to prove the four color theorem.[2]
11 years later Percy John Heawood showed Kempe was mistaken in his proof but that four colors suffice still held true.[2]
History: 4 vs 5 ColoringThe four color theorem was finally proven in 1976 by Kenneth Appel and Wolfgang Haken[4,5]. (It should be said that this was proof was aided by a computer, so there was some controversy surrounding this proof.)
Greedy Coloring● Given a vertex order, assign each vertex the
first available color● Fast, but potentially poor
Vertex Ordering● Any graph has a vertex ordering for greedy
coloring that yields an optimal coloring● Finding this ordering for arbitrary graphs is
NP-hard
Welsh-Powell Algorithm● Provides an upper-bound on the number of
colors used by greedy coloring[6]
● Order vertices by descending degree
Chordal Graphs● All cycles of 4 or more vertices have a chord● Chord - an edge not in the cycle which
connects 2 of the vertices
Perfect Elimination Ordering
● A graph is chordal iff it has a perfect elimination ordering[7]
● Each vertex and its neighbors which follow it in the order form a clique[7]
● This ordering can be found using lexicographic BFS[7]
Lexicographic BFS1. Begin with all vertices in a single set2. Remove a vertex v from the first set3. Place this vertex at the end of the order4. Divide each set into two subsets: neighbors of v and
non-neighbors of v.5. Repeat 2-4 until all vertices are in the order
Note: if we reverse this ordering, we get a perfect elimination ordering (if one exists)
Brute ForceThe brute force search is highly inefficient as it runs through each possibility of kn where k is the number of colors and n the number of vertices.
Brute Force● The key factor for the inefficiency of the
brute force algorithm is the sheer number of colorings to check.
● Is there a way to reduce the number of colorings?
Brute Force● Number of Colorings Used:
○ C = 1 -> 1 coloring○ 1 < C < V -> ???○ C = V -> 1 coloring
● This is still a huge number of colorings, so it’s still extremely slow!
Brute Force Algorithm● Generate all possible combinations of
‘guarantee’ spots for all C where 1 < C < V○ For each of these combinations, generate all
possible permutations of C colors from 0 to C-1■ For each of the above permutations, generate all
possible combinations of colors in the remaining V-C spots by counting in base C with V-C digits.
Brute Force Algorithm● Test each coloring combination for validity.● If a valid coloring is found, stop generating
possibilities, because the current C is the chromatic number.○ If this is true, what order did I test my colorings in?
Parallel Processing● Performing work on multiple processors at
the same time.● You must divide tasks up such that there
aren’t any dependences between tasks that are running at the same time.○ DMV Analogy○ What are dependences?
Matrix Matrix Multiply● Multiply two matrices
together.● This algorithm is one
of the quintessential parallel programming algorithms.
Matrix Matrix Multiply● The Algorithm:
○ For each row of the left side matrix, multiply the ith element with the ith element of the corresponding column in the right matrix.
○ The sum of these multiplications is put at the [r][c] spot of the result matrix.
for(int r = 0; r < dim; r++) { for(int c = 0; c < dim; c++) { sum = 0; for(int i = 0; i < dim; i++) { sum += matrix[r][i] * matrix[i][c]; } result[r][c] = sum; } }
Parallel Processing Algorithms
● Times are in seconds.
● Sizes are of M by M matrices.
● 4 Hyperthreaded cores were used.
Parallel Brute Force● Used nearly the same algorithm as the serial
version, with the following differences:○ Generate N choices for the ‘guarantee’ spots, where
N is the number of parallel threads.○ Assign each thread to generate the subsequent
possible colorings for these spots and test whether they are valid colorings.
○ Merge all threads and check for completion.
Implementations● Greedy coloring
○ Random vertex ordering○ Welsh-Powell ordering○ Ordering by lexicographic BFS
● Brute force● Parallelized brute force
Results (greedy)Random Welsh-Powell Lex. BFS
random_5_5.txt 3 3 3
random_10_20.txt 4 4 4
random_20_35.txt 4 4 5
random_40_100.txt 5 4 5
random_100_500.txt 6 6 7
random_200_600.txt 6 5 6
random_500_1500.txt 6 6 6
Results (brute force)● Small graphs run quickly,
but the run times grow exponentially.○ Note: Timings are in
seconds.○ The longest runs for each
category took 137.68 and 68.87 minutes respectively.
Results (parallel)● Timings are in
seconds.● All graphs were
cliques.● Speedup less than 1
means parallel is slower.
SudokuA game in which the goal is to create a 9x9 chart where no number shares a column, row or 3x3 square.
Sudoku● Sudoku can be represented as a graph coloring
problem● Transform the board into a graph with 81
vertices where two vertices that shares a column, row or 3x3 square are connected by an edge. Now color using 9 colors.
Register Allocation● At compile time, the compiler allocates registers
to certain variables in a program. Multiple variables can exist in the same register but they cannot be called at the same time, so allocating them becomes a coloring problem.
Scheduling ProblemGraph coloring can be used to find the minimum number of time slots needed to create a schedule with no time conflicts
Example● Finals will be here soon so we’ll use that as our
example.● For each Student list out what classes are being
taken● Student1 {biology, diff. eq, bio stats, graph algo }● Student2 {English lit, journalism, biology, pchem1}● Student3 {bio stats, modern physics, modern physics
lab}
Example continued● Each vertex represents a class and an edge
between vertices represents a student taking both.
So our example becomes….
Example Continued● Now we simply color to determine how many
time slots are required to make sure there are now time conflicts.
The above graph becomes...
Open Problems● Is there a polynomial time algorithm for
checking if a k-coloring for a graph exists?
Open Problems● Erdős-Faber-Lovász Conjecture - the union of n
pairwise edge-disjoint complete graphs with n vertices is n-colorable
References1. Brooks, R.L. On Colouring the Nodes of a Network. Mathematical Proceedings of the
Cambridge Philosophical Society, April 1941.2. Thomas, Robin. The Four Color Theorem. School of Mathematics, Georgia Institute of
Technology. http://people.math.gatech.edu/~thomas/FC/fourcolor.html.3. Wilson, Robin. Four Colors Suffice. London: Penguin Books, 2002.4. Appel, Kenneth and Wolfgang Haken. Every Planar Map is Four Colorable Part I. Discharging.
Illinois Journal of Mathematics, 1977.5. Appel, Kenneth et al. Every Planar Map is Four Colorable Part II. Reducibility. Illinois Journal
of Mathematics, 1977.6. Welsh, D.J.A. and M.B. Powell. An Upper Bound for the Chromatic Number of a Graph and Its
Application to Timetabling Problems. The Computer Journal, 1967.7. Rose, Donald J. et al. Algorithmic Aspects of Vertex Elimination on Graphs. SIAM Journal on
Computing, 1976.8. http://www.math.illinois.edu/~dwest/openp/
Email answers to [email protected].
1. Use the lexicographical BFS algorithm to produce an ordering for the following graph (details on next page):
Homework
0
2
13
5
4 6
HomeworkFor question 1, begin with vertex 6. When breaking ties, select the lowest-numbered vertex. See http://en.wikipedia.org/wiki/Lexicographic_breadth-first_search for more details on the algorithm itself.