Approximating the Chromatic of a Graph

NaiWei Lin

Department of Computer Science

University of Arizona The

Tucson AZ

naiweicsarizonaedu

Abstract

The problem of computing the chromatic p olynomial of a graph is Phard This pap er

presents an for computing the chromatic p olynomial of a graph

2 2

n log n nm for a graph with n vertices and m This algorithm has time complexity O

edges This pap er also shows that the problem of computing the chromatic p olynomial

of a can b e solved in p olynomial time Kno wledge ab out the chromatic

p olynomial of graphs can b e employed to improve the p erformance of logic programs and

deductive databases

Intro duction

This pap er considers nite graphs without lo ops ie edges joining a vertex to itself and

multiple edges b etween any pair of vertices The chromatic number of a graph G written as

G is the minimum numb er of colors necessary to color G such that no adjacent vertices have

the same color The chromatic p olynomial of a graph G denoted by C G x is a p olynomial

in x representing the numb er of dierent ways in which G can b e colored by using at most x

colors

The problem of k colorability of a graph G is the one of deciding whether the value

C G k Since the problem of deciding whether the value C G k is NPcomplete

the problem of computing the value C G k is Pcomplete The more general problem

of computing the chromatic p olynomial of a graph is therefore Phard

This pap er presents an approximation algorithm for computing the chromatic p olynomial

of a graph This algorithm is based on the gr eedy metho d We rst determine an ordering

According to the determined ordering we on the vertices of the graph using some heuristics



This work was supp orted in part by the National Science Foundation under grant numb er CCR

next derive an upp er b ound and a lower b ound on how many dierent ways each vertex can

b e colored The pro duct of the upp er b ounds and the pro duct of the lower b ounds for all the

vertices in the graph then give resp ectively an upp er b ound and a lower b ound on the total

the numb er of available colors is numb er of dierent ways the entire graph can b e colored If

given as a symb olic variable then the two pro ducts are p olynomials in this variable Finally

we take a mean of these two p olynomials as an approximation of the chromatic p olynomial of

2 2

for a graph with n vertices n log n nm the graph This algorithm has time complexity O

and m edges

A graph is called chordal if every cycle of length greater than has an edge joining two

nonconsecutive vertices of the cycle Chordal graphs arise in many contexts and contain the

following families of graphs interval graphs cactus graphs adjoint graphs of cactus graphs

and so on Gavril has shown that problems of nding a minimum coloring a minimum

a maximum clique and a maximum indep endent set of a chordal graph covering by cliques

can b e solved in p olynomial time In this pap er we show that the problem of computing

the chromatic p olynomial of a chordal graph can also b e solved in p olynomial time

Man y problems in areas such as op erations research and articial intelligence require enu

merating all the solutions that satisfy a set of binary equality or disequality constraints on

y or variables ranging over a nite domain of values The constraints are of the form x

x y These constraint satisfaction problems can b e reduced to the problem as

h vertex in the graph corresp onds to a variable in the constraints each edge in the follows Eac

graph corresp onds to a disequality constraint and the edges of two vertices are merged if there

each coloring of the is an equality constraint b etween the corresp onding two variables Hence

graph corresp onds to a solution to the original constraint satisfaction problem Accordingly

the asso ciated counting problem for each such constraint satisfaction problem reduces to the

computation of the chromatic p olynomial of its corresp onding graph

in the settings such as This class of constraint satisfaction problems is frequently realized

logic programs and deductive databases where it is easy to generate multiple solutions of a

problem if required The ability to estimate the chromatic p olynomial of a graph allows us

to estimate the numb er of solutions generated by the pro cedures realizing these constraint

satisfaction problems Information ab out the numb er of solutions generated by pro cedures has

b een used to estimate the cost of executing pro cedures and the cost information has b een

further used to optimize programs and queries in these settings For example this information

has b een employed for query optimization in deductive databases by appropriately rearranging

the evaluation order of subgoals and for pro cess granularity control in parallel logic

programming systems by prop erly preventing smallgrain pro cesses from spawning

The remainder of this pap er is organized as follows Section derives a numb er of upp er and

lower b ounds on the chromatic p olynomial of a graph Section discusses how the orderings

presents on the vertices of a graph aect the b ounds on its chromatic p olynomial Section

s

H

A H

H

A H s s

A

A s s

Figure An example

an approximation algorithm for computing the chromatic p olynomial of a graph based on an

ordering prop osed in Section Section shows some exp erimental results on the p erformance

b ehavior of the algorithm Finally Section concludes this pap er

Bounds on Chromatic

Since the value of the chromatic p olynomial C G x is always nonnegative for any graph G

x really means the function and natural numb er x we shall assume that any p olynomial P

maxP x Furthermore for any two p olynomials P x and P x we dene P x P x

1 2 1 2

if and only if maxP x maxP x for all natural numb ers x We shall derive b ounds

1 2

on the chromatic p olynomial of a graph based on the greedy metho d

Let G V E b e a graph The order of G denoted by jGj is the numb er of vertices

in G Let U b e a subset of V The subgraph of G induced by U is a graph H U F

such that F consists of all the edges in E b oth of whose vertices b elong to U The neighbors

v fw V jv w E g of a vertex v in G is the set of vertices adjacent to v The N

G

v of v is the subgraph of G induced by N v adjacency graph Adj

G G

Let G V E b e a graph of order n and v v b e an ordering on V We

1 n

dene two sequences of subgraphs of G according to The rst is a sequence of subgraphs

G G called accumulating subgraphs where G is the subgraph induced by

1 n i

0 0

G V fv v g for i n The second is a sequence of subgraphs G

i 1 i

2 n

0

called interfacing subgraphs where G is the adjacency graph Adj v for i n

i

( ) G

i

1 i

For example consider the graph shown in Figure The imp osed ordering is denoted by the

lab els of vertices The corresp onding accumulating subgraphs and interfacing subgraphs are

shown in Figure

The following prop osition gives an upp er b ound and a lower b ound on the chromatic p oly

nomial of a graph in terms of resp ectively the chromatic numb er and the order of interfacing

subgraphs

i

s s s s

accumulating

H

s s A s A A H s

subgraphs

s s s As s As A s

G

i

s s s

interfacing

s

subgraphs

s s s

0

G

i

Figure The accumulating and interfacing subgraphs of the graph in Figure

Prop osition Let G V E be a graph of order n and be the set of al l possible order

ings on V Suppose the interfacing subgraphs of G corresponding to an ordering are

0 0

G G Then

n

2

n n

Y Y

0 0

x G g max fx x jG jg C G x min fx

2 2

i i

i=2 i=2

Pro of Supp ose G G are the accumulating subgraphs of G corresp onding to an

1 n

ordering The pro of is by induction on G for j n In base case G is a graph

j 1

Q

j

0

consisting of one vertex v so C G x x Supp ose x j C G x x jG

1 1 j

i

i=2

Q

j

0

and for some j j n Then consider adding the vertex v x G x

j +1

i i=2

0

asso ciated edges into G to form G For the lower b ound since jG j is the

j j +1

j +1

0

degree of v in G we have x jG j C G x C G x From the

j +1 j +1 j j +1

j +1

hyp othsis we obtain

j +1

Y

0 0

x x jG j x jG j C G x C G x

j j +1

i j +1

i=2

0

For the upp er b ound since G is the minimum numb er of colors necessary for coloring

j +1

0 0

G we have C G x x G C G x From the hyp othsis we

j +1 j

j +1 j +1

obtain

j +1

Y

0 0

C G x x G x G C G x x

j +1 j

j +1 i

i=2

Since G G we have the following formula

n

n n

Y Y

0 0

x G x jG j C G x x x

i i

i=2 i=2

Finally b ecause Formula holds for any ordering Formula follows 2

The upp er b ound in Formula is in terms of the chromatic numb er of interfacing sub

graphs Unfortunately the computation of the chromatic numb er of a graph is NPcomplete

Nevertheless it turns out that if each of the chromatic numb ers in Formula is replaced

by any of its lower b ounds the resultant expression is still an upp er b ound on the chromatic

gives a lower b ound on the chromatic numb er p olynomial The following theorem by Bondy

of a graph that can b e computed eciently

Theorem Let G be a graph of order n d dn be the degrees of nodes in G

be dene and d recursively by

j

1 j

X

n d

j i

i=1

Suppose k n is some integer satisfying

1 k

X

n

j

j =1

Then G k 2

We dene G called the Bondy number of a graph G to b e the largest integer k n

satisfying Formula Then an upp er b ound on the chromatic p olynomial of a graph can b e

expressed in terms of the Bondy numb er of interfacing subgraphs

Prop osition Let G V E be a graph of order n and be the set of al l possible order

ings on V Suppose the interfacing subgraphs of G corresponding to an ordering are

0 0

G G Then

n

2

n n

Y Y

0 0

x G g jg C G x min fx x jG max fx

2 2

i i

i=2 i=2

Pro of By Theorem and an argument parallel to the upp er b ound argument of Prop osition

2

Ordering of Vertices

It is clear that carrying out the computation of the maximum and minimum among all the

p ossible orderings in Formula is impractical As a result we shall employ a representative

ordering to compute upp er and lower b ounds on the chromatic p olynomial

if every pair of vertices in the graph are adjacent An ordering on A graph is a clique

the vertices of a graph is said to b e a perfect elimination ordering if all the corresp onding

interfacing subgraphs are cliques Dirac and Rose have shown that a graph is chordal

if and only if it has a p erfect elimination ordering The graph in Figure is an example of a

chordal graph and the lab els of vertices show a p erfect elimination ordering The following

prop osition states an app ealing prop erty of p erfect elimination ordering

is a Prop osition Let G V E be a graph of order n and be an ordering on V If

Q Q

n n

0 0

x G j C G x x x jG perfect elimination ordering then x

i i=2 i i=2

Pro of By the fact easily proved that K jK j for any clique K 2

One implication of Prop osition is that if a p erfect elimination ordering of a graph can b e

generated eciently then the chromatic p olynomial of that graph can b e computed eciently

Unfortunately not every graph has a p erfect elimination ordering For example no complete

with n and m is chordal bipartite graph K

nm

We now describ e an ordering that will b e used to compute b ounds on the chromatic p oly

nomials For obvious reasons we shall try to generate a p erfect elimination ordering whenever

it is p ossible The ordering generation is an iterative graph reduction pro cess and the ordering

is generated in reverse order

At each iteration we search for a vertex such that its adjacency graph is a clique If such

a vertex v exists it is chosen as the vertex to generate It is clear that if the graph resulted

from removing v has a p erfect elimination ordering then the original graph containing v also

has a p erfect elimination ordering The latter ordering can b e constructed by simply adding v

at the rear of the former ordering The pro cess continues by removing v from the graph and

pro ceeding to the next iteration

On the other hand if such a vertex v do es not exist then we cho ose a vertex w that

has the smallest degree to generate The basic idea b ehind this heuristic is that to yield

nontrivial lower b ounds for larger numb er of values we demand the maximum order of the

interfacing subgraphs in Formula to b e as small as p ossible Since the ordering generation

is a graph reduction pro cess the degree of vertices or the order of the adjacency graph of

vertices will b ecome smaller when the pro cess go es on Therefore when the generation of

a p erfect elimination ordering cannot continue we greedily cho ose the vertex that has the

smallest degree to generate The pro cess continues by removing the chosen vertex w from the

graph and pro ceeding to the next iteration The whole pro cess terminates when all the vertices

are generated

Notice also that the ordering among the vertices whose adjacency graph is a clique is not

crucial In the pro cess once a vertex has a clique as its adjacency graph its later adjacency

graphs will still remain as cliques This is b ecause the removal of vertices from a clique results

in another clique

Let G V E b e a graph and U b e a subset of V Then the graph G U denotes the

called a perfectsmal lestlast ordering subgraph induced by V U We dene an ordering

0

as follows Let G G b e a sequence of subgraphs of a graph G of order n with

1 n

G V E G and G V E G fv g

1 1 1 i+1 i+1 i+1 i i

v if there is a vertex v V such that

i

v

v is a clique Adj

i

G

i

v g otherwise fd min

G 2V v

i i

for i n then v v Since a p erfectsmallestlast ordering always cho oses a

0 n 1

vertex whose adjacency graph is a clique if such a vertex exists It has the following prop erty

Prop osition If a graph G is chordal then a perfectsmal lestlast ordering on the vertices

of G is a perfect elimination ordering 2

An Approximation Algorithm

We are now ready to present an algorithm for computing an upp er b ound and a lower b ound

on the chromatic p olynomial of a graph based on Formula and the p erfectsmallestlast

ordering The algorithm is shown in Figure Apart from the b ounds this algorithm also

Q

n

0

computes a mean of the b ounds Let L x jG j G x denote the lower b ound x

0

i=2

i

Q

n

0

x G in Formula resp ectively with and U G x denote the upp er b ound x

0

i=2

i

b eing a p erfectsmallestlast ordering on the vertices of G We estimate the chromatic

0

p olynomial of a graph G as

U G x LG x

b

C G x

U G x LG x

b

the harmonic mean of U G x and LG x Notice that although C G x is an estimate of

b

C G x C G x itself may b e a rational function but not a p olynomial

We now consider the complexity of Algorithm CP Let n and m b e resp ectively the numb er

of vertices and edges in the graph We rst consider the test in the if statement Detecting

Algorithm CPG

b egin

G V E G

1 1 1

U G x LG x

for i to n do

if there is a vertex v V such that Adj v is a clique then

i G

i

v v

i

else

v min fd v g

i v 2V G

i i

U G x U G x x G v

i i

LG x LG x x jG v j

i i

G V E G fv g

i+1 i+1 i+1 i i

o d

b

C G x the harmonic mean of U G x and LG x

end

Figure An algorithm for estimating the chromatic p olynomial of a graph

2

if a graph of order k is a clique can b e p erformed in time O k At the worst case when

no adjacency graph is a clique and the detection has to b e p erformed for every vertex the

P P

n n

2 2 2

d v O n m The minimum d v O n time required is O n

G j j

j =1 i j =1

G

i

op eration in the else branch can b e p erformed in time O n Thus altogether the complexity

2

of the if statement is O n m

The symb olic multiplications of p olynomials for U G x and LG x can b e p erformed in

time O n since the order of U G x and LG x is at most n The computation of G v

i i

demands a sorting step so it requires time O n log n The up dating from G to G can

i i+1

b e p erformed in time O n m Put together the complexity for each iteration of the for

2

statement is O n log n m Taking the numb er of iterations into account the time demanded

2 2

for the for statement is O n log n nm

The computation of the harmonic mean needs a symb olic multiplication and a symb olic

2

addition It can b e p erformed in time O n Therefore the complexity of the entire algorithm

2 2

is O n log n nm This complexity analysis leads to the following theorem

The problem of computing the chromatic polynomial of a chordal graph is solv Theorem

able in polynomial time

Pro of By Prop ositions and the complexity analysis of Algorithm CP 2

m

s s s

H

H

H

H

H

H

H

s s H

m m

Figure Graph K

m2

Performance Analysis and Measurements

This section investigates the p erformance b ehavior of Algorithm CP Since the values of C G x

b

are usually very large we shall consider the relative error jC G x C G xjC G x in

p erformance analysis

The worstcase relative error of an approximation algorithm o ccurs at the cases where

C G x U G x or C G x LG x namely C G x is equal to one of the two extremes

The worstcase relative error is minimized when the relative errors for C G x U G x and

C G x LG x are equal The harmonic mean provides such an optimum b ecause

b b

C G x LG x U G x LG x U G x C G x

U G x LG x U G x LG x

Since b oth U G x and LG x are nonnegative we have

U G x LG x

U G x LG x

b

for any nonnegative integer x This implies that we always have C G x C G x

This statement is always true if we can compute b oth a lower b ound and an upp er b ound on

the measure we are interested in On the other hand we should also realize that b ecause the

problem of k colorability of a graph is NPcomplete there is no p olynomial time algorithm for

approximating the chromatic p olynomial of a graph that has a relative error less than unless

P NP Therefore if P NP is the b est worstcase relative error we can exp ect We

now give an example that has a relative error of Consider the complete bipartite graph K

m2

shown in Figure According to Formula we have the relative error

2 m1 2 m1

x x x x

2 m1 2 m1

x x x x

b

which gives when x In general C K x for x minm n while C K x

mn mn

for x

order

order

k

Figure The average values of the relative errors of the approximate chromatic p olynomials

for random graphs of order and

Another reason for cho osing the harmonic mean is as follows Since U G x b ecomes more

b

signicant than LG x as x increases we usually have C G x C G x except for some

small x At the mean time the harmonic mean is always less than or equal to the arithmetic

mean Therefore in most cases the harmonic mean gives a b etter upp er b ound than the

arithmetic mean

To consider the average p erformance b ehavior we also run some exp eriments on randomly

generated graphs The edges in the graph are chosen indep endently and with probability

Figure displays the results of the average values of the relative errors over graphs of order

and over graphs of order The results show that the value of the relative error

increases as the order of graphs increases This is b ecause the higher the order of a graph

the higher the degree of the estimated b ounds on its chromatic p olynomial and the higher

the accumulated error The results also show that the value of the relative error decreases as

for small values of k This the numb er of colors k increases except for transient uctuation

is b ecause for each graph G of order n b oth U G x and LG x are p olynomial of degree

n

n with the co ecient of x b eing Hence the degree of the numerator is smaller than the

degree of the denominator in Formula and lim The smallestdegree heuristic

x !1

employed in the p erfectsmallestlast ordering aims to restrict the transient uctuation to very

small values This allows us to have a go o d approximation of the chromatic p olynomial of a

graph in most cases

Conclusions

The problem of computing the chromatic p olynomial of a graph is Phard This pap er has

presented an approximation algorithm for computing the chromatic p olynomial of a graph

2 2

This algorithm has time complexity O n log n nm for a graph with n vertices and m edges

This pap er has also shown that the problem of computing the chromatic p olynomial of a chordal

wledge ab out the chromatic p olynomial of graphs graph can b e solved in p olynomial time Kno

can b e employed to improve the p erformance of logic programs and deductive databases

Ackno wledgments

Sp ecial thanks to S Debray P Downey and U Manb er for many valuable comments on this

work

References

A O Allen Probability Statistics and Queuing Theory With Computer Science Appli

cations Academic Press Inc

A Bondy Bounds for the Chromatic Numb er of a Graph Journal of Combinatorial J

Theory Jan pp

S K Debray and NW Lin Cost Analysis of Logic Programs to app ear in ACM

Transactions on Programming Languages and Systems

G A Dirac On Rigid Circuit Graphs Abhandlungen aus dem Mathematischen Seminar

der Universitat Hamburg pp

F Gavril Algorithms for Minimum Coloring Maximum Clique Minimum Covering by

Cliques and Maximum Indep endent Set of a Chordal Graph SIAM Journal of Comput

ing June pp

aph Theory and Perfect Graphs Academic Press New M C Golumbic Algorithmic Gr

Y ork

of Computer R M Karp Reducibili ty Among Combinatorial Problems Complexity

Computations edited by R E Miller and J W Thatcher Plenum Press New York

pp

D J Rose Triangulated Graphs and the Elimination Pro cess Journal of Mathematical

Analysis and Applications pp

D J Rose R E Tarjan and G S Lueker Algorithmic Asp ects of Vertex Elimination

SIAM Journal of Computing June pp

Articial Intel ligence D E Smith and M R Genesereth Ordering Conjunctive Queries

pp

L Sto ckmeyer On Approximation Algorithms for P SIAM Journal on Computing

Novemb er pp

L G Valiant The Complexity of Computing the Permanent Theoretical Computer

Science pp

D H D Warren Ecient Pro cessing of Interactive Relational Database Queries Ex

ery Large Data Bases pressed in Logic Proc Seventh International Conference on V

pp