Download - Graph Coloring

Transcript
Page 1: Graph Coloring

Graph Coloring 1March 2014

Graph Coloringprepared and Instructed by

Shmuel WimerEng. Faculty, Bar-Ilan University

Page 2: Graph Coloring

Graph Coloring 2

Vertex Coloring

March 2014

A k-coloring of a graph G is a labeling f : V(G) → { 1,…,k }.

A coloring is proper if no two vertices x and y, connected with an edge have same color, xy ϵ E(G) => f(x) ≠ f(y).

G is k-colorable if it has proper k-coloring.

The chromatic number χ(G) is the smallest k such that G has proper k-coloring. G is called k-chromatic.

If χ(G) = k, but χ(H) < k for every proper subgraph H, then G is k-critical.

Page 3: Graph Coloring

Graph Coloring 3March 2014

The vertices having same color in a proper k-coloring must be independent. Therefore, χ(G) is the minimum number of independent sets covering G.Hence, G is k-colorable iff G is k-partite.

Examples. Every bipartite graph is 2-colorable.Every even cycle graph is 2-colorable (it is bipartite).Every odd cycle graph is 3-colorable and 3-critical.2-colorability can be tested with BFS. (How?)

We compute the distance from a vertex u. A connected graph is bipartite iff G[X] and G[Y] are independent sets, where X and Y are vertices of even and odd distance from u, respectively.

Page 4: Graph Coloring

Graph Coloring 4March 2014

The largest clique size ω(G) satisfies χ(G) ≥ ω(G).

The largest independent set size α(G) satisfies χ, since every color class is an independent set, therefore having at most vertices.

Is χ(G) > ω(G) possible?

Ks

Yes, χ(G) may exceed ω(G)!

Proper coloring of Ks requites s colors. , but χ Hence χ(G) > ω(G).

ss

ss sC5

Could it be constructed with C3 rather than C5?

Page 5: Graph Coloring

Graph Coloring 5March 2014

Example. Minimizing exam period in school. How to schedule exams in as few parallel sessions as possible, where now two concurrent exams have a common student?

Define , where corresponds to a course, and iff courses and have a common student. Then an independent set of vertices implies a parallel exam session, and χ(G) is the smallest number of parallel sessions.

Example. Chemical storage. different chemicals, of which the interaction between some pairs is explosive, should be stored. What is the smallest required number of compartments in the storage? χ(G).

Page 6: Graph Coloring

Graph Coloring 6

Upper Bounds of Chromatic Number

March 2014

Easy bounds are χ(G) ≤ n(G), χ(G) ≥ ω(G), and , all hold with equality for cliques. Better than χ(G) ≤ n(G) upper bounds can be obtained by coloring algorithms.

A greedy algorithm w.r.t V(G) order v1,…,vn , assigns to vi

the smallest color index not incident so far to vi. Proposition. There is χ(G) ≤ ∆(G) + 1. (∆(G) is the largest vertex degree.) Proof. By construction. A vertex has no more than ∆(G) neighbors. Upon vi coloring there must be at least one of 1,…, ∆(G)+1 colors unused. ■

Page 7: Graph Coloring

Graph Coloring 7March 2014

Different orderings may yield smaller upper bounds. Finding the best ordering is hard. Is there an ordering yielding χ(G)? It can be shown that such one exists.Example. Register allocation and interval graphs.Consider the registers used by a compiler, each has start and end time. What is the smallest number of physical registers that can be used? Assign the symbols a, b, c, … to the registers in the code, and draw their usage time intervals.

ab

cd e

f

gProposition. If G is an interval graph then χ(G) = ω(G).

Page 8: Graph Coloring

Graph Coloring 8March 2014

Proof. By left-to-right traversal of the time intervals, pre sorted by their starting time. Initializing k=0. Increasing to k+1 at starting point and decreasing to k-1 at ending point. ■The bound χ(G) ≤ ∆(G)+1 may still be very poor.

For (n+1)-vertex star graph ∆(G) = n, whereas χ(G) = 2.For (n+1)-vertex wheel graph ∆(G) = n, whereas χ(G) ≤ 4.

Page 9: Graph Coloring

Graph Coloring 9March 2014

The bound χ(G) ≤ ∆(G)+1 can be further improved by considering the vertices with high degree first.

Proposition. (Welsh-Powell 1967) If the vertices are ordered in non increasing degree, d1 ≥ d2 ≥ … dn, then .

Proof. When vertex i is colored, at most min { di , i-1 } of its neighbors have already been colored. Its color is therefore 1 + min{ di , i-1 }. Maximization over i yields the upper bound. ■

Page 10: Graph Coloring

Graph Coloring 10March 2014

Lemma. If H is k-critical graph, then δ(H) ≥ k-1.

Proof. Assume in contrary that δ(H) < k-1. Let x ϵ H be a vertex for which dH(x) < k-1.

We managed to properly color H with k-1 colors, which contradicts with H being k-critical graph (. ■

Since H is k-critical, H-x is by definition (k-1)-colorable, so let us use any k-1 colors to properly color H-x.

Since dH(x) < k-1, N(x) consume k-2 colors at most. Let us color x by one of the k-1 not consume by N(x).

The minimum degree δ(G) in G can also be used to deduce upper bounds.

Page 11: Graph Coloring

Graph Coloring 11March 2014

Corollary. (Szekeres-Wilf 1968) .

Proof. Let χ() and be a -critical subgraph of .

By the above lemma

There is also, yielding the desired bound. ■

Page 12: Graph Coloring

Graph Coloring 12

Coloring of Directed Graphs

March 2014

Theorem. Let a graph G be directed with longest path l(G), then . Furthermore, there are orientations of G’s edges such that equality holds.

Proof. Let G’ be a maximal acyclic sub digraph of G (not necessarily a tree).

G G’

G’ must have some vertices with outgoing arcs only.

Page 13: Graph Coloring

Graph Coloring 13March 2014

Define f(v) to be a coloring function assigning color 1+l(v) to vertex v.f is strictly increasing along a path in G’ using colors 1+l(G’) on V(G) = V(G’). For each edge uv ϵ E(G) there exists a path in G’ between u and v, since either there was uv ϵ E(G’) or the edge is closing a cycle of G.

G G’1

1

2

3

4

5

6

Page 14: Graph Coloring

Graph Coloring 14March 2014

That implies f(u) ≠ f(v) since f increases along paths of G’.Consequently, f is a proper coloring and χ(G) ≤ 1 + l(G).

To prove the existence of an orientations of G’s edges satisfying χ(G) = 1 + l(G), an orientation satisfying χ(G) ≥ 1 + l(G) is shown.

Each edge uv ϵ E(G*) is oriented u → v iff f(u) < f(v). Since f is a proper coloring, this defines an orientation.

Let f be an optimal coloring satisfying f(G) = χ(G). We derive a digraph G* as follows.

Page 15: Graph Coloring

Graph Coloring 15March 2014

Since the color labels along paths in G* strictly increase, and there are only χ(G) labels, there is l(G*) ≤ χ(G*) – 1, hence χ(G*) = 1 + l(G*). ■

1 2

34

G G*

Page 16: Graph Coloring

Graph Coloring 16

Brook’s Theorem

March 2014

The bound holds for any graph.

Brook showed that cliques and odd cycles are essentially the only graphs where holds.

Theorem. (Brook 1941) If is connected and other than a clique or an odd cycle, then .

Proof. Let have nodes and be connected, neither a clique, nor an odd cycle.

Let and assume , as otherwise for it is a clique, and bipartite or an odd cycle for .

Page 17: Graph Coloring

Graph Coloring 17March 2014

Consider first the case where is not k-regular.

Choose a vertex for which and grow a spanning tree rooted at (by any search, e.g. BSF).

Index the vertices in decreasing order as they are being reached by the search, yielding the order .

Each vertex other than has a higher-indexed neighbor along its path to root, hence it has at most lower-indexed neighbors.

Using the greedy coloring with the vertex decreasing order obtains proper -coloring.

Page 18: Graph Coloring

Graph Coloring 18March 2014

In the remaining cases G is -regular. 3 cases possible.

1st case: is 1-connected. Let be a cut-vertex.

𝑮 ′ 𝑮𝑥

Let be a component of together with .

The degree of in is less than and a proper -coloring is possible.

Page 19: Graph Coloring

Graph Coloring 19March 2014

That can repeat for every components of , yielding -proper coloring for each ( included).By permuting colors of the subgraphs, we can make the colorings agree on , yielding -proper coloring of .

Find a vertex with two non adjacent neighbors and (why such exist?) whose deletion leaves a connected subgraph (otherwise G was 2-conncted).

𝑣𝑛

𝑣1 𝑣2

2nd case: G is not 2-connected.

Page 20: Graph Coloring

Graph Coloring 20March 2014

is connected and a spanning tree rooted at can be constructed (e.g. BFS).

The labels are assigned to the vertices in decreasing order as they are reached. Starting coloring from and , they use same color.

Each vertex other than has then at most lower-indexed neighbors so colors can be used for those.

All in all, proper coloring of has been obtained.

has neighbors, of which and already used the same

color. The rest neighbors used at most other colors, and can therefore be properly colored.

Page 21: Graph Coloring

Graph Coloring 21

𝑥=𝑣𝑛

March 2014

3rd case: G is 2-connected. Choose a vertex such that vertex connectivity .

That is possible by choosing to be one of the two disconnecting vertices.

has a neighbor in every block of obtained by deleting the 2nd vertex in a cut-set, otherwise was 1-connected rather than 2-connected.

𝑣1 𝑣2

Page 22: Graph Coloring

Graph Coloring 22March 2014

There is no edge connecting and since they reside in different blocks.

is connected since blocks have no cut-vertices and are not such.

implies is also connected.

All in all this is the same situation as the case of not 2-connected. ■Brook’s Theorem implies that the cliques and the odd cycles are the only -regular -critical graphs. (Homework)

Page 23: Graph Coloring

Graph Coloring 23

Chromatic Polynomials

March 2014

We shall associate with any graph a function telling whether or not it is 4-colorable.

This study was motivated by the hope to prove the Four-Color Theorem, which by that time was a conjecture.

Let denote the number of proper colorings of a graph with colors. is called the chromatic function of .

Example. . The first vertex can be colored in ways, while each of the other two in ways.

Page 24: Graph Coloring

Graph Coloring 24March 2014

For there is and for there is .

If then . For there is .

The Four-Color Theorem for planar graph states that .

It is difficult to compute by inspection, but it can be systematically obtained as a sum of chromatic functions of complete graphs.

For a tree of vertices there is .

Page 25: Graph Coloring

Graph Coloring 25March 2014

Theorem. Let be not incident, and let be obtained by adding the edge to , and be obtained by identifying and in . Then .

𝑢𝑣

𝑘 (𝑘−1 ) (𝑘−2 )

𝐺2

𝑢 𝑣𝐺

𝑘 (𝑘−1 ) (𝑘−2 )2

¿𝑢 𝑣𝐺1

𝑘 (𝑘−1 ) (𝑘−2 ) (𝑘−3 )+¿

Page 26: Graph Coloring

Graph Coloring 26March 2014 26

Proof. In a proper coloring of , and may have either the same color or different colors.The number of proper colorings where and have different colors does not change if an edge would exist, yielding .

Similarly, the number of proper colorings where and have same color does not change if an and are merged, yielding . ■Corollary. The chromatic function is a polynomial.

Proof. The procedure of the theorem results in two graphs. In the number of edges is increased. In the number of vertices is decreased.

Page 27: Graph Coloring

Graph Coloring 27March 2014

The process is finite. It ends with producing complete graphs, whose chromatic functions are polynomial.The chromatic function is therefore a finite sum of polynomials, which must be polynomial too. ■

For -vertex graph the degree of is , the coefficient of is 1 and that of is , the sign of the coefficients is alternating, and the free coefficient is zero. (Homework).

Example. Scheduling feasibility. Lectures scheduling is in order, for which some time slots are given (e.g. campus is open). There is no limit on available rooms.

Page 28: Graph Coloring

Graph Coloring 28March 2014

It is known that some lectures cannot take place in parallel (e.g. some students are registered to both).

Is scheduling feasible? How many schedules there are?

Solution. Define a graph where corresponds to a lecture, and corresponds to lectures that cannot be scheduled simultaneously.

Derive the chromatic polynomial , where is the number of time slots.

Given , valuation of yields the number of distinct schedules. indicated non existence of feasible scheduling. ■

Page 29: Graph Coloring

Graph Coloring 29March 2014

𝑃𝐺 (𝑘 )=𝒌𝟓−𝟕𝒌𝟒+𝑎𝑘3−𝑏𝑘2+𝑐𝑘Example.

= +

= + + +

Page 30: Graph Coloring

Graph Coloring 30March 2014

= + + +2

𝑃𝐺 (𝑘 )=𝑘 (𝑘−1 ) (𝑘−2 ) (𝑘−3 ) (𝑘−4 )+3𝑘 (𝑘−1 ) (𝑘−2 ) (𝑘−3 )+2𝑘 (𝑘−1 ) (𝑘−2 )=𝑘5−7𝑘4+19𝑘3−23𝑘2+10𝑘

Page 31: Graph Coloring

Graph Coloring 31

Edge Coloring

March 2014

Edge coloring partitions into sets (some possibly empty) .

A -edge-coloring of a graph is a labeling .

An edge coloring is proper if adjacent edges have different colors. All coloring henceforth are assumed proper.

Page 32: Graph Coloring

Graph Coloring 32March 2014

Edge coloring thus partitions into sets of matchings. (Only loopless graphs admit proper edge coloring).

is k-edge-colorable if it has -edge-coloring.

The edge chromatic number is the smallest such that has -edge-coloring. is called -edge-chromatic.

Clearly, .

Clearly, is -edge-colorable, where .

Not 3-edge-colorable, hence .

Page 33: Graph Coloring

Graph Coloring 33March 2014

Example. Timetabling. teachers …, and classes …, are given. Teacher is required to teach class a lessen of period . Schedule a complete timetable having minimum total duration.

Solution. The scheduling is represented by a bipartite graph , , vertices and are connected with parallel edges.The minimum number of colors required for edge-coloring ensures minimum duration.• No schedule overlap for a teacher.• No lesson overlap for a class.• No two lesson schedules overlap in a class. ■

Page 34: Graph Coloring

Graph Coloring 34March 2014

Homework. 1. Show that a -regular graph is -edge colorable iff can

be partitioned into perfect matchings.2. Show by an appropriate edge coloring that .3. Given graph , , , show that .4. Eight schoolgirls go for a walk in pairs every day. Can

they arrange their outgoing so that every girl has a different companion at every day of the week?

Page 35: Graph Coloring

Graph Coloring 35

Edge Coloring of Bipartite Graphs

March 2014

Let the subgraph span (), and be a -edge-coloring of .

A color is available for an edge if it is available in its two end vertices.

If is uncolored, any of its available colors can be assigned to extend to a -edge-coloring of .

For , each component of is either an even cycle or a path (called -path). (why?)

Theorem. If is bipartite then .

Page 36: Graph Coloring

Graph Coloring 36March 2014

Proof. By induction on . Let . Assume that has a .

If a color is available for we are done. Otherwise, each of the colors is represented either at or at .

Since the degrees of and in are at most, there are colors , where is available at and exists in , and is available at and exists in .

Consider the subgraph . Because has a degree one in , the component containing is an -path .

Page 37: Graph Coloring

Graph Coloring 37March 2014

cannot terminate at . If it did, it would started from with color and end at with color , hence comprising even number of edges. would then be an odd cycle in , impossible for a bipartite graph.Interchanging the colors of , a new -edge-colorable is obtained, where color is available at both and .Assigning color to obtains a -edge-coloring of . ■

𝑢

𝑣

𝑃𝑒𝑢

𝑣

𝑃𝑒

Page 38: Graph Coloring

Graph Coloring 38March 2014

Clearly, , and for bipartite graphs there is .

What can be said about an upper bound? Surprisingly, it is very tight.

Theorem. (Vizing 1964, Gupta 1966). Let be a simple graph (no parallel edges, loopless). Then

Proof. Let be a proper subgraph of , edge-colored with colors, but could not be colored. We present a recoloring procedure to include .

Upper Bound of Edge Chromatic Number

Page 39: Graph Coloring

Graph Coloring 39March 2014

Since more than colors are used, every vertex has a missing color.

Let be missing at and be missing at . ( must be presented at and at .)

𝑢𝑣

𝑢𝑣𝑣1

Let be a neighbor of such that is colored . Some color must be missing at since colors are used.

Page 40: Graph Coloring

Graph Coloring 40March 2014

Suppose does not appear on . We could recolor with , free from , and then color with .

𝑢𝑣𝑣1

So we suppose that appears on .

The process continues for .

𝑢𝑣𝑣1

Finding a new color that appears at , let be the neighbor of such that the edge is colored .

Page 41: Graph Coloring

Graph Coloring 41March 2014

At some color must be missing.

𝑢

𝑣𝑣1𝑣2

𝑣 𝑖

𝒂𝒊+𝟏 𝑢

𝑣𝑣1𝑣2

𝑣 𝑖

𝒂𝒊+𝟏 𝑢

𝑣𝑣1𝑣2

𝑣 𝑖𝒂𝒊+𝟏

If is missing at , we downshift color from to for ().

We are finished, unless appears at , in which case the process continues to and a color . There are only colors, hence the repetitive selection of must eventually repeat a color.

Page 42: Graph Coloring

Graph Coloring 42March 2014

Let be the shortest non repetitive color list such that is missing at and repeats one of .

Let for some . This color is missing at and appears on .

If is missing , we use on and downshift colors from and to complete the augmentation.

𝑢𝑣

𝑣1𝑣2

𝑣𝑘−1

𝑣𝑘

𝑣 𝑙

Page 43: Graph Coloring

Graph Coloring 43March 2014

Hence we assume that appears at and does not.

Let be the longest alternating path of edges colored and that begins at (with ). is unique. (why?)

P

𝑢𝑣

𝑣1𝑣2

𝑣𝑘−1

𝑣𝑘

𝑣 𝑙

Depending on the opposite end of , recoloring can take place to complete the augmentation. There are three possibilities of end: at , at , and elsewhere.

Page 44: Graph Coloring

Graph Coloring 44March 2014

If ends at , it is with since is presented at and is colored with . Downshifting colors from , interchanging colors along , and coloring with , completes the edge coloring augmentation.

𝑢𝑣

𝑣1𝑣2

𝑣𝑘−1

𝑣𝑘

𝑣 𝑙

𝑎𝑘

𝑎0𝑎0

𝑎𝑘

𝑢𝑣

𝑣1𝑣2

𝑣𝑘−1

𝑣𝑘

𝑣 𝑙

𝑎0

𝑎𝑘

𝑎𝑘

𝑎0𝑎𝑘

Page 45: Graph Coloring

Graph Coloring 45March 2014

If ends at , it is with since since is presented at and is missing from . Downshifting from , interchanging colors along , and coloring with , completes the edge coloring augmentation.

𝑢𝑣

𝑣1𝑣2

𝑣𝑘−1

𝑣𝑘

𝑣 𝑙𝑎𝑘

𝑎𝑘

𝑎0𝑎0

𝑢𝑣

𝑣1𝑣2

𝑣𝑘−1

𝑣𝑘

𝑣 𝑙𝑎𝑘

𝑎0

𝑎𝑘𝑎𝑘

Page 46: Graph Coloring

Graph Coloring 46March 2014

Finally, suppose that neither ends at nor , so it ends at some vertex outside

𝑢𝑣

𝑣1𝑣2

𝑣𝑘−1

𝑣𝑘

𝑣 𝑙𝑎𝑘𝑎𝑘

𝑎𝑘

𝑎0𝑎0

ends with either of or colored edge, so either of or is missing from the far end of , as otherwise it would not be longest.

Page 47: Graph Coloring

Graph Coloring 47March 2014

Notice that the vertices along can also touch any of , since has been assumed as being presented at those (otherwise coloring downshift had been possible).

We downshift from , assign color to , and interchange colors along . ■

𝑢𝑣

𝑣1𝑣2

𝑣𝑘−1

𝑣𝑘

𝑣 𝑙𝑎𝑘𝑎0

𝑎0𝑎𝑘

𝑎𝑘

Page 48: Graph Coloring

Graph Coloring 48

Line Graphs

March 2014

Many questions about vertices have natural analogues involving edges.

Definition. The line graph is defined by and if and , where .

Independent sets have no pairs of adjacent vertices; matchings have no adjacent edges.

Vertex coloring partitions the vertices into independent sets; edges can be partitioned into matching.

𝑒 𝑓𝑔h

𝑮

𝑒

𝑓

𝑔

h𝑳 (𝑮 )

𝑢 𝑣

𝑤

𝑧

𝑧𝑤𝑣𝑣𝑣

Page 49: Graph Coloring

Graph Coloring 49

Line Graphs Characterization

March 2014

Theorem. (Krausz 1943) A simple graph is the line graph of some simple graph iff has a partition into cliques using each vertex of at most twice.

Proof. Necessity follows from the fact that the edges adjacent at a vertex of are represented in by vertices connected in a clique.

Since an edge connects two vertices, those vertices imply two cliques at most.

For sufficiency, suppose has such a partition, using cliques. We shall construct H satisfying . Assume that has no isolated varices.

Page 50: Graph Coloring

Graph Coloring 50March 2014

Let be the vertices of that appear in a single clique of (if such one exist). We define a vertex in for each set of .

Edges of are defined such that vertices are adjacent if the corresponding sets (cliques) of intersect.

By its construction, each vertex of G appears in exactly two sets of .

Also, two vertices cannot both appear in two sets of , as otherwise a clique was split among the sets.

Page 51: Graph Coloring

Graph Coloring 51March 2014

Hence there are no parallel edges in , so it is simple, and there is one edge in for each vertex of .

cliqueclique

impossible𝐺=𝐿 (𝐻 )

𝐻=>

Adjacent vertices in appear together in some and the corresponding edges of share the vertex corresponding to . Hence . ■Krausz’s theorem does not directly yield an efficient test for line graph, which the following does.

Page 52: Graph Coloring

Graph Coloring 52March 2014

Theorem. (Bieneke 1968) A simple graph is the line graph of some simple graph iff does not contain any of the following subgraphs as an induced subgraph.