In computer science and graph theory, the method of color-coding efficiently finds k-vertex simple paths, k-vertex cycles, and other small subgraphs within a given graph using probabilistic algorithms, which can then be derandomized and turned into deterministic algorithms. This method shows that many subcases of the subgraph isomorphism problem (an NP-complete problem) can in fact be solved in polynomial time.
The following results can be obtained through the method of color-coding:
- For every fixed constant , if a graph contains a simple cycle of size , then such cycle can be found in:
- For every fixed constant , and every graph that is in any nontrivial minor-closed graph family (e.g., a planar graph), if contains a simple cycle of size , then such cycle can be found in:
- O() expected time, or
- O() worst-case time.
- If a graph contains a subgraph isomorphic to a bounded treewidth graph which has vertices, then such a subgraph can be found in polynomial time.
To solve the problem of finding a subgraph in a given graph , where can be a path, a cycle, or any bounded treewidth graph where , the method of color-coding begins by randomly coloring each vertex of with colors, and then tries to find a colorful copy of in colored . Here, a graph is colorful if every vertex in it is colored with a distinct color. This method works by repeating (1) random coloring a graph and (2) finding colorful copy of the target subgraph, and eventually the target subgraph can be found if the process is repeated a sufficient number of times.
Suppose becomes colorful with some non-zero probability . It immediately follows that if the random coloring is repeated times, then is expected to become colorful once. Note that though is small, it is shown that if , is only polynomially small. Suppose again there exists an algorithm such that, given a graph and a coloring which maps each vertex of to one of the colors, it finds a copy of colorful , if one exists, within some runtime . Then the expected time to find a copy of in , if one exists, is .
Sometimes it is also desirable to use a more restricted version of colorfulness. For example, in the context of finding cycles in planar graphs, it is possible to develop an algorithm that finds well-colored cycles. Here, a cycle is well-colored if its vertices are colored by consecutive colors.
An example would be finding a simple cycle of length in graph .
By applying random coloring method, each simple cycle has a probability of to become colorful, since there are ways of coloring the vertices on the path, among which there are colorful occurrences. Then an algorithm (described below) of runtime can be adopted to find colorful cycles in the randomly colored graph . Therefore, it takes overall time to find a simple cycle of length in .
The colorful cycle-finding algorithm works by first finding all pairs of vertices in V that are connected by a simple path of length k − 1, and then checking whether the two vertices in each pair are connected. Given a coloring function to color graph , enumerate all partitions of the color set into two subsets , of size each. Note that can be divided into and accordingly, and let and denote the subgraphs induced by and respectively. Then, recursively find colorful paths of length in each of and . Suppose the boolean matrix and represent the connectivity of each pair of vertices in and by a colorful path, respectively, and let be the matrix describing the adjacency relations between vertices of and those of , the boolean product gives all pairs of vertices in that are connected by a colorful path of length . Thus, the recursive relation of matrix multiplications is , which yields a runtime of . Although this algorithm finds only the end points of the colorful path, another algorithm by Alon and Naor that finds colorful paths themselves can be incorporated into it.
The derandomization of color-coding involves enumerating possible colorings of a graph , such that the randomness of coloring is no longer required. For the target subgraph in to be discoverable, the enumeration has to include at least one instance where the is colorful. To achieve this, enumerating a -perfect family of hash functions from to is sufficient. By definition, is k-perfect if for every subset of where , there exists a hash function such that is perfect. In other words, there must exist a hash function in that colors any given vertices with distinct colors.
There are several approaches to construct such a -perfect hash family:
- The best explicit construction is by Moni Naor, Leonard J. Schulman, and Aravind Srinivasan, where a family of size can be obtained. This construction does not require the target subgraph to exist in the original subgraph finding problem.
- Another explicit construction by Jeanette P. Schmidt and Alan Siegel yields a family of size .
- Another construction that appears in the original paper of Noga Alon et al. can be obtained by first building a -perfect family that maps to , followed by building another -perfect family that maps to . In the first step, it is possible to construct such a family with random bits that are almost -wise independent, and the sample space needed for generating those random bits can be as small as . In the second step, it has been shown by Jeanette P. Schmidt and Alan Siegel that the size of such -perfect family can be . Consequently, by composing the -perfect families from both steps, a -perfect family of size that maps from to can be obtained.
In the case of derandomizing well-coloring, where each vertex on the subgraph is colored consecutively, a -perfect family of hash functions from to is needed. A sufficient -perfect family which maps from to can be constructed in a way similar to the approach 3 above (the first step). In particular, it is done by using random bits that are almost independent, and the size of the resulting -perfect family will be .
The derandomization of color-coding method can be easily parallelized, yielding efficient NC algorithms.
Recently, color-coding has attracted much attention in the field of bioinformatics. One example is the detection of signaling pathways in protein-protein interaction (PPI) networks. Another example is to discover and to count the number of motifs in PPI networks. Studying both signaling pathways and motifs allows a deeper understanding of the similarities and differences of many biological functions, processes, and structures among organisms.
Due to the huge amount of gene data that can be collected, searching for pathways or motifs can be highly time consuming. However, by exploiting the color-coding method, the motifs or signaling pathways with vertices in a network with vertices can be found very efficiently in polynomial time. Thus, this enables us to explore more complex or larger structures in PPI networks. More details can be found in.
- Alon, N., Yuster, R., and Zwick, U. 1994. Color-coding: a new method for finding simple paths, cycles and other small subgraphs within large graphs. In Proceedings of the Twenty-Sixth Annual ACM Symposium on theory of Computing (Montreal, Quebec, Canada, May 23–25, 1994). STOC '94. ACM, New York, NY, 326–335. DOI= http://doi.acm.org/10.1145/195058.195179
- Alon, N., Yuster, R., and Zwick, U. 1995. Color-coding. J. ACM 42, 4 (Jul. 1995), 844–856. DOI= http://doi.acm.org/10.1145/210332.210337
- Coppersmith–Winograd Algorithm
- Alon, N. and Naor, M. 1994 Derandomization, Witnesses for Boolean Matrix Multiplication and Construction of Perfect Hash Functions. Technical Report. UMI Order Number: CS94-11., Weizmann Science Press of Israel.
- Naor, M., Schulman, L. J., and Srinivasan, A. 1995. Splitters and near-optimal derandomization. In Proceedings of the 36th Annual Symposium on Foundations of Computer Science (October 23–25, 1995). FOCS. IEEE Computer Society, Washington, DC, 182.
- Schmidt, J. P. and Siegel, A. 1990. The spatial complexity of oblivious k-probe Hash functions. SIAM J. Comput. 19, 5 (Sep. 1990), 775-786. DOI= http://dx.doi.org/10.1137/0219054
- Naor, J. and Naor, M. 1990. Small-bias probability spaces: efficient constructions and applications. In Proceedings of the Twenty-Second Annual ACM Symposium on theory of Computing (Baltimore, Maryland, United States, May 13–17, 1990). H. Ortiz, Ed. STOC '90. ACM, New York, NY, 213-223. DOI= http://doi.acm.org/10.1145/100216.100244
- Alon, N., Goldreich, O., Hastad, J., and Peralta, R. 1990. Simple construction of almost k-wise independent random variables. In Proceedings of the 31st Annual Symposium on Foundations of Computer Science (October 22–24, 1990). SFCS. IEEE Computer Society, Washington, DC, 544-553 vol.2. DOI= http://dx.doi.org/10.1109/FSCS.1990.89575
- Alon, N., Dao, P., Hajirasouliha, I., Hormozdiari, F., and Sahinalp, S. C. 2008. Biomolecular network motif counting and discovery by color coding. Bioinformatics 24, 13 (Jul. 2008), i241-i249. DOI= http://dx.doi.org/10.1093/bioinformatics/btn163
- Hüffner, F., Wernicke, S., and Zichner, T. 2008. Algorithm Engineering for Color-Coding with Applications to Signaling Pathway Detection. Algorithmica 52, 2 (Aug. 2008), 114-132. DOI= http://dx.doi.org/10.1007/s00453-007-9008-7