Color-coding

In computer science and graph theory, the method of color-coding[1][2] 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 theory and analysis of the color-coding method was proposed in 1994 by Noga Alon, Raphael Yuster, and Uri Zwick.

Results

The following results can be obtained through the method of color-coding:

• For every fixed constant $k$, if a graph $G = (V, E)$ contains a simple cycle of size $k$, then such cycle can be found in:
• O($V^\omega$) expected time, or
• O($V^\omega \log V$) worst-case time, where $\omega$ is the exponent of matrix multiplication.[3]
• For every fixed constant $k$, and every graph $G = (V, E)$ that is in any nontrivial minor-closed graph family (e.g., a planar graph), if $G$ contains a simple cycle of size $k$, then such cycle can be found in:
• O($V$) expected time, or
• O($V \log V$) worst-case time.
• If a graph $G = (V, E)$ contains a subgraph isomorphic to a bounded treewidth graph which has $O(\log V)$ vertices, then such a subgraph can be found in polynomial time.

The method

To solve the problem of finding a subgraph $H = (V_H, E_H)$ in a given graph $G = (V, E)$, where $H$ can be a path, a cycle, or any bounded treewidth graph where $|V_H| = O(\log V)$, the method of color-coding begins by randomly coloring each vertex of $G$ with $k = |V_H|$ colors, and then tries to find a colorful copy of $H$ in colored $G$. 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 $H$ becomes colorful with some non-zero probability $p$. It immediately follows that if the random coloring is repeated $\tfrac{1}{p}$ times, then $H$ is expected to become colorful once. Note that though $p$ is small, it is shown that if $|V_H| = O(\log V)$, $p$ is only polynomially small. Suppose again there exists an algorithm such that, given a graph $G$ and a coloring which maps each vertex of $G$ to one of the $k$ colors, it finds a copy of colorful $H$, if one exists, within some runtime $O(r)$. Then the expected time to find a copy of $H$ in $G$, if one exists, is $O(\tfrac{r}{p})$.

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.

Example

An example would be finding a simple cycle of length $k$ in graph $G = (V, E)$.

By applying random coloring method, each simple cycle has a probability of $k!/k^k > \tfrac{1}{e^k}$ to become colorful, since there are $k^k$ ways of coloring the $k$ vertices on the path, among which there are $k!$ colorful occurrences. Then an algorithm (described below) of runtime $O(V^\omega)$ can be adopted to find colorful cycles in the randomly colored graph $G$. Therefore, it takes $e^k\cdot O(V^\omega)$ overall time to find a simple cycle of length $k$ in $G$.

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 $c: V\rightarrow \{1, \dots, k\}$ to color graph $G$, enumerate all partitions of the color set $\{1, \dots, k\}$ into two subsets $C_1$, $C_2$ of size $k/2$ each. Note that $V$ can be divided into $V_1$ and $V_2$ accordingly, and let $G_1$ and $G_2$ denote the subgraphs induced by $V_1$ and $V_2$ respectively. Then, recursively find colorful paths of length $k/2 - 1$ in each of $G_1$ and $G_2$. Suppose the boolean matrix $A_1$ and $A_2$ represent the connectivity of each pair of vertices in $G_1$ and $G_2$ by a colorful path, respectively, and let $B$ be the matrix describing the adjacency relations between vertices of $V_1$ and those of $V_2$, the boolean product $A_1BA_2$ gives all pairs of vertices in $V$ that are connected by a colorful path of length $k-1$. Thus, the recursive relation of matrix multiplications is $t(k) \le 2^k\cdot t(k/2)$, which yields a runtime of $2^{O(k)}\cdot V^\omega \in O(V^\omega)$. Although this algorithm finds only the end points of the colorful path, another algorithm by Alon and Naor[4] that finds colorful paths themselves can be incorporated into it.

Derandomization

The derandomization of color-coding involves enumerating possible colorings of a graph $G$, such that the randomness of coloring $G$ is no longer required. For the target subgraph $H$ in $G$ to be discoverable, the enumeration has to include at least one instance where the $H$ is colorful. To achieve this, enumerating a $k$-perfect family $F$ of hash functions from $\{1, 2, \dots, |V|\}$ to $\{1, 2, \dots, k\}$ is sufficient. By definition, $F$ is k-perfect if for every subset $S$ of $\{1, 2, \dots, |V|\}$ where $|S| = k$, there exists a hash function $h\in F$ such that $h: S \rightarrow \{1, 2, \dots, k\}$ is perfect. In other words, there must exist a hash function in $F$ that colors any given $k$ vertices with $k$ distinct colors.

There are several approaches to construct such a $k$-perfect hash family:

1. The best explicit construction is by Moni Naor, Leonard J. Schulman, and Aravind Srinivasan,[5] where a family of size $e^k k^{O(\log k)} \log |V|$ can be obtained. This construction does not require the target subgraph to exist in the original subgraph finding problem.
2. Another explicit construction by Jeanette P. Schmidt and Alan Siegel[6] yields a family of size $2^{O(k)}\log^2 |V|$.
3. Another construction that appears in the original paper of Noga Alon et al.[2] can be obtained by first building a $k$-perfect family that maps $\{1, 2, \dots, |V|\}$ to $\{1, 2,\dots, k^2\}$, followed by building another $k$-perfect family that maps $\{1, 2, \dots, k^2\}$ to $\{1, 2, \dots, k\}$. In the first step, it is possible to construct such a family with $2n\log k$ random bits that are almost $2\log k$-wise independent,[7][8] and the sample space needed for generating those random bits can be as small as $k^{O(1)}\log |V|$. In the second step, it has been shown by Jeanette P. Schmidt and Alan Siegel[6] that the size of such $k$-perfect family can be $2^{O(k)}$. Consequently, by composing the $k$-perfect families from both steps, a $k$-perfect family of size $2^{O(k)}\log |V|$ that maps from $\{1, 2, \dots, |V|\}$ to $\{1, 2, \dots, k\}$ can be obtained.

In the case of derandomizing well-coloring, where each vertex on the subgraph is colored consecutively, a $k$-perfect family of hash functions from $\{1, 2, \dots, |V|\}$ to $\{1, 2, \dots, k!\}$ is needed. A sufficient $k$-perfect family which maps from $\{1, 2, \dots, |V|\}$ to $\{1, 2, \dots, k^k\}$ can be constructed in a way similar to the approach 3 above (the first step). In particular, it is done by using $nk\log k$ random bits that are almost $k\log k$ independent, and the size of the resulting $k$-perfect family will be $k^{O(k)}\log |V|$.

The derandomization of color-coding method can be easily parallelized, yielding efficient NC algorithms.

Applications

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 $k=O(\log n)$ vertices in a network $G$ with $n$ 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.[9][10]

References

1. ^ 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
2. ^ a b 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