# G 2 iff g is a bipartite graph with at least 1 edge c

This preview shows page 1. Sign up to view the full content.

This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: 1/531 Algorithm Analysis and Design 42 / 49 Scheduling All Intervals Four Color Theorem Every planar graph can be colored using at most 4 colors. c Xin He (University at Buffalo) CSE 431/531 Algorithm Analysis and Design 43 / 49 Scheduling All Intervals Four Color Theorem Every planar graph can be colored using at most 4 colors. G is a planar graph if it can by drawn on the plane so that no two edges cross. I2 I1 I5 I4 I7 I8 (a) (b) I3 I6 Both graphs (a) and (b) are planar graphs. The graph (a) has a 3-coloring. The graph (b) requires 4 colors, because all 4 vertices are adjacent to each other, and hence each vertex must have a different color. c Xin He (University at Buffalo) CSE 431/531 Algorithm Analysis and Design 43 / 49 Scheduling All Intervals Interval Graph G = (V, E) is called an interval graph if it can be represented as follows: Each vertex p V represents an interval [bp , fp ). (p, q) E if and only if the two intervals Ip and Iq overlap. c Xin He (University at Buffalo) CSE 431/531 Algorithm Analysis and Design 44 / 49 Scheduling All Intervals Interval Graph G = (V, E) is called an interval graph if it can be represented as follows: Each vertex p V represents an interval [bp , fp ). (p, q) E if and only if the two intervals Ip and Iq overlap. I4 I1 I7 I5 I2 I8 I6 I3 0 1 2 3 4 5 I2 I1 I5 I4 I7 I8 I6 I3 14 15 c Xin He (University at Buffalo) CSE 431/531 Algorithm Analysis and Design 44 / 49 Scheduling All Intervals It is easy to see that the problem of scheduling all intervals is precisely the graph coloring problem for interval graphs. c Xin He (University at Buffalo) CSE 431/531 Algorithm Analysis and Design 45 / 49 Scheduling All Intervals It is easy to see that the problem of scheduling all intervals is precisely the graph coloring problem for interval graphs. We discuss a greedy algorithm for solving this problem. c Xin He (University at Buffalo) CSE 431/531 Algorithm Analysis and Design 45 / 49 Scheduling All Intervals It is easy to see that the problem of scheduling all intervals is precisely the graph coloring problem for interval graphs. We discuss a greedy algorithm for solving this problem. It is not easy to prove the greedy choice property for this greedy strategy. c Xin He (University at Buffalo) CSE 431/531 Algorithm Analysis and Design 45 / 49 Scheduling All Intervals It is easy to see that the problem of scheduling all intervals is precisely the graph coloring problem for interval graphs. We discuss a greedy algorithm for solving this problem. It is not easy to prove the greedy choice property for this greedy strategy. We show the correctness of the algorithm by other methods. c Xin He (University at Buffalo) CSE 431/531 Algorithm Analysis and Design 45 / 49 Scheduling All Intervals It is easy to see that the problem of scheduling all intervals is precisely the graph coloring problem for interval graphs. We discuss a greedy algorithm for solving this problem. It is not easy to prove the greedy choice property for this greedy strategy. We show the correctness of the algorithm by other methods. We use queues Q1 , Q2 , . . . to hold the subsets of intervals. (You can think that each Qi is a CPU, and if an interval Ip = [sp .tp ) is put into Qi , the job p is run on that CPU.) c Xin He (University at Buffalo) CSE 431/531 Algorithm Analysis and Design 45 / 49 Scheduling All Intervals It is easy to see that the problem of scheduling all intervals is precisely the graph coloring problem for interval graphs. We discuss a greedy algorithm for solving this problem. It is not easy to prove the greedy choice property for this greedy strategy. We show the correctness of the algorithm by other methods. We use queues Q1 , Q2 , . . . to hold the subsets of intervals. (You can think that each Qi is a CPU, and if an interval Ip = [sp .tp ) is put into Qi , the job p is run on that CPU.) Initially all queues are empty. c Xin He (University at Buffalo) CSE 431/531 Algorithm Analysis and Design 45 / 49 Scheduling All Intervals It is easy to see that the problem of scheduling all intervals is precisely the graph coloring problem for interval graphs. We discuss a greedy algorithm for solving this problem. It is not easy to prove the greedy choice property for this greedy strategy. We show the correctness of the algorithm by other methods. We use queues Q1 , Q2 , . . . to hold the subsets of intervals. (You can think that each Qi is a CPU, and if an interval Ip = [sp .tp ) is put into Qi , the job p is run on that CPU.) Initially all queues are empty. When we consider an interval [bp , fp ) and a queue Qi , we look at the last interval [bt , ft ) in Qi . If ft bp , we say Qi is available for [bp , fp ). (Meaning: the CPU Qi has finished the last job assigned to it. So it is ready to run the job [bp , fp ).) c Xin He (University at Buffalo) CSE 431/531 Algorithm Analysis and Design 45 / 49 Scheduling All Intervals Greedy-Schedule-All-Intervals 1 2 3 4 5 sort the intervals according to increasing bp value: b1 b2 bn k=0 (k will be the number of queues we need.) for p = 1 to n do: look at Q1 , Q2 , . . . Qk , put [bp , fp ) into the first available Qi . if no current queue is available: increase k by 1; open a new...
View Full Document

## This note was uploaded on 02/27/2012 for the course CSE 431/531 taught by Professor Xinhe during the Fall '11 term at SUNY Buffalo.

Ask a homework question - tutors are online