Table of Contents Author Guidelines Submit a Manuscript
Journal of Applied Mathematics
Volume 2019, Article ID 4073905, 7 pages
Research Article

Rainbow Connectivity Using a Rank Genetic Algorithm: Moore Cages with Girth Six

Universidad Autónoma Metropolitana, Cuajimalpa 05348, Mexico

Correspondence should be addressed to M. Gómez-Fuentes; moc.mia@setneufzemogcm

Received 12 September 2018; Accepted 29 January 2019; Published 3 March 2019

Academic Editor: Ali R. Ashrafi

Copyright © 2019 J. Cervantes-Ojeda et al. This is an open access article distributed under the Creative Commons Attribution License, which permits unrestricted use, distribution, and reproduction in any medium, provided the original work is properly cited.


A rainbow -coloring of a -connected graph is an edge coloring such that for any two distinct vertices and of there are at least internally vertex-disjoint rainbow -paths. In this work, we apply a Rank Genetic Algorithm to search for rainbow -colorings of the family of Moore cages with girth six -cages. We found that an upper bound in the number of colors needed to produce a rainbow 4-coloring of a -cage is 7, improving the one currently known, which is 13. The computation of the minimum number of colors of a rainbow coloring is known to be NP-Hard and the Rank Genetic Algorithm showed good behavior finding rainbow -colorings with a small number of colors.

1. Introduction and Definitions

Evolutionary algorithms have been applied to a wide variety of engineering problems [1], and they have also been applied to mathematics problems. For instance, Jong and Spears [2] showed that Genetic Algorithms (GA) can be used to solve NP-Complete problems, [3] applied a GA to a geometry problem, and [4] solved nonlinear algebraic equations by using a GA. Here we have successfully applied a Rank Genetic Algorithm (Rank GA) [5] to the graph theory problem of finding the rainbow connection number of a graph (). Chakraborty et al. [6] proved that, for a given graph , deciding whether is NP-Complete and that it is also NP-Complete to decide whether a given edge-colored (with an unbounded number of colors) graph is rainbow connected. Therefore, our motivation is to try using the Rank GA heuristic on this problem. To our best knowledge, this problem has not been approached in this way nor using any other heuristic algorithms.

In a genetic algorithm we have an initial population of individuals; in our case, each individual represents a particular edge-colored graph. Each individual of the population is evaluated according to a fitness function; this function measures the ability of the individual for reaching a predetermined objective. Once individuals are evaluated, the next generation is obtained by applying genetic operators to the population inspired by the evolution in nature, such as cross-over between individuals, selection of the fittest individuals, and mutations. This procedure is repeated until the genetic algorithm finds an individual that achieves the required objective or until a maximum number of generations are reached. A genetic algorithm can solve mathematical problems that are intractable by exhaustive search, as is the case of the problem described here.

A graph is -connected if and only if there are at least internally disjoint -paths connecting every two distinct vertices and of [7]. A rainbow path is a path such that all the edges of have different colors (a path of is a sequence of distinct vertices such that is an edge for ). An edge coloring of a graph is called a rainbow -coloring if for every pair of distinct vertices and there are at least internally disjoint rainbow -paths. The rainbow -connectivity (defined by Chartrand et al. [8]) of a graph is the minimum integer such that there exists an edge coloring using colors which is a rainbow -coloring. The rainbow -connectivity is known as the rainbow connection number and was introduced by Chartrand et al. [9].

The rainbow -connectivity of a graph has applications in the Cybernetic Security (see Ericksen [10]). For any fixed , deciding if is NP-Complete [6, 11]. For more references on rainbow connectivity and rainbow -connectivity we refer the reader to the survey by Li [12] et al. and the book of Li and Sun [13].

A graph is -regular if every vertex of has degree . The girth of is the length of a shortest cycle of . Given two integers and a -cage is a -regular graph with girth and the minimum possible number of vertices. Let denote the order of a -cage. For references on cages see the dynamic survey of Exoo and Jajcay [14]. By counting the vertices emerging from a vertex or from an edge the lower bound , known as the Moore bound, is obtained. That is, , whereWhen the -cage is called a Moore -cage; for references on Moore cages see [15]. The Moore cages have been characterized [1618]. The existence of -Moore cages is related to the existence of finite geometries. For instance, the -cage is the incidence graph of Fano’s plane. Concerning connectivity of -cages it has been proved that they are -connected [19].

Chartrand et al. [20] showed that the rainbow -connectivity of the -cage (the Moore cage known as Heawood graph) is between 5 and 7 inclusive. Recently, Balbuena et al. [21] proved that it is not 5, and they bounded the rainbow -connectivity of -cages as follows: if is a Moore -cage, thenIf is a -cage, then for , , and , respectively, we have , , and , respectively. In this paper we use a genetic algorithm to search for rainbow -colorings of -cages with and [21] in order to see if the upper bound for can be improved.

The structure of this paper is as follows. In Section 2 we explain how the Rank GA was applied to the rainbow coloring problem. Results are presented in Section 3 and finally the conclusions are drawn in Section 4.

2. Finding Rainbow Colorings in a Moore Cage with a Genetic Algorithm

Finding a particular rainbow -coloring of a graph using colors (that is a coloring with internally disjoint rainbow paths between any pair of vertices) implies that . We use an adapted version of the Rank GA [5] to find rainbow colorings in a Moore cage. To do so, each individual in the population contains a list of the assigned colors of each edge in the graph and is initialized randomly. In the Rank GA, the individuals of the population are ranked from best to worst in terms of their fitness before the genetic operators (selection, recombination and mutation) are applied. The application of these genetic operators depends on the rank of each individual in the population. The top ranked individuals tend to vary less than the bottom ranked ones. This is to make the latter try to escape from local optima of the fitness function. Also, top ranked individuals tend to be cloned more than others who tend to disappear.

The adapted RankGA pseudocode that was used is given in Algorithm 1 and its parameters are shown in Table 1.

Table 1: Parameters of the Rank GA.
Algorithm 1: Rank GA.
2.1. The Fitness Function

We detail below the fitness function. As this is an interdisciplinary work, we express the fitness function mathematically (below) and also in a computational way in Algorithm 2.

Algorithm 2: Coloring fitness function.

Let be a graph, let be the set of all possible colorings of the edges , and let be the set of all pairs of vertices of , that is, . The fitness function to be maximized using the RankGA is given aswhere andwhere is the set of all sets of internally disjoint paths between the vertices in andwherewhere is the set of all edges in path andwhere is the color that the coloring assigns to edge .

The function , in (12), calculates the cardinality of a set made out of the colors assigned to the edges in path . The function , in (10), calculates the ratio of the over the length of path , being this a value in the range , yielding 1 only in case the path has a rainbow coloring and lower values as the number of colors used in the path is reduced. The function , in (8), calculates the geometric mean of all the values of all the paths in the disjoint path set , yielding a value in the range with 1 representing a rainbow disjoint path set. The function , in (6), returns the maximum that can be obtained from the set of disjoint path sets between the vertices in the vertex pair yielding 1 if and only if there exists at least one rainbow disjoint path set in . Finally, the function in (4) computes the geometric mean of all the values yielding a result that is 1 if and only if all pairs of vertices have a fitness value of 1; i.e., the given coloring is a rainbow coloring.

The pseudocode of the fitness function is given in Algorithm 2.

2.2. Finding the Set of Internally Disjoint Paths Sets between Pairs of Vertices in a Graph

The total number of possible sets of paths (internally disjoint or not) between the vertices in pair is very high as grows so in order to save computing time when calculating the fitness of an individual, the function in (6) iterates only on the elements of the set which is the set of path sets that contain internally disjoint paths between the vertices in . Algorithm 3 describes a way to calculate and store the set of all .

Algorithm 3: Disjoint paths sets between vertices.

In this algorithm, the procedure takes each vertex pair in and calls function in order to get the full set of paths between the vertices in with length (since longer paths cannot be rainbow colored). Then it calls another function which tests each set containing paths between the vertices in to see if is a disjoint paths set and returns the set of disjoint paths sets .

The function is recursive and takes 3 parameters: a vertex pair , a graph , and a maximum length of the paths to be found. Figure 1 illustrates how this function works. Paths that go from vertex to vertex are made by adding the step from to of to all paths that go from of to for each . But before doing this, vertex is marked as visited in order to avoid paths that visit a vertex more than once. After computing the set of paths, vertex is unmarked.

Figure 1: Recursive finding of the set of paths between vertices and .

In Table 2 we show how several measures grow with parameter . First there is the number of vertices in the cage followed by the total number of vertex pairs. Then there is the number of vertex pairs with distances , , and between them, respectively. We can see how the total number of paths with length between vertex pairs changes with distance and with . The next measure is the important one because it shows the drastic increase with of the total number of paths sets containing paths (internally disjoint and noninternally disjoint) that can be formed with the paths between the pairs of vertices with distances , , and between them, respectively. All these sets need to be tested to see which of them are disjoint pats sets. Finally we show the total number of paths sets that need to be tested and the approximate time to compute this with our existing algorithms and computing power. As one can see the numbers are much bigger as increases making it practically impossible, at the moment, to do the work for .

Table 2: Growth with of the effort to find the sets of disjoint paths sets.

3. Results

The genetic algorithm was able to find several rainbow colorings of the -Moore cage for and using 7 colors. Using 6 colors, the algorithm could not find any rainbow colorations for neither nor . A sample rainbow coloring that was found can be seen in Figure 2.

Figure 2: Sample rainbow coloring with and .

4. Conclusions

The problem of finding the rainbow -connectivity of -cages is intractable by exhaustive search. So it had not been possible to verify if it is possible to improve the upper bound given by (2). With the Rank GA we could see that it is unlikely that the upper bound for -cages is less than 7, since with 6 colors no solution was found after having let the algorithm run for a long time. We also found that for the -cage there is an upper bound of 7 colors since the algorithm found rainbow colorings in this case. This upper bound improves quite a lot the 13 colors given by (2) which binds the rainbow -connectivity of -cages with a quadratic function. By finding out that the upper bound for the -cage is 7 we know that this upper bound function could be one that grows slower than a quadratic function and may be much slower. To find the form of this function the problem should be scaled to Moore cages with ; however, for , the problem is computationally very expensive, with the algorithms and computing power that we currently use. Thus, as for future work we will consider different approaches such as taking into account the symmetries of the graph, parallelization, and improvement of algorithms.

We believe that graph theory can benefit from the use of artificial intelligence techniques in some known NP-Complete and NP-Hard problems such as the one presented in this paper and there may be many of these cases.

Data Availability

No data were used to support this study.

Conflicts of Interest

The authors declare that they do not have any conflicts of interest.


This work was funded by Universidad Autónoma Metropolitana-Cuajimalpa. The authors would like to thank Dr. Rodolfo René Suárez Molnar, UAM-Cuajimalpa Unit Rector, for institutional support.


  1. D. Dasgupta and Z. Michalewicz, Evolutionary Algorithms in Engineering Applications, Springer Science and Business Media, 2013.
  2. K. A. De Jong and W. M. Spears, “Using genetic algorithms to solve NP-complete problems,” International Computer Games Association, pp. 124–132, 1989. View at Google Scholar
  3. S. Jakobs, “On genetic algorithms for the packing of polygons,” European Journal of Operational Research, vol. 88, no. 1, pp. 165–181, 1996. View at Publisher · View at Google Scholar · View at Scopus
  4. A. Pourrajabian, R. Ebrahimi, M. Mirzaei, and M. Shams, “Applying genetic algorithms for solving nonlinear algebraic equations,” Applied Mathematics and Computation, vol. 219, no. 24, pp. 11483–11494, 2013. View at Publisher · View at Google Scholar · View at MathSciNet · View at Scopus
  5. J. Cervantes and C. R. Stephens, “Limitations of existing mutation rate heuristics and how a rank GA overcomes them,” IEEE Transactions on Evolutionary Computation, vol. 13, no. 2, pp. 369–397, 2009. View at Publisher · View at Google Scholar · View at Scopus
  6. S. Chakraborty, E. Fischer, A. Matsliah, and R. Yuster, “Hardness and algorithms for rainbow connectivity,” in Proceedings of the 26th International Symposium on Theoretical Aspects of Computer Science STACS, pp. 243–254, 2009, Also, see Journal of Combinatorial Optimization, vol. 21, pp. 330–347, 2011.
  7. K. Menger, “Zur allgemeinen Kurventheorie,” Fundamenta Mathematicae, vol. 10, pp. 96–115, 1927. View at Publisher · View at Google Scholar
  8. G. Chartrand, G. L. Johns, K. A. McKeon, and P. Zhang, “The rainbow connectivity of a graph,” Networks. An International Journal, vol. 54, no. 2, pp. 75–81, 2009. View at Publisher · View at Google Scholar · View at MathSciNet
  9. G. Chartrand, G. L. Johns, K. A. McKeon, and P. Zhang, “Rainbow connection in graphs,” Mathematica Bohemica, vol. 133, no. 1, pp. 85–98, 2008. View at Google Scholar · View at MathSciNet
  10. A. Ericksen, “A matter of security,” Graduating Engineer and Computer Careers, pp. 24–28, 2007. View at Google Scholar
  11. V. B. Le and Z. Tuza, “Finding optimal rainbow connection is hard,” 2009.
  12. X. Li, Y. Shi, and Y. Sun, “Rainbow connections of graphs: a survey,” Graphs and Combinatorics, vol. 29, no. 1, pp. 1–38, 2013. View at Publisher · View at Google Scholar · View at MathSciNet · View at Scopus
  13. X. Li and Y. Sun, Rainbow Connections of Graphs, Springer, London, UK, 2013.
  14. G. Exoo and R. Jajcay, “Dynamic cage survey,” The Electronic Journal of Combinatorics, vol. DS16, 2013. View at Google Scholar · View at MathSciNet
  15. M. Miller and J. Siran, “Moore graphs and beyond: a survey of the degree/diameter problem,” The Electronic Journal of Combinatorics - Dynamic Surveys, vol. 14, 2005. View at Google Scholar
  16. E. Bannai and T. Ito, “On finite Moore graphs,” Journal of the Faculty of Science. University of Tokyo, vol. 20, pp. 191–208, 1973. View at Google Scholar · View at MathSciNet
  17. R. M. Damerell, “On Moore graphs,” Mathematical Proceedings of the Cambridge Philosophical Society, vol. 74, no. 2, pp. 227–236, 1973. View at Publisher · View at Google Scholar · View at Scopus
  18. A. J. Hoffman and R. R. Singleton, “On Moore graphs with diameters 2 and 3,” International Business Machines Journal of Research and Development, vol. 4, pp. 497–504, 1960. View at Publisher · View at Google Scholar · View at MathSciNet
  19. X. Marcote, C. Balbuena, and I. Pelayo, “On the connectivity of cages with girth five, six and eight,” Discrete Mathematics, vol. 307, no. 11-12, pp. 1441–1446, 2007. View at Publisher · View at Google Scholar · View at MathSciNet · View at Scopus
  20. G. Chartrand, G. L. Johns, K. A. McKeon, and P. Zhang, “On the rainbow connectivity of cages,” in Proceedings of the Thirty-Eighth Southeastern International Conference on Combinatorics, Graph Theory and Computing, vol. 184, pp. 209–222, 2007. View at MathSciNet
  21. C. Balbuena, J. Fresan, D. González-Moreno, and M. Olsen, “Rainbow connectivity of Moore cages of girth 6,” Discrete Applied Mathematics, vol. 250, pp. 104–109, 2018. View at Publisher · View at Google Scholar