L09-discrete math

Embed Size (px)

Citation preview

  • 8/9/2019 L09-discrete math

    1/38

    Graph Colouring

    L09: Oct 10

  • 8/9/2019 L09-discrete math

    2/38

    This Lecture

    Graph coloring is another important problem in graph theory.

    It also has many applications, including the famous !color problem.

    " Graph Colouring

    " #pplications

    " $ome %ositi&e 'esults

  • 8/9/2019 L09-discrete math

    3/38

    Graph Colouring

    Graph Colouring Problem:

    Gi&en a graph, colour all the &ertices so that

    t(o ad)acent &ertices get different colours.

    Objective: use minimum number of colours.

    *!colourable

  • 8/9/2019 L09-discrete math

    4/38

    Optimal Colouring

    +hat graphs ha&e chromatic number one

    (hen there are no edges-

    +hat graphs ha&e chromatic number

    # path # cycle # triangle

    +hat graphs ha&e chromatic number larger than

    Definition. min /colors for G is chromatic number, G 

  • 8/9/2019 L09-discrete math

    5/38

    Simple Cycles

    e&enC 2 χ 

    odd0C   *1 2 χ 

  • 8/9/2019 L09-discrete math

    6/38

    n   n03 1 2 χ 

    Complete Graphs

    # graph is a complete graph if there is an edge bet(een e&ery pair of &ertices.

    $ometimes (e denote a complete graph of n &ertices by 3n.

  • 8/9/2019 L09-discrete math

    7/38

    e&en+ * 2 χ odd0+ 1 2 χ 

    4+

    heels

  • 8/9/2019 L09-discrete math

    8/38

    Trees

    %ic5 any &erte6 as 7root.8

    if uniue path from root is

    e&en length:

    odd length:

    root

    Can pro&e more formally using induction.

  • 8/9/2019 L09-discrete math

    9/38

    !"Colourable Graphs

    +hen e6actly is a graph !colourable

    his is !colourable.

    colourable: tree, e&en cycle, etc.

    ;ot colourable: triangle, odd cycle, etc.

  • 8/9/2019 L09-discrete math

    10/38

    #ipartite Graphs

    +hen e6actly is a graph !colourable

    Is a bipartite graph !colourable

    Is a !colourable graph bipartite

    $act.  # graph is !colourable if and only if it is bipartite.

  • 8/9/2019 L09-discrete math

    11/38

    #ipartite Graphs

    +hen e6actly is a graph bipartite

    Can a bipartite graph has an odd cycle

    If a graph does not ha&e an odd cycle, then it is bipartite

    ;O

  • 8/9/2019 L09-discrete math

    12/38

    #ipartite Graphs

    +hen e6actly is a graph bipartite

    If a graph does not ha&e an odd cycle, then it is bipartite

    1. he idea is li5e colouring atree.

    . %ic5 a &erte6 &, colour it red.

    *. Colour all its neighbour green.

    . Colour all neighbours of green 

    &ertices red

    4. 'epeat until all &ertices are

    coloured.;o such edge because no triangle

    Theorem.  # graph is bipartite if and only if it has no odd cycle.

    ;o such edge because no 4!cycle

  • 8/9/2019 L09-discrete math

    13/38

    Chromatic %umber

    ?$

    Is the con&erse true

    If a graph has no complete subgraph of si=e ,

    then (e can colour it using colours ;O

  • 8/9/2019 L09-discrete math

    14/38

    Chromatic %umber

    Let @G be the largest complete subgraph that G contains.

    G A2 @G

    because (e need at least @G colors to color that complete subgraph.

    hen,

    In general, G could be larger than @G as (e ha&e seen an e6ample.

    ?&en (orse, there are graphs (ith @G2 i.e. no triangles,

    but G could be arbitrarily large e.g. at least one billion.

    $o @G is not a good estimate of the chromatic number G.

  • 8/9/2019 L09-discrete math

    15/38

    or&ing for the 'ing( Ta&e !

    $uppose the 3ing is hiring someone to *!color a graph.

    If you could find a *!coloring of the graph, then you can sho( in to the 3ing.

    But suppose the graph is not *!colorable, ho( can you con&ince the 3ing

    $ometimes, (hen you are luc5y, you can con&ince the 3ing by sho(ing that

    there is a complete subgraph of si=e and so the graph is not *!colourable.

  • 8/9/2019 L09-discrete math

    16/38

    hat)s %e*t+

    ;o one 5no(s ho( to find an optimal coloring efficiently.In fact, this is an ;%!complete problem, and many researchers

    belie&e that such an efficient algorithm does not e6ist C$C *10.

    #lso, no one 5no(s a 7concise8 necessary and sufficient condition for

    5!colorability. $o (hy are (e still studying this problem

    his problem is still interesting for t(o reasons:

    1It captures many seemingly different problems as you (ill see.

    In some important special cases, (e ha&e interesting results, e.g.

    ! (e can !color a map ne6t lecture

    ! in some cases (e can pro&e that G 2 @G this lecture.

  • 8/9/2019 L09-discrete math

    17/38

    This Lecture

    " Graph colouring

    " #pplications

    " $ome %ositi&e 'esults

  • 8/9/2019 L09-discrete math

    18/38

    ,pplication -: $light Gates

    flights need gates, but times o&erlap.

    ho( many gates needed

    1

    14 

    E

    4E

    *0

      99

    Flights

    time

  • 8/9/2019 L09-discrete math

    19/38

  • 8/9/2019 L09-discrete math

    20/38

    4E

    E

    9

    14

    *0

    1

    Graph Colouring

    here is a 5!colouring in this graph iff the flights can be scheduled using 5 gates.

    2A If there is a schedule, the flights scheduled at the same gate ha&e no conflict,

    and so (e can colour the graph by using one colour for flights in each gate.

    2 If there is a graph colouring, then the &ertices using each colour ha&e no conflict,

    and so (e can schedule the flights ha&ing the same colour in one gate.

    /ea: each color

    represents a gate.

  • 8/9/2019 L09-discrete math

    21/38

    4E, E1,14

    99

    *0 colors gates

    assigngates:

    4E

    E

    99

    14

    *0

    1

    Colouring the 0ertices

  • 8/9/2019 L09-discrete math

    22/38

    #etter Colouring

    * colors* gates

    4E

    E

    99

    14

    *0

    1

  • 8/9/2019 L09-discrete math

    23/38

  • 8/9/2019 L09-discrete math

    24/38

    .0

    .001

    1H.0

    *.091

    H.0

    9am

    1pm

    9am

    1pm

    assigntimes:

    time slotsbest possible

    Graph Colouring

  • 8/9/2019 L09-discrete math

    25/38

    ,pplication 2: 3egister ,llocation

    " Gi&en a program, (e (ant to e6ecute it as uic5ly as possible.

    " Calculations can be done most uic5ly if the &alues are stored in registers.

    " But registers are &ery e6pensi&e, and there are only a fe( in a computer.

    " herefore (e need to use the registers efficiently.

    his is a graph colouring problem.

  • 8/9/2019 L09-discrete math

    26/38

    ,pplication 2: 3egister ,llocation

    " ?ach &erte6 is a &ariable.

    " (o &ariables ha&e a conflict if they cannot be put into the same register.

    a and b cannot use the same register, because they store different &alues.

    c and d cannot use the same register other(ise the &alue of c is o&er(ritten.

    ?ach colour corresponds to a register.

  • 8/9/2019 L09-discrete math

    27/38

    4ore about ,pplications

    he e6amples (e ha&e seen are )ust some sample applications of graph coloring.

    he proofs are not &ery formal, but hope you can get the main idea.

    o model a problem as a graph coloring problem, a standard recipe is to thin5

    of your resource e.g. gates, time slots, registers as colors, each ob)ect as a&erte6, and each edge as a conflict.

    hen, using minimum number of colors to color all the nodes is eui&alent to

    using minimum amount of resource for all the ob)ects so that there (ould be

    no conflicts.

  • 8/9/2019 L09-discrete math

    28/38

    This Lecture

    " Graph colouring

    " #pplications

    " $ome %ositi&e 'esults

  • 8/9/2019 L09-discrete math

    29/38

    4a*imum Degree

    $uppose e&ery &erte6 is of degree at most d.

  • 8/9/2019 L09-discrete math

    30/38

    4a*imum Degree

    $act. Gi&en a graph (ith ma6imum degree d,  one can color it using at most dJ1 colors.

    ;ote that it is )ust a sufficient condition, but far from necessary.

    For e6ample, a tree could ha&e large ma6imum degree, but (e cancolor it using only t(o colors.

    Can (e generali=e the follo(ing argument

    7Gi&en an arbitrary ordering of the &ertices,

    (e can color them one by one using at most dJ1 colors.8

    Idea:find a goodordering.

  • 8/9/2019 L09-discrete math

    31/38

    4a*imum Degree Or/ering

    Claim. $uppose there is an ordering of the &ertices &1

    , -, &n

    ,

      such that each &erte6 has at most d neighbors in front.

      hen the graph can be colored by dJ1 colors.

    Proof.  +e color the &ertices one by one follo(ing the ordering.

      +hen (e color &erte6 &i, at most d neighbors of &i are colored.

      $ince (e ha&e dJ1 colors, (e can al(ays color & i using a color

      that has not appeared in its neighbors.

      +e can repeat this argument until e&ery &erte6 is colored.

  • 8/9/2019 L09-discrete math

    32/38

    4a*imum Degree Or/ering

    Claim. $uppose there is an ordering of the &ertices &1, -, &n,  such that each &erte6 has at most d neighbors in front.

      hen the graph can be colored by dJ1 colors.

  • 8/9/2019 L09-discrete math

    33/38

    Goo/ %e5s

    For some special graphs, (e 5no( e6actly (hen they are 5!colorable.

    Inter&al graphs conflict graphs of inter&als:

    a

    b

    c

    d

    a

    b

    c

    d

    For inter&al graphs,

    minimum number of colours need 2 ma6imum si=e of a complete subgraph

    $o the 7flight gate8 problem and the 7register allocation8 can be sol&ed.

  • 8/9/2019 L09-discrete math

    34/38

    nterval Graphs

    Theorem.  For inter&al graph G,

    G 2@G.

    'ecall that @G denotes the largest complete subgraph that G contains,

    and G A2@G because each &erte6 in the complete subgraph needs a

    different color.

    $o, in the follo(ing, (e )ust need to pro&e that G 2@G, by pro&iding

    a coloring using at most @G colors.

    +e (ill do so by sho(ing that there is al(ays a &erte6 (ith degree at

    most @G!1, and thus (e can produce a good ordering as in pre&ious slides.

  • 8/9/2019 L09-discrete math

    35/38

    Lo5 Degree 0erte*

    Lemma.  In an inter&al graph G, there is a &erte6 (ith degree at most 5!1.

    Proof.  Let @G 2 5. +e (ill sho( that there is a &erte6 (ith degree 5!1.

    Let & be the inter&al (ith leftmost right endpoint earliest finishing time.

    #ny inter&al that intersects & must intersect & at the right endpoint,

      as other(ise & is not the inter&al (it leftmost right endpoint.

    $o, all the inter&als that intersect & must intersect (ith each other,

      and thus they form a complete subgraph.

    $ince @G 2 5, this complete subgraph is of si=e at most 5,

      and thus & has at most 5!1 neighbors.

    herefore, & is a &erte6 of degree at most 5!1.

    &

  • 8/9/2019 L09-discrete math

    36/38

    Completing the Proof

    Lemma.  In an inter&al graph G, there is a &erte6 (ith degree at most 5!1.

    Theorem.  For inter&al graph G,

    G 2@G.

    Proof of Theorem. %ic5 a &erte6 guaranteed by the Lemma.  'emo&e this &erte6 and its incident edges from the graph.

      he remaining graph is still an inter&al graph, and is smaller.

      By induction, the remaining graph can be colored by 5 colors.

      $ince & has degree at most 5!1, (e can complete the 5!coloring.

    &

  • 8/9/2019 L09-discrete math

    37/38

    ,n 1*ample

    ;o( (e can sol&e the 7flight gate8 problem and the 7register allocation8 problem.

    Gi&en the flight information

    First (e order the inter&als  by their finishing time.

    1

    *

    4

    E

    H9

    10111

    Color them in re&erse order,use a color not in its neighbors.

    1

    *

    4

    E

    H9

    10111

    sed 4 color, (hich is optimalDsee the dotted line

    can ans(er the 3ing.

  • 8/9/2019 L09-discrete math

    38/38