HAL Id: hal-00783637
https://hal.archives-ouvertes.fr/hal-00783637
Submitted on 4 Feb 2013
HAL is a multi-disciplinary open access archive for the deposit and dissemination of sci- entific research documents, whether they are pub- lished or not. The documents may come from teaching and research institutions in France or
L’archive ouverte pluridisciplinaire HAL, est destinée au dépôt et à la diffusion de documents scientifiques de niveau recherche, publiés ou non, émanant des établissements d’enseignement et de recherche français ou étrangers, des laboratoires
An exact method for graph coloring
Corinne Lucet, Florence Mendes, Aziz Moukrim
To cite this version:
Corinne Lucet, Florence Mendes, Aziz Moukrim. An exact method for graph coloring. Computers and Operations Research, Elsevier, 2006, 33 (8), pp.2189-2207. �hal-00783637�
An exat method for graph oloring
C. Luet, F. Mendes
LaRIA EA 2083, 5 rue du Moulin Neuf 80000 Amiens - Frane
(Corinne.Luet, Florene.Mendes)laria.u-piardie.fr
A. Moukrim
HeuDiaSyC UMR CNRS 6599 UTC, BP 20529 60205Compiegne - Frane
Aziz.Moukrimhds.ut.fr
November 15,2004
Abstrat
Weareinterestedinthegrapholoringproblem. Weproposeanexat
methodbasedonalinear-deompositionofthegraph. Theomplexityof
thismethodisexponentialaordingtothelinearwidthoftheentrygraph,
butlinearaording to itsnumberofverties. Wepresent someexperi-
mentsperformedonliteratureinstanes,amongwhihCOLOR02library
instanes. Ourmethodis usefullto solvemorequiklythanotherexat
algorithmsinstaneswithsmalllinearwidth,suhasmug graphs. More-
over,ouralgorithmsarethersttoourknowledgetosolvetheCOLOR02
instane4-Inser3 withanexatmethod.
Keywords: grapholoring,exatmethod,linearwidth,linear-deomposition.
1 Introdution
The notions of tree-deomposition and path-deomposition have been intro-
duedbyRobertsonandSeymour[23℄. Thedeompositionmethodwepropose
hereisstronglyrelatedtothese notions,whihhavebeenstudied inpartiular
byBodlaendertosolvesomeNP-hardproblems[1℄.
Ourapproahisamethod basedonsuessivedeompositionsoftherepre-
sentativegraphprovidingsuessiveresolvedsubgraphsandtheirorresponding
withthenanialsupportofConseilRegionaldePiardieandFSE
grapharerepresentedbythedierentstatesof theboundarysetverties. The
numberofstatesto enumerategrowsexponentiallywiththesizeofthebound-
ary set. Its maximum size, for an optimal vertex numbering, orresponds to
thelinearwidth of thegraph. The main advantageof this method is that the
exponential fatorof its omplexity doesnot depend onthe size of the graph
but only on its linearwidth. This tehnique has been implemented eÆiently
byCarlier, Luetand Manouvrier to solve various NP-hardproblems suh as
network reliabilityorminimalSteinertreeomputation[4,18,19℄.
We apply the deomposition method to oneof the most studied problems
of ombinatorial optimization: the graph oloring problem. It onstitutes a
entralproblem in alot ofappliationssuhasshooltimetabling,sheduling,
orfrequenyassignment[5,6℄. Thegrapholoringproblemonsistsin oloring
the verties of a graph with a minimum number of olors, ensuring that two
adjaent verties do notreeivethe same olor. Various heuristi approahes
havebeen proposed forthis NP-hardproblem [12℄: greedy algorithms suh as
DSATUR [3℄, metaheuristis based on loal searh, tabu method, simulated
annealing,hybridalgorithms,et. (seeforexample [10,11,13,16,20,22,26℄).
To our knowledge, few exat methods are proposed to resolve this problem.
One of the most well-known exat algorithms is the exat branh-and-bound
algorithm implemented by Brelaz that uses DSATUR priniples [3℄. Impliit
enumerationstrategiesareusedin[17,25,27℄. MehrotraandTrik[21℄studied
alinearprogrammingformulationwhih is solvedbyusing olumn generation
tehniques. Morereently,MendezDiazandZabalapresentedabranh-and-ut
algorithm[8,9℄. HerrmannandHertzpresentedeÆientalgorithmsusedtond
edge-ritialand vertex-ritial subgraphsthat havesame hromati numbers
as initial graphs but are easier to solve [15℄. Desrosiers, Galinier and Hertz
proposeddierentalgorithmstodetettheseritialsubgraphs[7℄. Theymade
experiments on random graphs and on dierent types of benhmark graphs.
Theirmethod isveryeÆientonseveralinstanesfamilies.
Ourpaperisorganizedasfollows. Insetion2,wedesribethedeomposi-
tionmethodandintroduetheneessarynotions. Insetion3,wedevelopthe
implementationofthemethod. Wepresentanexatalgorithmwhihenablesus
tosolveeÆientlylargeinstaneswhoselinearwidthisbounded. Computational
resultsobtainedonvariousinstanes arepresentedin setion4. Theyompare
withtwoexatmethods: abranh-and-utalgorithm[9℄andanalgorithmbased
onvertex-ritialsubgraphsdetetion[7℄. Finally,wegivesomeonlusionsand
disussabouttheperspetivesofthiswork.
Tointroduethekindofdeompositionthatweusetosolvethegrapholoring
problem,itisneessarytoreallsomegraphtheorydenitionsandthenotions
oftree-deompositionandpath-deomposition.
2.1 Preliminary denitions
AnundiretedgraphGisapair,G=(V;E),madeupofavertexsetV andan
edgesetEVV. AgraphGisonnetedifforallvertiesw;v2V(w6=v),
thereexistsapathfromwtov. Withoutlossofgenerality,thegraphsGwewill
onsiderinthefollowingofthispaperwillbeundiretedandonnetedgraphs.
A subgraph of G= (V;E), induedby W V, is agraph G(W)= (W;E
W )
suhthatE
W
=E\(WW). Atreeisasimpleundiretedgraph,T =(I;E
T ),
withoutyleandwithjE
T
j=jIj 1. A rootedtree isatreediretedfrom the
rootr tothe leaves. Iftheedge (p;v) belongs to arooted tree, pis thefather
ofv, andvisoneofthesons ofp.
2.2 Tree-deomposition
A tree-deomposition of G = (V;E) is apair (fX
i
=i 2 Ig;T = (I;E
T )) with
fX
i
=i2IgafamilyofsubsetsofV and T atreesuhthat:
{ S
i2I X
i
=V,
{for alledges(v;w)2 E, there exists asubsetX
i
;i2I; withv 2X
i and
w2X
i ,
{foralli;j;k2I,ifj isonthepathfrom itokin T thenX
i
\X
k X
j .
Thetreewidth ofatree-deomposition ismax
i2I (jX
i
j 1). Thetreewidth ofa
graphGistheminimumtreewidth overallpossibletree-deompositionsofG.
Thedeompositionmethodisasfollows. Givenatree-deompositionof the
graph,partialsolutionsarebuiltonthesubsetsX
i
andthenassoiatedtosolve
the onsidered problem. The deomposition method omputes the solutions
fromtheleavestotherootofthetreeT,byexaminatingallpartialsolutionson
everysubgraphG(X
i
). Thenumberofpartialsolutionsisexponentialaording
tothesizeofthesubgraphsX
i
. Thesepartial solutionsareomputedfrom the
solutions of X
f
, for all f belonging to the sons of i in T. Unlike a simple
enumerative method, this method allows one to fatorize partial solutions of
theX
i
sets into lasses. This fatorization provides aneÆientmethod if the
ardinalityofthesetsX
i
issmall,i.e. ifthetreewidthofthetree-deomposition
issuÆientlysmall.
onean omputethetreewidthin lineartime,omputingthetreewidth ofany
graphisaNP-ompleteproblem[24℄. Bodlaender[2℄givesforaonstantkan
algorithm in O(n) whih for a graph G solves the problem \is the treewidth
ofGat mostk?". Ifso,it determinesatree-deompositionwithtreewidth at
mostk. This algorithm based onlique searh and graphontration hasan
exponential omplexity with respet to k (O(n2 k
2
)). It annot be used in
pratie,evenfork=4.
2.3 Path-deomposition and linear-deomposition
Thedeompositionmethodthatwewilluseinthefollowingisbasedonaspeial
aseoftree-deomposition. Wewillonsideratreewithonlyoneleaf,thatisa
path.
Apath-deomposition (X
1
;:::;X
r
)ofagraphGisanorderedsequeneofsub-
setsofV suh that:
{ S
1ir X
i
=V,
{for alledges(v;w)2 E, there exists asubsetX
i
;1i r;with v 2X
i
andw2X
i ,
{foralli;j;k2f1;:::;rg ,ifijkthenX
i
\X
k X
j .
Thepathwidth ofapath-deompositionis max
1ir (jX
i
j 1). Thepathwidth
of a graph is the minimum pathwidth over all possible path-deompositions
of G. A vertex linear ordering of G is a bijetion N : V ! f1;:::;jVjg.
For morelarity, we denote k thevertex N 1
(k). Let F
i
=fj 2 V=9(j;l) 2
E j i < lg 8i2 f1;:::;jVjg. The linearwidth of a vertex linear ordering
N is F
max
(N) = max
i2V (jF
i
j). The linearwidth of G, written F
max (G), is
the minimum linearwidth over all possible vertex linear orderings of G. The
linearwidthofagraphequalsitspathwidth[19℄.
ComputingthepathwidthorthelinearwidthofanygraphisaNP-omplete
problem[24℄,similarlyasomputingthetreewidthofanygraph. Thetreewidth
ofagraphGissmallerorequaltoitspathwidth,andasaonsequenetheex-
ponentialfatorofatree-deomposition issmallerthan that ofapath-deom-
position. Nevertheless, implementing the deomposition method on a linear-
deompositioniseasierthanusingatree-deomposition. First,fromatehnial
point of view, several X
i
partial solutionsmay have to be stored in memory
when resolving a problem with atree-deomposition. It involvessome prob-
lems of memory storage and ombination of the X
i
when implementing the
algorithm. Moreover,reatingalinear-deomposition iseasier thanreatinga
solvethe grapholoringproblem with alinear-deomposition. Theresolution
method is then based ona sequential insertionof the verties, using a vertex
linearorderingpreviouslydetermined. Thiswill bedeveloped in thefollowing
setion.
3 Appliation to the graph oloring problem
Inthissetion,weproposeamethod whih useslinear-deompositionin order
tosolvethegrapholoringproblem.
3.1 Problem denition
Aoloring of agraphG=(V;E) is anassignment ofaolor (i)2I to eah
vertexsuh that(i)6=(j)foralledges(i;j)2E.
IftheardinalityofI isk,theoloringofGisalledak-oloring. Theminimum
valueof kfor whiha k-oloringispossibleis alled thehromati number of
G and is denoted (G). The graph oloring problem onsists in nding the
hromatinumberofagraph.
3.2 Linear deomposition priniple
ConsideragraphG =(V;E). LetN =jVj and M =jEj. The verties of G
are numberedaordingto alinear ordering N : V ! f1;:::;Ng. Let V
i be
subsetof V, madeof theverties numberedfrom 1to i. LetH
i
=(V
i
;E
i )be
thesubgraphofGinduedbyV
i . F
i
istheboundarysetofH
i
,i.e. thesubsetof
V
i
suhthatv2F
i
ifandonlyif9(v;w)2E andvi<w(seegure1). Let
H 0
i
=(V 0
i
;E 0
i
)bethesubgraphofGinduedbyV 0
i
=(V nV
i )[F
i
. Anykindof
relationbetweenthevertiesofH
i
andthose ofH 0
i
dependson thevertiesof
F
i .
The linear deomposition is a dynami method. During the oloring we
willonsiderN subgraphsH
1
;:::;H
N
andtheN orrespondingboundarysets
F
1
;:::;F
N
. Startingfrom avertexlinearordering, webuildatrstiterationa
subgraphH
1
whihontainsonlythevertex1,thenateahstepthenextvertex
anditsorrespondingedgesareadded,untilH
N
. Partialsolutionsofstepiare
builtfrom partialsolutionsofstepi 1.
AteahsubgraphH
i
orrespondsaboundaryset F
i
ontainingtheverties
ofH
i
whihhaveatleastoneneighborinH 0
i
. TheboundarysetF
i
isbuiltfrom
F
i 1
byaddingthevertexiandremovingthevertiesthathavenoneighborwith
4 15
2 8 10 16
5 14
1 7 11 17
6 13
12 18
G=(V;E)
3 9
4
2 8 10
5
1 7
6
15
8 10 16
14
7 11 17
13
12 18
H
10
H 0
10
Figure1: SubgraphH
10
of GanditsboundarysetF
10
=f7;8;10g
1
F
5
=f4;5g C(H
5
;1)=[45℄val(C(H
5
;1))=2
3 5
V
V B
V
B
2 4
1
F
5
=f4;5g C(H
5
;1)=[45℄val(C(H
5
;1))=3
3 5
V
V B
V
R
Figure2: Dierentoloringsof H
5
butsameongurationofF
5
anorderingnumbergreaterthani. SeveraloloringsofH
i
mayorrespondto
thesameoloringofF
i
(seegure2). Moreover,theolorsusedbytheverties
V
i nF
i
donotinterferewiththeoloringofthevertieswhihhaveanordering
numbergreaterthani,sinenoedgeexists betweenthem. So,onlythepartial
solutionsorrespondingtodierentoloringsofF
i
havetobestoredinmemory.
Thisway,severalpartialsolutionsonH
i
maybesummarizedbyauniquepartial
solutiononF
i
,alledonguration ofF
i .
The graph oloring problem is solved by evaluating at eah step the on-
gurationsof theboundaryset F
i
. Atstepi, thesubgraph H
i 1
is solved. It
meansthat toeahonguration ofF
i 1
orrespondsavalueoftheminimum
numberofolorsneessarytoolorH
i 1
forthisxedoloringoftheboundary
set verties. Then, partial solutions arebuilt using solutionsof the preedent
step. Thispointwillbedetailedin setion3.4.
3.3 Boundary set ongurations
Aongurationof theboundarysetF
i
is agivenoloringofthevertiesof F
i .
ThisanberepresentedbyapartitionofF
i
,denotedB
1
;:::;B
j
,suhthattwo
verties u;v of F
i
arein thesameblok B
ifand only if theyhavethe same
olor. ThenumberofongurationsofF
i
dependsobviouslyonthenumberof
edgesbetweenthevertiesofF
i
. Theminimumnumberofongurationsis1. If
thevertiesofF
i
formalique,onlyoneongurationispossible: B
1
;:::;B
jFij ,
withexatlyonevertexin eah blok. Themaximalnumberof ongurations
ofF
i
equalsthenumberofpartitionsofasetwithjF
i
jelements. Whennoedge
existsbetweentheboundarysetverties,allthepartitionsaretobeonsidered.
The number of partitions of a set omposed by i elements and j bloks,
A
i;j
j=1 j=2 j=3 j=4
i=1 1[1℄
i=2 1[12℄ 2[1℄[2℄
i=3 1[123℄ 2[13℄[2℄ 5[1℄[2℄[3℄
3[1℄[23℄
4[12℄[3℄
i=4 1[1234℄ 2[134℄[2℄ 9[14℄[2℄[3℄ 15[1℄[2℄[3℄[4℄
3[13℄[24℄ 10[1℄[24℄[3℄
4[14℄[23℄ 11[1℄[2℄[34℄
5[1℄[234℄ 12[13℄[2℄[4℄
6[124℄[3℄ 13[1℄[23℄[4℄
7[12℄[34℄ 14[12℄[3℄[4℄
8[123℄[4℄
writtenA
i;j
,isgivenbythereursiveformulaofStirlingnumbersoftheseond
kind:
A
i;j
=jA
i 1;j +A
i 1;j 1
withA
1;1
=1andA
i;j
=0ifi<j.
ThenumberT(F
i
)ofdierentpartitions oftheboundarysetF
i
equalsthe
sumoftheA
jFij;j
forj from 1tojF
i j.
T(F
i )=
X
j=1tojFij A
jFij;j
Toidentifytheongurationsoftheboundaryset, weassoiatetoeahone
anorderingnumberbetween1andT(F
i
). Thepartitions ofsets withat most
fourelementsandtheirorderingnumberarereportedin table1.
Let C(H
i
;x) be the x th
onguration of F
i
for the subgraph H
i
. Its value,
denotedval(C(H
i
;x)),equalstheminimumnumberofolorsneessarytoolor
H
i
forthisonguration.
Ingure2,twodierentoloringsofH
5
orrespondtothesameonguration
ofF
5
. Only2olorsareneessarytoolorH
5
withtheongurationforwhih
verties2and3haveasameolor,whereas3olorsareneessarywhenverties2
and3havedierentolors. ThevalueoftheongurationC(H
5
;1),represented
bythepartition[45℄,is2,beausewekeeponlythebestvaluation.
The details of theimplementation of the deomposition method are reported
in algorithm 1. Note that H
1
= (f1g;;) and F
1
= f1g. So, there is only
oneongurationof F
1 , C(H
1
;1) =[1℄. Theinsertionof thevertex2 ofG in
C(H
1
;1)anprovideoneortwoongurationsofF
2
(onlyoneongurationif
theverties1and2areneighbors,twoongurationsotherwise).
Atstepi,wedonotexamineallthepossibleongurationsofthestepi 1,
but only those whih have been reatedat preedent step, it meansthose for
whih there is noedge betweentwovertiesof thesame blok. Foreah on-
guration of F
i 1
, we introdue the vertex i in eah bloksuessively. Eah
timetheintrodutionispossiblewithoutbreakingtheoloringrules,theorre-
sponding ongurationof F
i
is generated. Wegenerate alsotheongurations
obtainedby adding to eah ongurationof F
i 1
a new blok ontaining the
vertexi.
For agivensubgraphH
i
,onlytheongurationsthataredierentarerep-
resented. Theirorderingnumberx,inludedbetween1andT(F
i
),isomputed
byan algorithmaordingto their numberof bloks andtheir numberof ele-
ments. WhendierentoloringsofH
i
orrespondtothesameongurationof
F
i
,onlythebestvaluationiskeptin val(C(H
i
;x)).
AtstepN,onlyoneongurationC(H
N
;1)isgeneratedfromongurations
ofstepN 1. Itrepresentsalltheoptimaloloringsolutionsanditsvalueequals
(G).
Exampleofonguration omputing.
AssumethatwearesearhingforaoloringofthegraphGofgure3andthat
weareatstepiwithF
i
=fu;v;w;ig.
Supposethatatstepi 1,wehadF
i 1
=fu;v;wgandthattheongurations
ofF
i 1 were:
-C(H
i 1
;2)=[uw℄[v℄withvalue.
-C(H
i 1
;4)=[uv℄[w℄withvalue.
-C(H
i 1
;5)=[u℄[v℄[w℄ withvalue.
The values of and are at least 2, sine the orresponding ongurations
have2bloks. Remark that these valuesmaybeupper than2, depending on
theongurationsofthepreeedingsteps. Bythesameway,isatleast 3.
WewanttogeneratetheongurationsofF
i
fromtheongurationsofF
i 1 .
- it is impossible to insert i in the rst blok of C(H
i 1
;2), sine u and
i are neighbors. It is possible to insert i in the seond blok of C(H
i 1
;2).
We obtain C(H
i
;3) = [uw℄[vi℄ and val(C(H
i
;3)) = . It is also possible to
Input: agraphG
Output: : thehromatinumberofG
H
1
=(f1g;;)
F
1
=f1g
C(H
1
;1)=[1℄
fori=2toN do
BuildH
i andF
i
foreahongurationC(H
i 1
;x)ofF
i 1 do
forj =1tonumberofbloksofC(H
i 1
;x)do
if idoesnothaveanyneighborintheblokj then
part=C(H
i 1
;x)
insertiin theblokj ofpart
generatetheongurationC(H
i
;y)orrespondingtopart
if C(H
i
;y)alreadyexiststhen
val(C(H
i
;y))=min(val(C(H
i
;y));val(C(H
i 1
;x)))
else
val(C(H
i
;y))=val(C(H
i 1
;x))
endif
endif
endfor
part=C(H
i 1
;x)
addto part anewblokontainingi
val(part)=max(val(C(H
i 1
;x)),numberofbloksofpart)
generatetheongurationC(H
i
;y)orrespondingtopart
if C(H
i
;y)alreadyexiststhen
val(C(H
i
;y))=min(val(C(H
i
;y));val(part))
else
val(C(H
i
;y))=val(part)
endif
endfor
endfor
=val(C(H
N
;1))