230 likes | 619 Views
Graph Coloring, Planar Graph and Partial Order. CSC2110 Tutorial 5 Jerry Le jlle@cse.cuhk.edu.hk Rm120, SHB Office hour: Thu 3pm-5:30pm Oct 18 2007. Outline. Quick Review Q & A (questions from classwork2). Quick Review. Graph Coloring - Concept (Chromatic number, x-colorable...)
E N D
Graph Coloring, Planar Graph and Partial Order CSC2110 Tutorial 5 Jerry Le jlle@cse.cuhk.edu.hk Rm120, SHB Office hour: Thu 3pm-5:30pm Oct 18 2007
Outline • Quick Review • Q & A (questions from classwork2)
Quick Review • Graph Coloring - Concept (Chromatic number, x-colorable...) - Applications(Map coloring, Server upgrading, Register allocation...) • Planar Graph - Concept (Planar embedding, Discrete faces) - Important Theorems (Euler’s formula, 6-color theorem) • Partial order - Definition (antichain, chain, directed graph) - Properties (Transitive, Asymmetric) - Important Theorems (Dilworth’s Theorem) - Applications (Parallel task scheduling, Monotone sequences...)
True or False (Graph coloring) 1. A bipartite graph is 2-colorable. - True, put one color in one side, another color in the other 2. A 2-colorable graph is a bipartite graph. - True 3. A tree is 2-colorable. - True, because it has no cycles. 4. A 2-colorable graph is a tree. - False, it may not be connected, or may have cycles. 5. We have a k+1 vertex coloring for each graph with maximum degree k, and this coloring is optimal. - False, consider this
True or False (Planar graph) 1. Any connected graph has a planar embedding. - False, need to be planar graph... 2. Any graph of 5 vertices is a planar graph. - False, one counterexample is K5 3. Every simple planar graph is 6-colorable. - True. 4. The vertex degree of each simple planar graph is at most 5. - False, but we at least have one vertex of degree at most 5
True or False (Partial order) 1. “≤” can represent a partial order. - True, transitive and asymmetric 2. The subset relation “ ” can represent a partial order - True, check it out. 3. Let directed graph D represent a partial order, then D has no cycles. - True, otherwise the order is not asymmetric. 4. There are n elements in a partial order, and the length of the critical path (i.e. longest chain) is less than t, then there is an antichain of size at least n/t. - True, Dilworth’s theorem 5. Every partial ordering on a non-empty finite set has a minimal element. - True
Vertex coloring Let G be a graph. Which of the following statements are equivalent to each other? 1. G contains no odd-length cycles. 2. G is bipartite. 3. G is 2-colorable. 4. The maximum vertex degree of G is 1. 1,2,3 are equivalent.
Vertex coloring Find out the chromatic number of the following graphs.
Vertex coloring Find out the chromatic number of the following graphs.
Application of Vertex Coloring: Register Allocation (Long Question Q5.) When a computer performs calculations, the values of variables are stored in the memory. Register is a type memory that is very fast but also very expensive. Therefore, we want to use registers as efficiently as possible. Suppose we need to do the following calculation: Of course we can allocate a unique register for each variable, but that is not efficient enough... For example, b and d can use the same register, because we don’t need b anymore after the 1st step.
Application of Vertex Coloring: Register Allocation (Long Question Q5.) Suppose we need to do the following calculation: Of course we can allocate a unique register for each variable, but that is not efficient enough... For example, b and d can use the same register, because we don’t need b anymore after the 1st step. But we do need to let some variables use separate register, for example, a and b in the first step, c and d, etc.
Application of Vertex Coloring: Register Allocation (Long Question Q5.) Suppose we need to do the following calculation: a) Try to construct a graph to help you decide to use how many registers in total. Basically you need to decide: what do the variables represent? Under what condition should there be an edge between two vertices.
Application of Vertex Coloring: Register Allocation (Long Question Q5.) Suppose we need to do the following calculation: Generally, we operate each variable in two ways: “use” and “assignment” For example, c=a+b, we are “using” a and b, and we are “assigning” c an value. We call the interval between the first assignment (or input) and last use (or output) of a variable as its “lifetime” Two variables can not be assigned the same register if their lifetimes overlap!
Application of Vertex Coloring: Register Allocation (Long Question Q5.) Suppose we need to do the following calculation: Each vertex represents a variable, and we add an edge between two vertices iff their lifetimes overlap.
Application of Vertex Coloring: Register Allocation (Long Question Q5.) Suppose we need to do the following calculation: Find a vertex coloring of this graph, we need at least 4 colors (registers).
Vertex Coloring and Planar Graph (Long Question Q6.) 1. Prove that every triangle-free connected planar graph has a vertex of degree at most 3. 2. Prove that every triangle-free connected planar graph is 4-colorable. For triangle-free graph, every face is bounded by at least 4 edges, we have 4f ≤ 2e Using Euler’s theoremv-e+f=2, we have e ≤ 2v-4 If all vertices are of degree at least 4, then we have 4v ≤ 2e e ≤ e-4, contradiction! We proved the first statement.
Vertex Coloring and Planar Graph (Long Question Q6.) 1. Prove that every triangle-free connected planar graph has a vertex of degree at most 3. 2. Prove that every triangle-free connected planar graph is 4-colorable. Using result from the first statement 1, we can easily prove the second one, by adopting the same technique of proving “6-color theorem” (check it in the lecture notes).
Application of Dilworth’s theorem (Long Question Q7.) We are given a real number sequence Prove that the sequence must contain a monotone subsequence of length n+1. Define (i, ai) as the element in the partial order We say (i, ai) ≤ (j, aj) if i ≤ j and ai ≤ aj Now we have a partial order on the set {(i, ai)}
Application of Dilworth’s theorem (Long Question Q7.) We are given a real number sequence Prove that the sequence must contain a monotone subsequence of length n+1. A chain in our partial order is a monotone increasing subsequence An antichain in our partial order is a monotone decreasing subsequence Using Dilworth’s theorem, we are done!