A Novel Particle Swarm Optimization – based Algorithm for the Graph Coloring Problem Anh Tuan Hoang, Giang Thuy Thi Trinh, Vinh Trong Le Department of Mathematics – Mechanics - Informatics Hanoi University of Science, Vietnam {hoangtuananh, trinhthithuygiang,letrongvinh}@hus.edu.vn Abstract — In this paper, we study the problem of graph coloring and propose a novel particle swarm optimization (PSO) algorithm for it We use the PSO evolutionary progress to improve a simple deterministic greedy algorithm The new algorithm can achieve a result that is better than known heuristic algorithms do, as verified by an extensive simulation study Keywords — Graph coloring, first-fit algorithm, particle swarm optimization I INTRODUCTION Graph coloring is defined as coloring the nodes of a graph with the minimum number of colors without any two adjacent nodes having the same color [1] The coloring of a graph G = (V, E) is a mapping c: V → S, where S is a finite set of colors, such that if (u,v)∈ E then c(u) c(v) In other words, adjacent vertices are not assigned the same color The problem that arises is the coloring of a graph provided that no adjacent vertices have the same color The chromatic number X(G) is the minimum number of colors needed for coloring of the graph G A graph G is k-chromatic, if X(G) = k, and G is k-colorable, if X(G) k Graph coloring is one of the most useful problems in the graph theory It has been used to solve problems in school timetabling, computer register allocation, electronic bandwidth allocation, and many other applications A Previous work The problem of determining the chromatic number X(G) for certain graph G with n nodes was shown to be NP-complete [2] Therefore, researchers have been working to find greedy and heuristic algorithms for this problem One of the most popular greedy techniques is sequential coloring This technique focuses on carefully picking the next vertex to be colored and never re-colors any vertex The simplest algorithm of this kind is the First- Fit (FF) algorithm [3] which takes vertex in an arbitrary order and assigns each vertex the lowest legal color This algorithm can be implemented to run in O(m) (m is the number of edges) but it brings a poor result Authors in [4] proposed Largest Degree Ordering (LDO) algorithm in which vertices are colored in the order of nonincreasing degrees LDO was shown (by experiment results) to be better than FF and it has the complexity of O(n2) Before that, Brèlaz proposed another sequential method and gained a better performance [5] In his method, vertices are considered in Saturation Degree Ordering (SDO) The saturation degree of a vertex is defined as the number of its adjacent differently colored vertices Intuitively, this heuristics provides a better coloring but slower than LDO as it can be implemented to run in O(n3) B This work For an arbitrary graph G with n vertices, there are n! ways to sequentially color the vertices Therefore, it’s impossible to examine the all search space We used PSO technique [6] to reduce search space but still converge to a global good solution Our main contribution is a method to obtain a realistic solution from a random set of solutions using PSO technique The rest of the paper is organized as follows The main concepts of PSO and its application to solve the graph coloring problem are presented in section II Section III presents some experimental results We make conclusion and recommend some future works in section IV II PARTICLE SWARM OPTIMIZATION FOR SOLVING GRAPH COLORING PROBLEM A Particle swarm optimization Particle swarm optimization is a stochastic optimization technique developed by Dr Eberhart and Dr Kennedy [4], inspired by social behavior of bird flocking or fish schooling It shares many similarities with other evolutionary computation techniques such as genetic algorithms (GA) The algorithm is initialized with a population of random solutions and searches for optima by updating generations However, unlike the GA, the PSO algorithm has no evolution operators such as the crossover and the mutation operator In the PSO algorithm, the potential solutions, called particles, fly through the problem space by following the current optimum particle By observing bird flocking or fish schooling, we found that their searching progress has three important properties First, each particle tries to move away from its neighbors if they are too close Second, each particle steers towards the average heading of its neighbors And the third, each particle tries to go towards the average position of its neighbors Kennedy and Eberhart generalized these properties to be an optimization technique as below Consider the optimization problem P First, we randomly initiate a set of feasible solutions; each of single solution is a “bird” in search space and called “particle” All of particles have fitness values which are evaluated by the fitness function to be optimized, and have velocities which direct the flying of the particles The particles fly through the problem space by 978-1-4244-4994-1/09/$25.00 ©2009 IEEE following the current optimum particles The better solutions are found by updating particle’s position In every iteration, each particle is updated by following two "best" values The first one is the best solution (fitness) it has achieved so far (The fitness value is also stored.) This value is called pbest Another "best" value that is tracked by the particle swarm optimizer is the best value, obtained so far by any particle in the population This best value is a global best and called gbest When a particle takes part of the population as its topological neighbors, the best value is a local best and is called lbest After finding the two best values, the particle updates its velocity and positions with following equation (1) and (2) v[ ] = v[ ] + c1* rand() * (pbest[ ] - present[ ]) + + c2 * rand() * (gbest[ ] - present[ ]) present[ ] = persent[ ] + v[ ] (1) (2) PSO Algorithm For each particle Initialize particle EndFor Do For each particle Calculate fitness value If the fitness value is better than the best fitness value (pBest) in history set current value as the new pBest EndFor Choose the particle with the best fitness value of all the particles as the gBest For each particle Calculate particle velocity according to (1) Update particle position according to (2) EndFor While (stop condition is true) The stop condition mentioned in the above algorithm can be the maximum number of interaction is not reached or the minimum error criteria are not attained B Solving the graph coloring problem base on PSO In this section, we present application of PSO technique for the graph coloring problem Given graph G with n, let’s color vertices of G use as less color as possible under the constraint that no adjacent vertices have the same color It’s important to note that the order in which vertices to be considered results in the number of colors used We take the below example to illustrate the idea Example: Consider the graph given in Fig.1 If we color with the order 1- a; 2-b; 3-c; 4-d; 5-e, we have to use two colors, say and 1, (a – 0; b – 1; c – 0; d – 1; e – 1) But follow the order 1a; 2-b; 3-d; 4-c; 5-e, we have to use three colors (a – 0; b – 1; d – 0; c – 2; e – 1) Figure Example of coloring order In other words, the coloring order has impacts on the solution’s performance This is the main idea for us to design a new algorithm In our algorithm, each particle equivalent to one coloring order of vertices and this coloring order is changed by the evolutional process of PSO technique When the PSO evolution process finished, the best coloring order will be found Our new algorithm is described as follows 1) Represent a particle: There are three ways to represent a particle; they are the representation by real number, by integer number and by binary number In this paper, we use the first one Each particle is a vector with n components; every component is a real number corresponds to one in n vertices 2) Decode a particle: Assume that the set of vertices is {x1,x2,…, xn}, we use the below steps to decode the particle jth presented by vector {aj1, …, ajn} to a feasible solution a) Step 1: Rank {aj1, …, ajn} in increasing order b) Step 2: Color G by FF algorithm according to the order obtained in Step 1: if rank of aji is k (1 k n) then we color the ith vertex (xi) after coloring correspond to ajt which has rank 1, 2, , k-1 3) Initiate population: The beginning population is initiated with P particles (P is a designed parameter) Each particle is a vector with N components Every component is a real number between and which is randomly generated 4) Fitness function: If the jth particle results cj colors used, then the fitness value of this paritcle is computed with following equation: Fj = 1/cj (3) 5) Stop condition: The stop condition we used in this paper is defined as the maximum number of interaction Ngen (Ngen is also a designed parameter) C The complexity In this section, we compute the complexity of the above algorithm To initiate the population size P, we have to randomly generate a matrix with P rows and n columns So, the complexity of initiate phase is O(P.n) It’s clear that the population updating has also the complexity of O(P.n) In particle decoding, the complexity of Step is O(nlogn), and in Step 2, we use FF algorithm, so the complexity of this step is also O(m) Therefore, the total complexity of our algorithm with P particles and Ngen generations is O(Ngen.P.max{nlogn, m}), in which n is the number of vertices and m is the number of edges That means, our algorithm has complexity of O(nlogn) in the best case and O(n2) in the worst case III EXPERIMENT RESULTS We have generated 100 random graphs on 50 and 100 vertices for each edge-density 0.1, 0.2, 0.3, 0.5, 0.75 We have implemented the above three heuristic algorithms (FF, LDO, SDO) in addition to the proposed (PSO) Table show the average results of 100 times of running the four algorithms TABLE I Number of Vertices 50 100 with the number of vertices is 100 and the density is 0.5) and 0.7 (in the worst case, with the number of vertices is 100 and the density is 0.1) smaller than results of the best of three others (SDO) In average of 200 samples above, ours uses 2.478, 1.224 and 0,932 colors less than FF, LDO and SDO respectively It’s because, our algorithm search for the optimal order in a whole space of n! candidates while the three others only work in a nearly fix order AVERAGE RESULTS OF 100 TIMES Number of colors used Density ACKNOWLEDGMENT FF LDO SDO PSO 0.1 5.87 5.02 4.97 4.02 This research is partly conducted as a program for the QT09-03 and TN-09-03 in Funds for Science and Technology by the Vietnam National University 0.2 7.93 6.86 6.66 5.83 REFERENCES 0.3 9.96 8.74 8.36 7.38 0.5 13.75 12.24 12.01 10.83 0.75 20.22 18.45 18.34 17.43 0.1 8.17 7.14 6.75 6.05 0.2 11.67 10.35 9.79 9.33 0.3 16.36 14.55 13.91 13.45 0.5 20.07 18.12 18.43 16.60 0.75 34.25 31.54 30.87 29.85 The results in Table clearly show that, SDO is better than LDO, LDO is better than FF and ours is the best of four algorithms For example, our results are 1.83 (in the best case, [1] Tommy R Jensen, Bjarne Toft, Graph Coloring Problems, Wiley-Interscience,1995 [2] Garey M R., Johnson D S., Computers and Intractability: A Guide to the Theory of NP-Completeness, W.H Freeman, 1979 [3] Assefaw Hadish Gebremedhin, Parallel graph coloring, Phd Thesis, University of Bergen, Norway, 1999 [4] De Werra, D., Heuristics for Graph Coloring, Computational Graph Theory, Comput Suppl 7, Springer, Vienna, 1990, 191208 [5] Brèlaz, D., New methods to color the vertices of a graph, Communications of the Assoc of Comput Machinery 22, 1979, 251-256 [6] J Kennedy and R Eberhart, Swarm Intelligence, Morgan Kaufmann Publisher Inc, 2001 ... have to randomly generate a matrix with P rows and n columns So, the complexity of initiate phase is O(P.n) It’s clear that the population updating has also the complexity of O(P.n) In particle... Coloring, Computational Graph Theory, Comput Suppl 7, Springer, Vienna, 1990, 191208 [5] Brèlaz, D., New methods to color the vertices of a graph, Communications of the Assoc of Comput Machinery... number of vertices and m is the number of edges That means, our algorithm has complexity of O(nlogn) in the best case and O(n2) in the worst case III EXPERIMENT RESULTS We have generated 100