HAL Id: hal-00783886
https://hal.archives-ouvertes.fr/hal-00783886
Submitted on 6 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 abroad, or from public or private research centers.
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 publics ou privés.
Pre-processings and Linear-Decomposition Algorithm to Solve the k-Colorability Problem
Corinne Lucet, Florence Mendes, Aziz Moukrim
To cite this version:
Corinne Lucet, Florence Mendes, Aziz Moukrim. Pre-processings and Linear-Decomposition Algo- rithm to Solve the k-Colorability Problem. International Workshop on Experimental and Efficient Algorithms WEA’2004, May 2004, Brazil. pp.315-325. �hal-00783886�
Algorithm to Solve the k-Colorability Problem
?
C.Luet 1
,F.Mendes 1
,A. Moukrim 2
1
LaRIAEA2083,5rueduMoulin Neuf80000Amiens,Frane
2
HeuDiaSyCUMRCNRS6599UTC,BP20529 60205Compiegne,Frane
(Corinne.Luet,Florene.Mendes)laria.u-piardie.fr
Aziz.Moukrimhds.ut.fr
Abstrat. Weare interestedinthe grapholoring problem.We stud-
iedtheeetiveness ofsome pre-proessingsthat are speito the k-
olorabilityproblemandthatpromisetoreduethesizeorthediÆulty
of the instanes. We propose to apply onthe redued graph an exat
methodbasedonalinear-deompositionofthegraph.Wepresentsome
experimentsperformed onliterature instanes, among whihDIMACS
libraryinstanes.
1 Introdution
The Graph Coloring Problem onstitutes a entral problem in a lot of appli-
ations suh asshool timetabling, sheduling, or frequeny assignment [5,6℄.
This problembelongsto thelassofNP-hardproblems[10℄.Variousheuristis
approahes have been proposed to solve it (see for instane [2,8,9,11,13,17,
19,21℄).EÆientexatmethodsarelessnumerous:impliitenumerationstrate-
gies [14,20,22℄, olumn generation and linear programming [18℄, branh-and-
bound [3℄,branh-and-ut[7℄, withoutforgettingthe well-knownexatversion
ofBrelaz'sDSATUR[2℄.
A oloring of a graphG =(V;E) is an assignmentof a olor(x) to eah
vertex suh that (x) 6= (y) for all edges (x;y) 2 E. If the number of olors
used is k,the oloringof Gisalled ak-oloring. Theminimumvalue ofk for
whihak-oloringispossibleisalledthehromatinumberofGandisdenoted
(G). Thegraph oloring problem onsistsin ndingthe hromati numberof
agraph.Ourapproahtosolvethis problemistosolvefordierentvaluesofk
thek-olorability problem: \doesthereexist ak-oloringofG?".
Weproposetoexperimenttheeetivenessofsomepre-proessingsthatare
diretlyrelatedtothek-olorabilityproblem.Theaimoftheseproessingsisto
redue thesize of the graphby deleting vertiesandto onstrain it by adding
edges. Then we apply a linear-deomposition algorithm on the reduedgraph
in order to solvethe graph oloringproblem. This method is strongly related
tonotionsoftree-deomposition andpath-deomposition,wellstudiedbyBod-
laender [1℄. Linear-deomposition has been implemented eÆiently by Carlier,
?
main advantage that the exponential fator of its omplexity depends on the
linearwidthofthegraphbut notonitssize.
Our paper is organized as follows. We present in Set. 2 somepre-proes-
singsrelatedtothek-olorabilityproblemandtesttheireetivenessonvarious
benhmarkinstanes.InSet.3,wedesribeourlinear-deompositionalgorithm.
We report the resultsof our experiments in Set. 4. Finally, we onlude and
disussabouttheperspetivesofthiswork.
2 Pre-proessings
Inthissetion,wepresentseveralpre-proessingstoreduethediÆultyofak-
olorabilityproblem.Thesepre-proessingsareiterateduntilthegraphremains
unhangedorthewholegraphisredued.
2.1 Denitions
An undireted graph Gis apair(V;E)madeupof avertexset V and anedge
set E V V. Let N = jVj and M = jEj. A graph G is onneted if for
all vertiesw;v 2 V(w 6=v),there exists a pathfrom w to v. Without lossof
generality,thegraphswewillonsiderinthefollowingofthispaperwillbeonly
undiretedandonnetedgraphs.GivenagraphG=(V;E)andavertexx2V,
let#(x)=fy2V=(x;y)2Eg.#(x)representstheneighborhoodofx inG.The
subgraphofG=(V;E)induedbyI V,isthegraphG(I)=(I;E
I
)suhthat
E
I
=E\(II). A lique of G= (V;E)is a subset C V suh that every
twovertiesin C arejoined byan edgein E. LetE =(V V)nE bethe set
madeupof allpairsofvertiesthat arenotneighbors in G=(V;E).Letd be
thedegreeofG,i.e.themaximalvertexdegreeamongallvertiesofG.
2.2 Redution 1
A vertex redution using the following property of the neighborhood of the
vertiesanbeappliedtotherepresentativegraphbeforeanyotheromputation
with time omplexityO(jEjd), upperbounded byO(N 3
). Given agraphG,
for eah pair of verties x;y 2 V suh that (x;y) 2= E, if #(y) #(x) then
y and its adjaent edges an be erased from the graph. Indeed, suppose that
k 1olors areneeded toolor theneighbors of x.Thevertexx antakethe
k th
olor.Vertiesx andy are notneighbors.Moreover,theneighborsof y are
already oloredwith atmost k 1olors. So,if Gnfygis k-olorablethen G
isk-olorableaswellandweandeletey fromthegraph.Thisprinipleanbe
applied reursivelyaslongasvertiesareremovedfrom thegraph.
2.3 Redution 2
Supposethatwearesearhingforak-oloringofagraphG=(V;E).Thenwe
has k 1 neighbors. In the worst ase, those neighbors must have dierent
olors. Then the vertex x an take the k th
olor. It does not interfere in the
oloring of the remaining verties beause all its neighbors havealready been
olored.Therefore weanonsider fromthe beginningthat it will takeaolor
unused by its neighbors and delete it from the graphbefore the oloring.The
time omplexity ofthis redutionis O(N). We applythis priniplereursively
by examiningthe remainingvertiesuntil havingtotally reduedthegraph or
beingenabletodeleteanyothervertex.
2.4 VertexFusion
Supposethat wearesearhingforak-oloringofG=(V;E)and thatalique
C of size k has been previously determined. For eah ouple of non-adjaent
verties x;y 2 V suh that x 2= C and y 2 C, if x is adjaent to all verties
of Cny then x and y an be merged by the following way: eah neighbor of
x beomes aneighborof y, then x and its adjaentedges are erased from the
graph. Indeed,sine weare searhing for a k-oloring,x and y must havethe
sameolor.Then8z2#(x)(y)6=(z)andtheedge(y;z)anbeadded toG.
Then #(x)#(y)andx an beerasedfromthe graph(f Set.2.2). Thetime
omplexityofthispre-proessingisO(Nk).
2.5 Edge Addition
Supposethatwearesearhingforak-oloringofG=(V;E)andthataliqueC
ofsizekhasbeenpreviouslydetermined.Foreahoupleofnon-adjaentverties
x;y2V,if8z2C wehave(x;z)2Eor(y;z)2E,thentheedge(x;y)anbe
addedtothegraph.Neessarly,xmusttakeaolorfromtheolorsofCn#(x).
Sine #(y) Cn#(x), (x) 6=(y). This onstraint anbe representedby an
edgebetweenxandy.Thetimeomplexityofthispre-proessingisO(jEjk),
upperboundedbyO(N 2
k).
Algorithm1Pre-proessings
Input: agraphGandanintegerk
Output: agraphG 0
k-olorableifandonlyifGisk-olorable
repeat
redution1
redution2
if 9atleast1liqueofsizekthen
applyvertexfusionandedgeadditiononG
endif
untilthereisnomorehangeinG
0
Ouralgorithms havebeenimplementedon aPCAMD AthlonXp 2000+in C
language.Themethod used isasfollows.Tostart with,weapplyon theentry
graphGafastliquesearhalgorithm:aslongasthegraphisnottriangulated,
weremoveavertexofsmallestdegree,andthenweolortheremainingtriangu-
latedgraphbydeterminingaperfeteliminationorder[12℄onthevertiesofG.
Thesizeoftheliqueprovidedbythisalgorithm,denotedLB,onstitutesalower
bound ofthehromati numberof G.ThenweapplyonGthepre-proessings
desribedinAlgorithm1,supposingthatwearesearhingforak-oloringofthe
graph with k = LB. We performedtests onbenhmark instanes used at the
omputationalsymposiumCOLOR02,inludingwell-knownDIMACSinstanes
(see desription of the instanes at http://mat.gsia.mu.edu/COLOR02). Re-
sults are reported in Table 1. For eah graph, we indiate the initial number
of verties N and the numberof edges M. The olumn LB ontains the size
of the maximal lique found. The perentage of verties deleted by the pre-
proessings isreported in olumn Del. Thenumberof remainingvertiesafter
thepre-proessingstepisreportedin olumnnewN.Remarkthat someofthe
instanes are totally redued by the pre-proessings when k = LB, and that
someofthemarenotreduedatall.
Table1:Pre-proessingsresults
Graph N M LBnewN Del Graph N M LBnewN Del
1-FullIns3 30 100 3 15 50% 1-FullIns4 93 593 3 35 62%
1-FullIns5 282 3247 3 75 73% 2-FullIns3 52 201 4 9 81%
2-FullIns4 212 1621 4 41 81% 2-FullIns5 85212201 4 89 90%
3-FullIns3 80 346 5 11 86% 3-FullIns4 405 3524 2 51 87%
3-FullIns5 203033751 2 107 95% 4-FullIns3 114 541 6 13 89%
4-FullIns4 690 6650 2 58 92% 5-FullIns3 154 792 7 15 90%
5-FullIns4 108511395 2 65 94% fpsol2.i.1 49611654 65 228 54%
fpsol2.i.2 451 8691 30 175 61% fpsol2.i.3 425 8688 30 149 65%
inithx.i.1 864 18707 54 443 49% inithx.i.2 64513979 31 215 67%
inithx.i.3 621 13969 31 190 69% mulsol.i.1 197 3925 49 60 70%
mulsol.i.2 188 3885 31 88 53% mulsol.i.3 184 3916 31 83 55%
mulsol.i.4 185 3946 31 85 54% mulsol.i.5 186 3973 31 84 55%
shool1 385 19095 14 360 6% shool1nsh 35214612 14 331 6%
3-Inser3 56 110 2 56 0% 4-Inser3 79 156 2 79 0%
le450 25a 450 8260 20 297 34% le450 25b 450 8263 25 294 35%
anna 138 493 11 0 100% david 87 812 11 0 100%
homer 561 1629 13 0 100% jean 80 508 10 0 100%
mug100-1 100 166 3 100 0% mug100-25 100 166 3 100 0%
mug88-1 88 146 3 88 0% mug88-25 88 146 3 88 0%
miles250 128 387 7 34 73% miles500 128 2340 20 0 100%
miles750 128 4226 31 0 100% miles1000 128 6432 42 0 100%
miles1500 128 10396 73 0 100% DSJR500 1 500 3555 12 28 94%
zeroin.i.1 211 4100 49 86 59% zeroin.i.2 211 3541 30 55 74%
Problem
In this setion, we propose a method whih uses linear-deomposition mixed
withDsaturheuristiinordertosolvethek-olorabilityproblem.
3.1 Denitions
WewillonsideragraphG=(V;E).LetN =jVjandM=jEj.Avertexlinear
orderingofGisabijetionN :V !f1;:::;Ng.Formorelarity,wedenoteithe
vertexN 1
(i).LetV
i
besubsetofV madeofthevertiesnumberedfrom1toi.
LetH
i
=(V
i
;E
i
)bethesubgraphofGinduedbyV
i .LetF
i
=fj2V=9(j;l)2
E j i <lg8i2f1;:::;jVjg. F
i
is theboundaryset of H
i .LetH
0
i
=(V 0
i
;E 0
i )
bethesubgraphofGsuhthatV 0
i
=(V nV
i )[F
i andE
0
i
=E\(V 0
i V
0
i ).The
boundarysetF
i
orrespondstothesetofvertiesjoiningH
i toH
0
i
(seeFig.1).
3 9
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
Fig.1.AsubgraphH10ofGanditsboundarysetF10=f7;8;10g
Thelinearwidth of avertex linearorderingN is F
max
(N)=max
i2V (jF
i j).
insertion of theverties, using avertex linearordering previously determined.
Thiswillbedevelopedin thefollowingsetion.
3.2 Linear-DeompositionAlgorithm
The details of the implementation of the linear-deomposition method are re-
ported in Algorithm 2. The verties of G are numbered aording to alinear
ordering N : V ! f1;:::;Ng. Then, during the oloring, we will onsider N
subgraphs H
1
;:::;H
N
and theN orresponding boundary sets F
1
;:::;F
N , as
dened inSet.3.1.
Algorithm2k-olorability
Input: agraphGandanintegerk
Output: R esul t:TrueifandonlyifGisk-oloriable
H1=(f1g;;)
F1=f1g
C(H1;1)=[1℄
i=2
R esul t=True
whileiN andR esul tdo
R esul t=Fal se
BuildH
i andF
i
foreahongurationC(Hi 1;x)ofFi
1 do
forj=1tonumberofbloksofC(Hi 1;x)do
if idoesnothaveanyneighborintheblokjthen
R esul t=True
part=C(H
i 1
;x)
insertiintheblokj ofpart
generatetheongurationC(H
i
;y)orrespondingtopart
val (C(Hi;y))=min(val (C(Hi;y));val (C(Hi 1;x)))
endif
endfor
if numberofbloksofC(Hi 1;x)<kthen
R esul t=True
part=C(Hi 1;x)
addtopartanewblokontainingi
val (part)=max(val (C(Hi 1;x)),numberofbloksofpart)
generatetheongurationC(H
i
;y)orrespondingtopart
val (C(Hi;y))=min(val (C(Hi;y));val (part))
endif
endfor
i=i+1
endwhile
The omplexity of the linear-deomposition is exponential with respet to
F (N) ,soitisneessarytomakeagoodhoiewhennumberingtheverties
to obtain the smallest linearwidth is a NP-omplete problem [1℄. After some
experimentson various heuristisof vertex numbering, wehooseto beginthe
numbering from the biggest lique provided by our lique searh heuristi (f
Set.2.6).Thenweorderthevertiesbydereasingnumberofalreadynumbered
neighbors.
Startingfromavertexlinearordering,webuildatrstiterationasubgraph
H
1
whih ontainsonlythevertex1,thenat eah stepthenextvertexandits
orresponding edges are added, until H
N
. Toeah subgraphH
i
orrespondsa
boundarysetF
i
ontainingthevertiesofH
i
whihhaveatleastoneneighborin
H 0
i
.TheboundarysetF
i
isbuiltfromF
i 1
byaddingthevertexiandremoving
the verties whose neighbors have all been numbered with at most i. Several
oloringsofH
i
mayorrespondtothesameoloringofF
i
.Moreover,theolors
usedbythevertiesV
i nF
i
donotinterferewiththeoloringofthevertieswhih
haveanorderingnumbergreaterthani,sinenoedgeexistsbetweenthem.So,
only thepartial solutionsorrespondingto dierentoloringsof F
i
have to be
storedinmemory.Thisway,severalpartialsolutionsonH
i
maybesummarized
byauniquepartialsolutiononF
i
,alled onguration ofF
i .
Aongurationoftheboundaryset F
i
isagivenoloringofthevertiesof
F
i
.Thisanberepresentedbyapartition ofF
i
,denotedB
1
;:::;B
j
, suh that
two verties u;v of F
i
are in the same blok B
if they have the same olor.
Thenumberof ongurationsof F
i
depends obviouslyonthenumberof edges
betweenthe vertiesof F
i
.The minimumnumberof ongurationsis1. Ifthe
verties of F
i
form a lique, only one onguration is possible: B
1
;:::;B
jF
i j
,
with exatly onevertexin eah blok. The maximal numberof ongurations
ofF
i
equalsthenumberofpossiblepartitionsofasetwithjF
i
jelements.When
no edge exists between the boundary set verties, all the partitions are to be
onsidered. Their number T(F
i
) grows exponentially aording to the size of
F
i
.Theirorderingnumberx,inludedbetween1andT(F
i
),isomputedbyan
algorithmaordingtotheirnumberofbloksandtheirnumberofelements.This
algorithm uses the reursive prinipleof Stirling numbers of the seond kind.
The partitions of sets with at most four elements and their ordering number
are reported in Table 2. Let C(H
i
;x) be the x th
onguration of F
i
for the
subgraph H
i
. Its value, denoted val(C(H
i
;x)) equalsthe minimum number of
olorsneessarytoolorH
i
forthisonguration.
Atstepi,fortunatelywedonotexamineallthepossibleongurationsofthe
stepi 1,but onlythosewhih havebeenreatedat preedentstep,itmeans
those for whih there is no edge between two verties of the same blok. For
eahongurationofF
i 1
,weintroduethevertexi ineahbloksuessively.
Eah timethe introdution ispossiblewithoutbreaking theoloringrules,the
orrespondingongurationofF
i
isgenerated.Moreover,foreahonguration
ofF
i 1
withvaluestritlylowerthank 1,wegeneratealsotheonguration
obtainedbyaddinganewblokontainingthevertexi.
Inordertoimprovethelinear-deomposition,weapplytheDsaturheuristi
evenly onthe remaininggraphH 0
, for dierentongurationsof F
i
.If Dsatur
j=1 j=2 j=3 j=4 T(i)
i=1 1[1℄ T(1)=1
i=2 1[12℄ 2[1℄[2℄ T(2)=2
i=3 1[123℄ 2[13℄[2℄ 5[1℄[2℄[3℄
3[1℄[23℄
4[12℄[3℄ T(3)=5
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℄ T(4)=15
ndsak-oloringthen theproess endsand theresult ofthek-oloringis yes.
Otherwisethelinear-deompositionontinuesuntilaongurationisgenerated
at step N, in this ase the graph is k-olorable, or no onguration an be
generatedfromthepreedentstep,inthisasethegraphisnotk-olorable.The
omplexityofthelinear-deompositionalgorithm,upperboundedbyN2 Fmax
,
isexponentialaordingtothelinearwidthofthegraph,butlinearaordingto
itsnumberofverties.
3.3 Exampleof Conguration Computing
Assume that we are searhing for a 3-oloring of the graphG of Fig. 2. Sup-
pose thatat step i 1we hadF
i 1
=fu;vg.Theongurationsof F
i 1 were
C(H
i 1
;1)=[uv℄ofvalueandC(H
i 1
;2)=[u℄[v℄ ofvalue.Thevalueof
is2or3,sinetheorrespondingongurationhas2bloksandk=3.
u
v
i
H
i 1
G
Fig.2.ConstrutionofH =(V [fig;E [f(u;i)g)