Coloring Cycles Fast

Let’s look at a very fast distributed algorithm. We will have a simple setting - A graph which is a directed cycle. By directed, its not about the communication pathway, the underlying communication is still both ways, except each node has an extra information. (like whose on the left etc.) Each node has exactly one successor and one predecessor. Let’s say we need a proper -coloring i.e., each node has to be labelled with a label varying from to and labels of any pair of neighbors are always different.

We’ll assume that initially the nodes are already colored with some color. This is a valid assumption in a real life setting, because each computer could be mapped to a unique identifier from a large set of identifiers. Think of this like an IP address. Currently, the number of colors is as large as the maximum value of any computer’s identifier, we would like to reduce the number of colors.

Let’s say we already have a coloring with 256 numbers (labels from to ).

One algorithm would be to follow a simple strategy: In each step, a node is active if it is a local maximum. The active nodes will then pick a color which is free from the color that the neighbors already have. This process is continued until all the nodes stop changing their colors. It can be shown that we can reduce any number of coloring to a 3-coloring since each node has at most two neighbors in the graph.

Let’s write this algorithm as a pseudocode, we should keep in mind that all the nodes in the network run the same algorithm. Let be the unique identifier of the the node. Pseudocode is given as follows.


while(true){
	Send message c to all neighbors
	Receive messages from all neighbors. Let M be the set of messages received
	If c != 1 && c != 2 && c != 3 && c > max(M){
		c = min({1 , 2 , 3} \ M) 
	}
}

Let’s call as stopping state. Once a computer reaches a stopping state, it never changes it state, meaning eventually all the computers would reach this state and the process will end at some finite time. We can rewrite the algorithm without while(true) by breaking out of the loop whenever the node reaches the stopping state.

Faster coloring with Unique identifiers

In worst case, the algorithm above is not particularly efficient. For example, if we had a chain/cycle with increasing node values, in each round at most two nodes reach the stopping state, which means that it takes rounds until all nodes have stopped. But we can do much faster. For unique identifiers initially, in one round, we can reduce the number of colors to .

We can represent the unique identifiers in terms of binary. For example, let’s take a node with value

whose successor node (marked with a prime) has values

Consider the index of the lowest bit that differs i.e.,

Now let the index be in binary and the value of be , where is or . Define the new color of node as concatenation of and . In other words, set

Note that is at most 3 digits and is a single bit, thus this new color’s value is less than . This process is done by all the nodes in a single round.

Note that this always produces a proper coloring. To see this, consider a pair of nodes and so that is the successor of . By definition, , we need to show that . If the indices in which differs from is same as differs from , then cannot be same for both as it would imply that doesn’t differ from in that index which is contradiction. If the indices in which those two differ are different, then can never be equal to since one of them will be at least be greater than the other by one regardless of what is chosen for both the nodes.

The algorithm reduces colors to colors in one round. If we iterate the algorithm, we can reduce the number of colors to in rounds. The reduction works only till the maximum number of colors is of size 3-bits, and maximum color value possible is in that case since index of is at max which is . Once we have reduced it to colors, we can then reduce it to colors by the algorithm we discussed previously in rounds.

We must be careful about the time complexity especially when we deal with such small functions, because for practical purposes, the constants will start mattering! ( for all practical ). But here, as a classic theoretic person in the context, we’ll skip it anyways.

2-Coloring Algorithms:

Consider a undirected path graph. It’s clear that it has a 2-coloring. A straightforward algorithm would be to perform round computation where each node gets to know about the whole graph, then compute the coloring locally and then outputting the color, or maybe just find the distance from the start node and color based on the parity (in case of directed).

Canonical LOCAL Algorithm:

LOCAL is a type of model used in distributed algorithm. It’ll be defined properly in the upcoming sections, but for now its just as equivalent of what we have assumed till now - Each node has a unique ID and information about its neighbors and tries to output/compute some structure or property of the network.

In any -round algorithm, any node in the network can gain information/topology of the network within a radius of distance. For a particular node, any such distributed algorithm can be viewed as a centralized algorithm being locally operated on a -hop subgraph of that node (or ). At first round, we simulate it for radius, then we simulate it for radius and so on.

Thus, any -round LOCAL algorithm can be mathematically viewed as a , where is some function that operates on the graph. The main essence is that the algorithm does not care about the topology of the graph that is greater than radius for any node.

Lower bound for 2-coloring:

Indeed, the straightforward algorithm we discussed is asymptotically as good as any other algorithm could do in terms of number of rounds. Let’s prove this by contradiction. Suppose there is an algorithm which runs for rounds and outputs a -coloring for given a path graph. Let’s cpnstruct a counter-example for which this algorithm would fail.

Consider three graphs , all having nodes with unique identifiers, of path length , with central node being . Let’s run the algorithm on these three graphs and get the 2-coloring for each of these path graphs. Now, by pigeonhole principle, atleast two of should have the same color. WLOG, we assume are such graphs having central node being colored with the same color. Note that the central nodes in all three graphs has exactly nodes in both the sides.

Given these info, construct a new graph , by adding a edge from one terminal node of to one terminal node of .

Color configuration of G1
c' - ... - c(u) - ... - c'

Color configuration of G3
c'' - ... - c(w)- ... - c''

Color configuration of G
c' - ... - c(u) - ... - c' - c'' - ... - c(w) - ... - c'' 

We have two cases:

  1. If - The algorithm is wrong in this case for one of the graphs or as fixes the color configuration for every node and it should be same for both the graphs.
  2. If - The algorithm is wrong in this case for graph (Assuming that , as we have a monochromatic edge.

Thus, such an algorithm cannot exist with rounds. Note that for greater than this bound, this argument of “the algorithm working on is exactly equivalent to the algorithm independently working on and , then their results being combined directly”, would fail, since now the radius of the central nodes will start overlapping with each other.

Thus, for any deterministic -coloring algorithm, is the lower bound.

Coloring on general graphs and trees:

We already saw an -round algorithm for directed paths. Let’s now look at the lower-bound for -coloring directed paths.

Lower bound for 3-coloring directed paths:

First of all, we define something called a -ary , -coloring function which takes inputs and produces an output value (a color here) from i.e.,

with (for convenience) , as well as it satisfies the following condition:

Let be a -round -coloring algorithm and be the color node (outputs at the end of when run on a directed path graph . Now, if is a valid -coloring algorithm, then its straightforward to see that is a -ary , -coloring function, since it satisfies the condition mentioned above

Claim:

Let be a -ary -coloring function which outputs the color of node . Define as

is a -ary coloring function.

Proof:

Before the proof, we first clarify some things here and there. First, this claim is purely mathematical, meaning that the function isn’t really doing anything but this is for a general function. Second, has its output as a set, which is a subset of i.e., range of is the power set of . This is by definition of function, since has its outputs from . Thus, by definition, is a coloring function. Now to prove the claim, we need to show that

We prove this by contradiction. Assume

Now consider the element present in the set . Since by assumption, the sets are equal, therefore this element must be present in the other set as well, i.e., there exists such that .

But this is a contradiction, since is a -ary -coloring function (by definition shouldn’t exist). Therefore, the sets are not equal. Note that in the case where is the maximum possible element (in case of finite sets), is an empty set by definition.

Now we complete the proof for the lower bound. If we have a -round algorithm , which gives a -coloring on directed graphs, it can be viewed as , which is a -ary -coloring function. Using the claim we made above, there exists a function which is a -ary -coloring function. which could be constructed as given in the claim.

Repeatedly using the claim again and again on the function times, we get a function which is a -ary -coloring function.

Let , then becomes a unary -coloring function, where . Now, for

But since is a unary -coloring function, therefore ,

which means that all will have different output values when they become inputs for . But this is not possible, since is a -coloring function, with . This means that doesn’t exist.

Back tracing all the functions, doesn’t exist implies doesn’t exist which implies that such an algorithm cannot exist. Hence, the lower bound on -coloring directed paths.

This kind of proof technique where we define a function and then progressively kind of simulate rounds is also called Round-Elimination Technique. In a general way, this technique can be viewed as reducing a -round algorithm solving a problem to a round algorithm solving a problem that could be then used to solve the original problem. In this case, the problem description stayed same, but in some problems, the problem description along with other properties might blow up exponentially. There is a tool called Round Eliminator which automatically does this round-elimination.

Also, note that this lower bound proof uses stronger and general claims which implies that locality in some sense is a strong property regardless of the graph’s whole topology.


3-coloring on rooted trees:

A similar algorithm can be applied for rooted trees as well. Follow the same strategy, but instead each node comparing its color with its parent instead of its successor. By this way, we can maintain the legality each round. We can view this algorithm on rooted trees working on each disjoint path on the tree separately from a node.

Once the color reduce is done, we can convert the -coloring to -coloring by the shift-down technique. Each node adopts the color of its parent. The root chooses any color different from its current. This ensures legality and additionally, for each node, now its neighbors will be using at most two colors.

Using shift-down we can eliminate the colors with each color being eliminated in two rounds. Let’s say we need to eliminate color . Once the shift-down is done, the nodes with color can freely choose any one color from since its neighbors use at most two colors. We can repeat this for colors and as well to get the -coloring.

coloring on bounded degree graphs:

Lets now see a coloring algorithm for a general bounded degree graph along the lines of the algorithm we saw previously.

Consider a vertex , and let it have (at most ) neighbors: . Initially each node takes it own ID as its color. Let be the bit representation. Let be the bit representation of the index of the first (least significant) bit where differs from for all . Then sets it color to be

where represents the th bit in .

This again can be viewed similar to the algorithm presented for rooted trees, here we have parents at most for each node and we break the symmetry with each parent. This algorithm reduces the number of bits in the colors from to at most in one step. Thus, by applying this reduction times, the number of bits in the colors reduce to at most . By doing a shift-down, it can be reduced to . Hence the total number of colors in the graph is at most .

Now we reduce this to in rounds. In each round, one color higher than is eliminated. This is straightforward - choose a set of nodes with color , let’s say . Now find the minimum color that is not present among the neighbors of this node and recolor it with that color. Since initially legality was preserved before these rounds, no two adjacent nodes will be recoloring themselves, thus preserving legality. We continue the same process for nodes with color , and so on.

Claim:

Any graph with maximum degree can be colored in rounds using colors. If we assume , then such a graph can be colored in rounds.

Open Problems and Ideas:

For coloring on general graphs, Linial gave an algorithm which runs in rounds. Then the time complexity was further reduced to and for some specialized problems, to . But all these algorithms are non-constructive. Can we make it constructive? How does the trade-off between and on different algorithms?

Open question (Considered to be hard): Is round algorithm optimal for - coloring on general bounded degree graphs? Note that this lower bound has been proved for MIS.

Exercises

  1. Is there a -coloring algorithm which runs in less than rounds on a path graph of length ?
  2. Design a round algorithm that works on any path (not given a consistent orientation of the edges).

Resources: