Colorful Vertex Recoloring of Bipartite Graphs
Abstract
We consider the problem of vertex recoloring: we are given vertices with their initial coloring, and edges arrive in an online fashion. The algorithm is required to maintain a valid coloring by means of vertex recoloring, where recoloring a vertex incurs a cost. The problem abstracts a scenario of job placement in machines (possibly in the cloud), where vertices represent jobs, colors represent machines, and edges represent “anti affinity” (disengagement) constraints. Online coloring in this setting is a hard problem, and only a few cases were analyzed. One family of instances which is fairly well-understood is bipartite graphs, i.e., instances in which two colors are sufficient to satisfy all constraints. In this case it is known that the competitive ratio of vertex recoloring is .
In this paper we propose a generalization of the problem, which allows using additional colors (possibly at a higher cost), to improve overall performance. Concretely, we analyze the simple case of bipartite graphs of bounded largest bond (a bond of a connected graph is an edge-cut that partitions the graph into two connected components). From the upper bound perspective, we propose two algorithms. One algorithm exhibits a trade-off for the uniform-cost case: given colors, the algorithm guarantees that its cost is at most times the optimal offline cost for two colors, where is the number of vertices and is the size of the largest bond of the graph. The other algorithm is designed for the case where the additional colors come at a higher cost, : given additional colors, where is the maximum degree in the graph, the algorithm guarantees a competitive ratio of . From the lower bounds viewpoint, we show that if the cost of the extra colors is , no algorithm (even randomized) can achieve a competitive ratio of . We also show that in the case of general bipartite graphs (i.e., of unbounded bond size), any deterministic online algorithm has competitive ratio .
Keywords and phrases:
online algorithms, competitive analysis, resource augmentation, graph coloringFunding:
Boaz Patt-Shamir: This research was supported by the Israel Science Foundation, grant No. 1948/21.Copyright and License:
![[Uncaptioned image]](x1.png)
2012 ACM Subject Classification:
Theory of computation Online algorithms ; Theory of computation Graph algorithms analysis ; Theory of computation Adversary modelsEditors:
Olaf Beyersdorff, Michał Pilipczuk, Elaine Pimentel, and Nguyễn Kim ThắngSeries and Publisher:

1 Introduction
Motivation.
In the cloud, jobs are placed on machines according to multiple criteria. Sometimes, during the execution of a job, it turns out that the job is in conflict with another job, in the sense that the two jobs must not run on the same machine. Such conflicts may arise due to limited resources on a single machine, or due to security considerations, or other reasons. Whenever such a conflict between two jobs located in the same machine is detected, the system needs to migrate one of the conflicting jobs (or both) so as to separate them. This situation was abstracted in [1] as the “vertex recoloring” (or “disengagement”) problem. Generally speaking, the problem is stated as an online problem, where initially we are given vertices (representing jobs) colored in colors (representing machines). Edges (representing conflicts) arrive online, and the algorithm is asked to output a valid vertex coloring after the arrival of each edge. Recoloring a vertex incurs a cost, and the cost incurred by an algorithm is the total cost of vertex recoloring events by the algorithm. As usual with online problems, the performance measure is the competitive ratio, namely the worst-case ratio between the cost paid by the online algorithm in question and the best cost possible (offline).
In this paper we seek to generalize the problem so as to make it both richer theoretically and more realistic practically. Our starting point is the following. Recalling the motivating scenario of job migration as outlined above, we note that in many cases, it is possible to acquire more machines on which jobs may be executed. Therefore, we are interested in understanding what are the consequences of allowing the online algorithm to use more colors. Our reference cost is still the optimal cost when using the initial colors, but now we allow the online algorithm to use more colors.
The idea is not new: in fact, it was used in the very first paper on competitive analysis [12] (for cache size). Later work called this type of comparison “resource augmentation” (see, e.g., [5]). However, in this paper, still motivated by the job migration scenario, we propose an additional generalization: we also consider the case in which the additional colors come at a greater cost. We are not aware of any previous study of such a model.111In paging, this could be interpreted as follows: The offline solution uses a cache of size , while the online solution has the cache of size and an additional cache whose replacement cost may be greater. We believe that this approach, which we call weighted resource augmentation, may be appropriate in other scenarios as well.
Our results.
The problem of vertex recoloring is natural and applicable in many situations, but one has to bear in mind that it entails the problem of graph coloring, which is notoriously hard, computationally speaking. Following the approach of [1], we focus on polynomially-solvable instances of coloring. Specifically, in this paper we consider bipartite graphs, i.e., we assume that after all edges have arrived, the graph is 2-colorable. In [1] it was shown that the competitive ratio of online vertex recoloring is in the case of bipartite graphs, where is the number of vertices. We study the effect of using more colors in this case. In the following, the competitive ratio is w.r.t. the 2-color optimal solution. For general bipartite graphs and deterministic algorithms it turns out that extra colors do not really help:
Theorem 1.
Let be the set of instances of recoloring with two basic colors and special colors, where recoloring by a basic color costs 1 and recoloring by a special color costs . Then for every deterministic online recoloring algorithm there is an instance in with competitive ratio .
(We note that competitive ratio is trivial to achieve when given special colors. See Lemma 5.) We therefore restrict our attention to a subclass of bipartite graphs, namely bipartite graphs of bounded bond size. A bond of a connected graph is a set of edges whose removal partitions the graphs into two connected components (alternatively, a minimal edge cut, cf. [4], and see Definition 6). Our main result in this paper is the following:
Theorem 2.
Suppose that the final graph is bipartite, with all vertex degrees at most , and with bond size at most for each of its connected components. Then there is a deterministic algorithm that uses special colors of cost at most , whose competitive ratio is .
We note that in acyclic graphs, the largest bond size is . The following result shows that the competitive ratio of Theorem 2 cannot be improved even if we restrict the instances to have largest bond size 1.
Theorem 3.
Consider instances in which the final graph is a collection of paths, and there is an infinite set of special colors, each of cost . The competitive ratio of any (possibly randomized) recoloring algorithm in this class of instances is .
On the other hand, if (i.e., the cost of all colors is ), another algorithm provides a way to reduce the competitive ratio at the price of using more colors.
Theorem 4.
Suppose that the final graph is bipartite with bond at most . Then for any given there is a deterministic online algorithm that uses special colors of unit cost, and guarantees competitive ratio .
Our techniques.
Our algorithms use Algorithm 1 of [1], denoted in this paper, as a black box. To facilitate our algorithms, however, we need to develop a refined analysis of Algorithm . In Lemma 17 we prove a tighter upper bound on the cost of when applied to an input sequence that satisfies a certain condition (“moderate sequences,” cf. Definition 7). Using this bound, the main idea in our algorithms is to filter the input sequence so as to make it moderate, and to feed that sequence to for simulation (which we know to have good performance). The difference between our algorithms is what to do with the other edges, and how to determine the color of vertices which may be affected by the filtering.
The approach taken by our Algorithm (whose performance is stated Theorem 2), is to use special colors, essentially in greedy fashion, to resolve conflicts that involve edges that were rejected from simulation due to the moderate sequence condition. We show that this approach can guarantee competitiveness while using additional colors. The other approach, taken by our Algorithm , is to have a hierarchical set of instantations (simulations) of . If an edge is rejected by one instantation, one of its endpoints is sent to the next instantiation in the hierarchy, which uses a new set of colors; and if this fails, we send that vertex to the next instantiation etc. We show that the number of edges in this hierarchy of simulations decreases exponentially as a function of a parameter of the “moderation” of the input sequence, which allows us to prove Theorem 4.
We note that the largest bond size proves to be a very useful graph parameter, as it measures, in some precise sense, how far a graph is from a tree. Our Lemma 10 gives us a tool which may be handy in other contexts as well.
Related work.
As mentioned above, the problem of vertex recoloring was introduced in [1], where vertices have weights, and the cost of recoloring a vertex is its weight. It is shown that for bipartite graphs, competitive ratio of can be achieved by a deterministic online algorithm, and that no randomized algorithm has competitive ratio . Tight bounds are also presented for coloring for randomized and deterministic algorithms where denotes the maximal degree in the graph. Recently, Rajaraman and Wasim [11] considered the capacitated setting where there is a bound on the number or weight of vertices in each color. They give “traditional” resource-augmented algorithms: the algorithms are allowed to violate the capacity bound by a where is an arbitrarily small constant. They also study the -overprovisioned setting where the the algorithm is allowed colors and the maximum degree of the graph is bounded by .
Recoloring (or coloring with recourse) has been considered previously in the context of dynamic data structures [6, 3, 13, 10]. In these papers, no initial coloring is given and the competitive ratio is not analyzed; their measure of performance is the absolute number of recolorings. Competitive analysis is implicit in [3, 13] which is bicriteria: the arrival model is similar to ours but the final graph may be arbitrary, and the goal is to minimize both the update time and the number of colors used. In this line of work, it is assumed that the algorithm has access to an oracle that can be queried about the chromatic number of a graph. The best general result is due to Solomon and Wein [13], who give a deterministic algorithm with amortized running time using colors. Henzinger et al. [9] give better results for bounded arboricity graphs.
Although the largest bond and maximum cut of a graph may seem superficially similar, they are quite different, both in value and complexity. For example, finding the largest graph bond in bipartite graphs is NP-hard [7], but max-cut is trivial in bipartite graphs, and it is polynomially computable in planar graphs [8]; any tree has a max-cut of size but largest bond size .
Paper organization.
The remainder of this paper is organized as follows. In Section 2, we formalize the problem and introduce some notation. In Section 3, we prove our main result Theorem 2. In Section 4, we consider the uniform case and prove Theorem 4. Additional material is included in the full version: we prove our lower bounds Theorem 3 and Theorem 1, and present a slightly improved version of Algorithm . A short conclusion is presented in Section 6.
2 Problem Statement and Notation
Problem statement.
We consider the following model. Initially we are given a palette of basic colors, and a superset of colors. The extra colors in are called special colors. Each color is assigned a cost , such that for all basic colors, and for all special colors, where is some given parameter. We are also given a set of vertices with an initial coloring using only the basic colors. The online input is a sequence of edges , where each edge is an unordered pair of distinct vertices. We define the graph by . In response to the arrival of each edge , the algorithm outputs a coloring such that none of the edges in is monochromatic.
Given an algorithm , an initial coloring and an edge sequence , is a sequence of colorings . Define the cost of on an instance as
where is the Kronecker delta. That is, whenever a vertex is recolored, the algorithm pays the cost of its new color. In this paper we assume that the input is such that the final graph can be colored using , i.e., is -colorable. Given an initial coloring , the offline cost of an input sequence with respect to the basic colors is
In other words, the offline cost of w.r.t. is the least cost of recoloring using basic colors so that has no monochromatic edges.
Let denote an instance. The competitive ratio of an algorithm with respect to is . Let us make a quick observation about the problem.
Lemma 5.
Any instance of recoloring with basic colors can be solved by an online algorithm using special colors at cost at most , where is the number of vertices and is the cost of a special color.
Proof.
Consider the final graph, with vertices colored by the initial coloring. Any feasible solution must recolor a vertex cover of the monochromatic edges in this graph. Therefore, denoting the size of such a minimum vertex cover by , we have that . On the other hand, we can maintain in an online manner a 2-approximate vertex cover (e.g., using an online version of the algorithm of Bar-Yehuda and Even [2]), and every time a vertex enters the online cover, we recolor it with a distinct new color. The special colors never collide because each is used at most once, and hence the total cost is at most .
Additional notation.
-
Given a sequence , denotes the prefix of the first elements of . Given sequences and , denotes the sequence obtained by concatenating and .
-
Given a graph and , denotes the graph induced by , i.e., the graph with vertices whose edges are all edges of with both endpoints in .
Graph bond.
The largest bond size is a graph parameter related to max cut, but it is quite different. Intuitively, the graph bond is a measure of how close the graph is to a tree. We give below a definition that generalizes the standard one (e.g., [7]) to graphs with multiple connected components.
Definition 6.
Let be a graph with connected components. An edge set is a bond of if ) has exactly connected components. The size of the largest bond of is denoted .
Note that if and only if is a forest. Also note that the size of the largest bond of a graph is monotone in its edge set. More formally, if and are two graphs with the same vertex set, then implies .
We remark that an alternative definition for bond is a minimal edge cut [4]: an edge cut of is an edge set such that has more connected components than , and an edge cut is minimal if no proper subset of is an edge cut of .
3 Non-Uniform Cost
In this section we prove our main result. Intuitively, we show that while the competitive ratio for general bipartite graphs is known to be , by using additional colors of cost (at most) , one can reduce the competitive ratio to in graphs whose largest bond is small. In the full version, we show that we can achieve the same competitive ratio with only additional colors, using a somewhat more complicated algorithm.
Our algorithm uses the algorithm of Azar et al. [1] for bipartite graphs as a black box; henceforth, we refer to Algorithm 1 of [1] as . The basic strategy of our algorithm is as follows. The input sequence of edges is split in two: a subsequence denoted is sent to a simulation by algorithm (which uses only the two basic colors), and the remaining edges are sent to a procedure called recx, which uses the additional special colors. Determining which edge goes to depends on the size of the connected components of its two endpoints, and by the number of vertices already recolored by in them. The idea is to control the simulation of so that its cost remains within the range of competitiveness, and use the special colors only once we know that we can pay for them. The bond size affects the total cost due to the edges that are not sent to the simulation.
3.1 Algorithm : Specification
To describe the algorithm, we need some notation. Recall that is the sequence of the first edges of . We use to denote the set of edges in : . We use to denote the subsequence of edges sent to the simulation of in steps , and to denote the corresponding set of edges. is used to denote the set of vertices ever recolored by algorithm when executed on input . We also define to be .
We now specify the algorithm, using the parameters (the maximal cost of a color), and , a parameter of our choice which indirectly controls how many of the edges will be sent to the simulation: the smaller is, less edges will be sent to the simulation.
We also define the following concepts.
Definition 7.
Consider a sequence of edges and a connected component of the graph which is edge-induced by the set of edges in .
-
is small if and large otherwise, where is the number of vertices in .
-
is -light if , and -heavy otherwise, where is the set of vertices ever recolored by algorithm on input .
Definition 8.
Consider an input sequence , and two values and .
-
An input sequence is called -moderate if for every edge in , it holds that if and are in two distinct connected components and with respect to , then either or is either small or -light (i.e., no edge in connects two distinct components which are large and -heavy).
-
The two series of subsequences and of are defined inductively as follows.
(Informally, is appended to if it keeps the moderation property, and to otherwise.) The pseudocode for the algorithm appears in the following page.
3.2 Analysis
We now turn to analyze the algorithm.
The interesting part about the algorithm is that the simulation of is unaware of some of the edges. We start by showing that Algorithm produces a valid coloring.
Lemma 9.
After every step , is a valid coloring of the graph .
Proof.
First observe that once a vertex becomes special, then it is always colored by a special color. Likewise, only special vertices are colored by special colors.
Algorithm
State:
Each vertex has an actual color
and a simulated color
. The simulated coloring is the coloring maintained by the simulation of . The initial actual colors are given as input, and the
initial simulated colors are the initial actual colors.
Each vertex records whether its simulated color was ever changed by
the simulation of .
This
allows the algorithm to maintain the set .
Each vertex has an indication whether it is “special” or not. Initially all vertices are not special.
Action:
Upon the arrival of edge :
a.
If is
-moderate then
send to (which updates );
//
set for every non-special vertex .
b.
Else
If both and are not special then mark as special.
c.
Invoke
Procedure :
1.
If and are special then
if is monochromatic then
recolor with a free special color. // there are special colors
2.
Else
If is special then
if is colored by a basic color then
recolor with a free special color.
// first time is colored special
3.
Else
If is special then // this case cannot happen because of the way recx is used.
if is colored by a basic color then
recolor with a free special color.
We prove the lemma by induction on . The base case is , in which and hence any coloring is valid. For the inductive step, we first consider all edges but the new edge and for those we proceed in two sub-steps. Then we consider the new edge .
For all edges but , if is not a simulated edge and is not sent to , then the first sub-step is empty. If is a simulated edge and is sent to , then the colors of some non-special vertices may change. After this sub-step, for each (old) edge: (1) if its two endpoints are non-special then the edge is not monochromatic by the correctness of ; (2) if its two endpoints are special, then their color does not change in this sub-step and the edge is not monochromatic by the induction hypothesis; (3) if one endpoint is special and the other is not, then one and only one endpoint is colored by a special color, and hence the edge is not monochromatic.
The second sub-step is the invocation of recx on the input edge. Following this invocation one vertex might be recolored to a special color. Clearly any (old) edge with at least one node not special remains non-monochromatic by the induction hypothesis. For an (old) edge with two special endpoints, if their color is not changed, they remain non-monochromatic by the induction hypothesis. For such an edge for which one of its endpoints changed color by recx, the code ensures that it is non-monochromatic after the execution of recx.
Now as to the edge itself, we have a number of cases depending whether it is a simulated edge and the status (special or not) of its two endpoints when step begins.
-
1.
If its two endpoints are non-special when step starts:
-
if is a simulated edge: at the end of the first sub-step is not monochromatic by the correctness of ; none of its endpoints is marked special and hence recx does not recolor any node and remains non-monochromatic.
-
if is not a simulated edge: One of its endpoints is marked special; recx recolors that vertex by a special color, while the other endpoint remains colored by a basic color; hence is not monochromatic.
-
-
2.
If its two endpoints are special when step starts, then regardless of whether is a simulated edge or not the code of recx ensures that is not monochromatic.
-
3.
If one endpoint is special and the other is not when step starts, then regardless of whether is a simulated edge or not, the status of neither vertex changes, and one of them remains colored by a special color and the other by a basic color, hence is not monochromatic.
We now turn to analyze the competitiveness of our algorithm. To this end, we first prove the following property about graphs with bounded bond size.
Lemma 10.
Let be a connected graph with largest bond size at most , and let be a partition of such that the induced subgraph is connected, for every . Then the number of edges which are not contained in any of these induced subgraphs (i.e., the number of edges with endpoints in two different parts of the partition) is at most .
Proof.
Consider the multi-graph obtained from by contracting each to a single node and eliminating self-loops. We shall prove that .
First, we note that , and that the size of the largest bond of is at most . We now prove, by induction on , that if a loop-free multigraph has nodes and bond size at most , then . The base case is ; in this case, is empty since does not contain self loops.
For the inductive step, fix any . Let be an arbitrary node in , and let . We proceed according to the connectivity of . If is connected, then the degree of is at most . Since , by the induction hypothesis and the fact that the size of the largest bond of is at most the size of the largest bond of (which is at most ), we have that .
Otherwise, is disconnected. Let be the set of vertices of an arbitrary connected component of , and denote . Let , and . Trivially , and , where and are the number of edges in and in , respectively. Since the largest bond of a subgraph is no larger than the largest bond of the original graph, and since the number of nodes in each of and is strictly less than , by the inductive hypothesis we have that and . It follows that .
Corollary 11.
Let be a graph with , and let be a collection of disjoint subsets of vertices in such that is connected for all . Then i.e., the number of edges with endpoints in two different subsets is at most .
Proof.
Let be any partition of such that:
-
for each , , and is connected; and
-
is exactly the set of vertices which are not connected in to any vertex of .
This can be achieved by associating each vertex of with the set closest to it (like in a Voronoi partition). Note that we may assume without loss of generality that is empty: otherwise, consider the graph : Clearly, by the definition of , the number of edges connecting vertices in different in and is the same.
Since every edge between two subsets connects different parts of the partition and , the result follows from Lemma 10, when applied to each connected component of separately.
We proceed to bound from above the cost of Algorithm . The cost consists of two parts: the cost incurred by Procedure recx and the cost due to the simulation of . We start by stating a number of facts due to the definition of the algorithm.
Fact 12.
A vertex which is colored by a special color after step must belong to a connected component of that has more than vertices of .
Proof.
Observe that a node is colored by a special color only in procedure recx, when it is a special vertex. Moreover, it is marked special only when an edge arrives, and that edge is in . It follows that there is an edge , for , which connects two large and heavy connected components of . Hence, is part of a large connected component of which has more than vertices of .
Recalling the sequences and defined in Definition 8 as a function of any sequence , we prove the following lemma that allows us to (indirectly) give an upper bound on the number of vertices that require “special treatment”.
Lemma 13.
For any given , and , it holds that , where is the set of vertices whose colors are modified when is given as input to .
Proof.
In order to prove the lemma we maintain, as the input sequence proceeds, sets of vertices, , which are pairwise disjoint; furthermore, all vertices in each belong to the same connected component of the input graph (with respect to all edges, not only those in ). We call the sets witness sets. We construct the witness sets online as follows. Initially, there are no witness sets. When an edge arrives, we modify the witness sets as follows.
-
I
If none of is already in one of the existing witness sets, and if the connected component that contains (after is added to the graph) has at most vertices from : do nothing.
-
II
If none of is already in one of the existing witness sets, and if the connected component that contains (after is added to the graph) has more than vertices from : create a witness set which contains all the vertices in that connected component.
-
III
If one of , w.l.o.g. , is already in an existing witness set, say , and is not: add all the vertices of the connected component of to . (As we prove below in Point 4, these vertices do not yet belong to any witness set.)
-
IV
If both are already in some witness sets (possibly the same one): do nothing.
Intuitively, witness sets are created when a connected component passes the “critical mass” threshold of vertices from , and vertices that do not belong to any witness set are added to the witness set they encounter, i.e., the set of the first vertex that belongs to a witness set, to which they are connected.
The following properties follow from a straightforward induction on the input sequence.
-
1.
All the vertices of a given witness set are in the same connected component of . This is because a new witness set is created from connected vertices. Moreover, additions to a witness set are always in the form of vertices connected to vertices already in that witness set.
-
2.
All the vertices in a connected component of with more than vertices of are in some witness set (not necessarily all in the same witness set). This follows by induction on the arrival of new edges of and the actions relative to witness sets taken when this happens.
-
3.
Every two vertices which are in the same connected component of are either both in some witness set (not necessarily the same), or both are not in any witness set. This follows from the fact that the actions taken regarding witness sets exclude the possibility of an edge with exactly one endpoint in a witness set.
-
4.
If a vertex belongs to some witness set at some point of the execution, then belongs to in the remainder of the execution. This follows from the fact that a vertex becomes a member of witness set only in Cases II or III above.
It follows from the above properties that the total number of witness sets is at most , because each witness set that is created requires at least distinct vertices of , vertices do not change their witness set, and the sets are pairwise disjoint.
Next, we claim that when an edge is added to (i.e., it connects two distinct large-and-heavy connected components of ), then the vertices of and already belong to two distinct witness sets. By definition, each of and contains more than vertices of , and hence, by Point (2) above, the endpoints of are already associated with witness sets. To show that the endpoints of belong to distinct witness sets, assume, by way of contradiction, that the endpoints of belong to the same witness set. Then from Point 1 we have that and are already connected in (but, by assumption, they are not connected in ). Let be the first edge (according to the order of the arrival of the edges) in that completes a path from some node in to some node in . Since , it must be the case that when arrived, both of its endpoints belonged to two large and heavy connected components of . Point 2 ensures then that the vertices of and are already in witness sets. Point 1 implies that these witness sets must be distinct, because before the arrival of , and are not connected to each other in . The sets to which the vertices of and belong are the same, and hence distinct, when arrives, by Point 4. This is in contradiction to the assumption that the witness sets are the same.
Thus, an edge is added to only when its endpoints are in two distinct witness sets. Since there can be at most such sets, we get from Corollary 11 and the assumption that the graph has bond size at most , that there are at most such edges.
Lemma 14.
The total cost incurred in procedure recx is , where is the set of vertices ever recolored by .
Proof.
Procedure recx only recolors vertices that are marked special. For each special vertex , the procedure recx recolors from a basic color to a special color exactly once in the step when becomes special, and might recolor again when a new edge arrives, and also is marked special. Let be the set of vertices ever marked special, and the set of edges such that when they arrive both their endpoints are marked special.
A node is marked special only when an edge arrives and . By Lemma 13 , and hence .
Let , and . By applying Corollary 11 with sets , we have that .
The cost of recx is therefore
Next, we bound from above the cost incurred by the simulation of . We need a refined analysis of Algorithm . In the following two lemmas, we recall properties of from [1]. The first lemma relates the number of vertices recolored by to the optimal cost.
Lemma 15 ([1], Lemma 3.4).
Let denote the offline cost for input when using two colors of unit cost. Then .
The next lemma is used to upper-bound the number of times a vertex is recolored by .
Lemma 16 ([1], Proposition 3.5).
Let denote the number of vertices recolored by in step . There exists a subset of steps such that . Moreover, for every , if the arriving edge connects two distinct connected components and , and recolors , then .
In [1], Lemma 15 and Lemma 16 are used to show an bound on the competitive ratio of . Here, we prove a tighter bound on the competitive ratio when the input sequence is moderate (cf. Definition 7). The proof uses amortized analysis by designing an appropriate charging scheme.
Lemma 17.
If is a -moderate input sequence, then .
Proof.
Let be the set of vertices recolored by so far after it processed the th input edge. Let be the subset of steps given by Lemma 16; it suffices to bound from above the cost incurred by on steps in . We will do this via a charging scheme.
The high-level intuition behind the charging scheme is as follows. Let , and suppose connects components and , and that in response, recolors (recall that we consider bipartite graphs and two colors, hence a monochromatic edge must connect two distinct connected components). Our goal is to charge a the load of on certain vertices and show that (1) the total charge in each step is at least a constant fraction of or and (2) every vertex is charged times in total over the course of the input sequence. There are four cases to consider and each case will use a different type of charging. (1) The first is when is small, i.e. . In this case, we charge every vertex in . Lemma 16 implies that a vertex can only be charged by this charging type a total of times. (2) The second case is when is large and light. In this case, we charge to the vertices of that are newly recolored by the algorithm. Since is light, the number of vertices that are recolored for the first time by in this step is sufficiently large. Since this type of charging charges newly recolored vertices, a vertex can be charged by this charging type at most once.
The remaining possibilities concern case (3) when is large and heavy. We consider two subcases. (3.1) The first subcase is when is large and heavy and is small and heavy. In this case, we charge to . Lemma 16 implies that is at least an fraction of . Moreover, since the vertices in are part of a large component after this step, a vertex can be charged by this charging type at most once. The final and most interesting case is (3.2) when is light. To handle this case, we maintain, for each (maximal) connected component that exists at a given time, a subset of vertices. We will charge to the vertices of in this case. The sets are defined inductively as described in the pseudocode of the charging scheme below. As we prove below, each vertex is charged by this type of charging only once, we the size of the sets is large enough to compensate for the cost of recoloring.
Note that these cases are exhaustive as and cannot be both large and
heavy, otherwise the edge would not have been input to the simulation . The following summarizes in a formal manner the charging scheme described above. We then formally prove the desired properties of the charging scheme as stated informally above.
Charging scheme
Initially, for every vertex .
When a new edge arrives connecting components and :
1.
Suppose recolors
(a)
Charge vertices as follows:
i.
If is small, then charge to each vertex in
ii.
If is large and light, then charge
to each vertex in , i.e., the vertices of
that were never recolored before step .
iii.
If is large and heavy, small and heavy, then charge to each vertex in
iv.
If is large and heavy, light, then charge to each vertex in .
(b)
If is light, then ; else
2.
If does not recolor, then
Observe that every vertex charged is either in , the component being recolored, or was previously recolored (case 1(a)iii). Thus every vertex that is charged is in . It now remains to show that in each step, the number of vertices being charged is at least a constant fraction of the number of vertices being recolored – i.e. the total charge received by the vertices can pay for the recoloring cost – and that each vertex is not charged more than times.
Claim 18.
Consider a connected component that exists after an arbitrary step , and the set defined by the charging scheme. For every , we have .
Proof.
We prove this claim by induction on , the base case being . By definition for , such that , and hence the claim hold, since . For the inductive step, suppose that , and that and . If (which occurs in two distinct cases in the specifications of the charging scheme) then, since ,
Otherwise, . Then, when arrived, recolored one of the two connected components and the other connected component was light. Suppose w.l.o.g. that recolored , and was light. Then, we have
By the lightness of , we have that by Lemma 16. This concludes the induction argument.
Claim 19.
Suppose recolors component at step . Then the number of vertices being charged is at least .
Proof.
We show that the number of vertices being charged is at least in every case. In case 1(a)i, we charge so this clearly holds. In case 1(a)ii, lightness of implies that . In case 1(a)iii, we have where the first inequality is due to being heavy and the second due to Lemma 16. For case 1(a)iv, we get that from Claim 18.
Claim 20.
Every vertex is charged at most times.
Proof.
By Lemma 16, the number of times a vertex is charged due to case 1(a)i is . The number of times a vertex is charged due to line 1(a)ii is at most once since it is recolored and now belongs to . The number of times it can be charged due to 1(a)iii is at most once since it now belongs to a large component. The number of times it can be charged due to 1(a)iv is at most once since afterwards it belongs to and thus cannot be in for any future component, due to the way the set is modified in 1b.
Combining the fact that only vertices in can be charged and Claims 19 and 20, we are done proving Lemma 17.
We are now ready to conclude the analysis of Algorithm .
Proof of Theorem 2.
By Lemma 14, the total cost incurred by recoloring using a special color is . Next, note that by the code the sequence given as input to , , is -moderate. It therefore follows from Lemma 17 that the total cost due to the simulation of is . Since by Lemma 15 the optimal cost is , we are done by picking, say, .
4 Uniform cost
In this section, we still consider vertex recoloring of bipartite graphs, but now in the setting where that all colors, basic and special, have the same cost. We thus present an algorithm which has better competitive ratio if more than two colors are available, covering the spectrum between an competitive ratio with no special colors, and a competitive ratio with special colors, where is an upper bound on the size of graph bonds. Specifically, we prove Theorem 4, reproduced below.
See 4
The idea is to use instances of Algorithm (Alg. 1 of [1]) for recoloring bipartite graphs.
High-Level Description.
We push the ideas of simulation and promoting vertices to be “special”, used in algorithm , even further. Roughly speaking, the main idea of the algorithm is to create multiple (possibly overlapping) subinstances of the problem, such that the input sequence of each subinstance is moderate, as in Definition 7. Each subsequence is fed into a different instance of , which uses a distinct pair of colors. At every point in time, each vertex is associated with some instance , which determines its actual color.
More specifically, denote the th instance of by , its input sequence by , and the coloring that it maintains at any time by . Each vertex is associated at any given time with one of the instances, denoted . Initially, for all . We define . determines the coloring of : . Our algorithm maintains the following invariants: (1) each subsequence is moderate; (2) for each level , the coloring is a valid coloring of with respect to where is the graph consisting of every edge in the entire input sequence, not just those of .
Suppose that when an edge arrives, and have the same color. This can only happen if they have the same level . We first check if appending to is still moderate. If it is, then we append and send to , and recolor vertices of level accordingly. Otherwise, we choose one of them, arbitrarily, to promote to level .
When we promote a vertex to level , in order to maintain invariant (2), we attempt to append, one-by-one, each edge in which to , in arbitrary order. In this process, if for some edge , we are unable to append it to without maintaining the moderate property, we promote to the next level. Note a vertex cannot be promoted indefinitely as it eventually ends up at a level with no other vertices.
Pseudocode of our algorithm is given below.
Algorithm : Coloring a bipartite graph of largest bond size using colors.
a.
Set for all .
b.
Set to be the initial vertex coloring.
c.
Fix an arbitrary initial coloring for , say for all
.
d.
Let .
// is a constant parameter in
e.
When edge arrives:
(1)
If then return; // different
colors
(2)
Let // as well
(3)
If is
-moderate, then send to // is
appended to
(4)
Else invoke
// is -excess; is chosen arbitrarily
f.
Output coloring for all .
Procedure :
1.
Let
// gets the initial color of
2.
Let be an arbitrary ordering of the edges arrived so far, such that .
3.
For each edge in :
(a)
If is
-moderate, send to
// is appended to
(b)
Else invoke and return
// is -excess
4.
// promotion to level was successful
4.1 Analysis
Claim 21.
Let . At any time , if , then .
Proof.
At any time , if at the beginning of time step , , we are done as the levels do not change (step 5(a)). If at the beginning of time step and is moderate then is added (step 5(c)), and the claim holds. In the remaining case (Step 5(d)), is promoted and is not, hence their level will not be the same at the end of time step .
The correctness of the algorithm is now straightforward.
Lemma 22.
The coloring produced by Algorithm is correct.
Proof.
Follows from the fact that at any time (1) two vertices of different levels are not colored by the same color, (2) if an edge exists and , then (3) the correctness of for all .
We now proceed to give an upper bound on the cost paid by Algorithm and on the number of colors it uses. Recoloring occurs in either by some or by procedure promote (which recolors to the initial color of the corresponding level). We analyze each separately.
Let us denote by the optimal cost of recoloring an input sequence , when only the two initial colors of unit cost are available; the initial coloring of the vertices is understood from the context. Regarding recoloring by some , we have the following. Let denote the set of vertices whose color was altered by .
Lemma 23.
For all , .
Proof.
Follows from Lemma 17 and the fact that is -moderate by construction.
We note that the recoloring done by the algorithm are either (1) changes of , for such that , done by , or (2) change of the color of due to the change of , in procedure promote. We now analyze the cost due to the latter; the former was analyzed in the above lemma.
We use the following definition.
Definition 24.
Clearly, the total cost due to recoloring by promote is at most , because each excess edge causes at most one vertex to be recolored (indirectly) when promote changes the level of a vertex. Then by Lemma 13 we have:
Lemma 25.
for every .
We now have that the total cost of the algorithm is
(1) |
Next, we bound . We will need the following lemma.
Lemma 26.
Let denote the set of edges in . Then for every , .
Proof.
Let be the set of vertices to which was applied at some point in the algorithm. Clearly, , because each -excess edge promotes a single vertex to level . It follows that by Lemma 25. Now, , because an edge is appended to only if both its endpoints are in at that time. Since is a subset of the edges of a graph with largest bond size , we have from Corollary 11 that . We therefore conclude that .
We can now prove that decreases exponentially with , for large enough .
Proposition 27.
for every .
Proof.
Since recolors a vertex only if it is incident on an input edge, we have that . The result follows from Lemma 26.
Proposition 27 immediately gives an upper bound on the number of colors used by Algorithm .
Corollary 28.
With and , Algorithm uses at most colors.
Proof.
Let . By Step d of Algorithm , . Clearly, , and hence, by Proposition 27 we have that . Hence, for we have that . The result follows, since .
We can now conclude the analysis of Algorithm .
Proof of Theorem 4.
Fix . The number of colors is given by Corollary 28. By Inequality (1), the total cost of the algorithm is at most
5 Lower Bounds
In this section we prove two lower bounds on online recoloring. The first, Theorem 3, says that no matter how many extra colors we use, if they cost , then the best competitive ratio one can hope for is even if the underlying graph is acyclic. The second lower bound, Theorem 1, shows that if there is no upper bound on the bond size of the graph, the competitive ratio of any online recoloring algorithm is at least .
5.1 Acyclic Graphs
In this subsection we show that the competitive ratio of Algorithm cannot be improved, even by randomized algorithms, as stated by Theorem 3 reproduced below.
See 3
Proof.
By Yao’s Principle, it suffices to show the existence of an input distribution on which the expected cost of any deterministic algorithm is times the optimal cost. We describe such a distribution. Initially, there are vertices, each colored by one of the two basic (unit cost) colors. Without loss of generality, let us assume that is a multiple of vertices. For ease of explanation, we shall assume that the vertices are arranged left-to-right on a line. The input sequence is constructed in phases, where . In phase , edges arrive so that at the end of the phase, each connected component is a path with vertices. Specifically, for each , an edge connecting random endpoints of the -th leftmost path and the -th leftmost path is inserted. Note that after the last phase, we have a set of paths of length vertices each. Note that for every phase , the set of connected components at the end of the phase is predetermined; it is only the order in which the vertices in a connected component appear in the corresponding path that is randomized.
Fix an arbitrary deterministic recoloring algorithm . We now bound from below the expected cost of on the input distribution defined above. We first prove the following lemma.
Lemma 29.
Let be an arbitrary deterministic algorithm that uses only the two basic colors. Let be any integer power of not greater than . Consider a randomized input sequence as described above and a connected component consisting of vertices after phases. Let be the restriction of the input sequence to the connected component. Then we have .
Proof.
In phase , there are merges of paths each containing vertices. Observe that with probability exactly a given merge is monochromatic (i.e., the merging new edge connects two vertices of the same color) independently of all other merges (in the same and other phases). This is because for a given merge, each of the two merged paths have one end colored with each of the two basic colors. Further observe that a monochromatic merge at phase results in recoloring of exactly vertices. Let be the indicator random variable indicating whether at least half of the merges in phase are monochromatic. Clearly, if then the algorithm recolors at least vertices in phase . Moreover, for any , even when conditioned on all (except ), it holds that .
It therefore follows that , and
where the last inequality follows from the fact that is a sum of independent Bernoulli random variables with parameter , and so their sum is at least with probability .
We now continue with the proof of Theorem 3. Consider one of the paths of length that exist after the last phase. We give a lower bound on the expected cost of for re-coloring the vertices of that path. Let be the indicator random variable indicating if uses at least once an extra color (of cost ) for recoloring the vertices of the given path. There are two cases to consider.
-
(1)
If , then , and hence .
-
(2)
Otherwise, . In this case, define a deterministic online recoloring algorithm that uses only the basic colors as follows. mimics so long as uses basic colors. Once uses a special color (if it does), stops mimicking and continues to recolor (properly), using only the basic colors.
We make the following observations.
-
by Lemma 29.
-
The probability that and diverge in their colorings on the path under consideration (and hence do not have the same cost for that path) is less than .
It follows that with probability more than , , and that cost is at least
Therefore, in both cases the expected cost of for recolorings of the vertices in the path that we consider is .
The bound above is the cost for a single component of length . By linearity of expectation, the expected cost of for all components is . On the other hand the cost of the optimal algorithms is for any input sequence. Hence we have a lower bound on the competitive ratio of .
5.2 Bipartite Graphs with Unbounded Bond Size
In this subsection we show that no deterministic online recoloring algorithm can have good competitive ratio for all bipartite graphs with large bond, even when special colors are available. In fact, using special colors cannot improve the competitive ratio beyond the easy bound of Lemma 5 if the bond may be large.
See 1
Proof.
We construct an adversarial input sequence that consists of phases. At any point in time, a vertex is said to be special if the algorithm has recolored it at some earlier point to a special color; the vertex is called basic otherwise. Furthermore, at each phase we characterize the connected components as active or inactive. A component is said to be active if at least half of its vertices are basic, and it is said to be inactive otherwise. Let denote the two basic colors. Initially, each vertex is given either the color or . An active component is said to be -dominated, for if at least a quarter of its vertices are colored (a component may be both -dominated and -dominated).
The construction maintains the following invariant:
-
At the start of phase , every active component has vertices.
In phase , we match active components of the same dominating color in pairs. For each such pair of connected components of the same dominating color, we add a perfect matching between their vertex sets such that at least a quarter of the matching edges (i.e., at least edges) are monochromatic. The process ends once there is at most one active component of dominating color and at most one active component of dominating color .
We claim that the cost paid by the algorithm for the above input sequence is at least . To prove the claim, let be the number of special vertices at the end of the input sequence, and let be the number of edges that were monochromatic when they arrived. Clearly, the cost for the algorithm is at least . Now, if , then the algorithm’s cost is and the claim holds. Otherwise, , and hence, by the definition of active components, at the end of the execution, there are at most vertices in inactive components. It follows that in each phase there are at least vertices in active components, and therefore at least vertices in active components of the same dominating color, which implies that in each phase, the number of introduced monochromatic edges is . Further, note that if then the number of phases is at least : before every phase , each connected component contains less than vertices, and hence there are at least active connected components, so there are at least two connected components dominated by the same color. It follows that the total cost of the algorithm is .
In summary, we have shown that the cost of the online algorithm for the input sequence specified above is . As the optimal cost is the theorem follows.
We note that the largest bond size of any active connected component in the construction above is .
6 Conclusions
In this paper we studied competitive vertex recoloring with weighted augmentation. We have shown that the competitive ratio of recoloring bipartite graphs may be reduced if the online algorithm can use additional colors, even if they are more costly than the basic two colors. Beyond the direct technical contribution, we believe that we introduced some conceptual contributions:
-
The approach of weighted resource augmentation is new, as far as we know.
-
The concept of the largest graph bond as a way to generalize algorithmic results quantitatively.
It seems that these ideas can be useful in dealing with other problems of competitive analysis.
References
- [1] Yossi Azar, Chay Machluf, Boaz Patt-Shamir, and Noam Touitou. Competitive vertex recoloring. Algorithmica, 85(7):2001–2027, 2023. doi:10.1007/s00453-022-01076-x.
- [2] Reuven Bar-Yehuda and Shimon Even. A linear-time approximation algorithm for the weighted vertex cover problem. Journal of Algorithms, 2(2):198–203, 1981. doi:10.1016/0196-6774(81)90020-1.
- [3] Luis Barba, Jean Cardinal, Matias Korman, Stefan Langerman, André van Renssen, Marcel Roeloffzen, and Sander Verdonschot. Dynamic graph coloring. Algorithmica, 81(4):1319–1341, 2019. doi:10.1007/s00453-018-0473-y.
- [4] J.A. Bondy and U.S.R Murty. Graph Theory. Springer Publishing Company, Incorporated, 1st edition, 2008.
- [5] Allan Borodin and Ran El-Yaniv. Online Computation and Competitive Analysis. Cambridge University Press, 1998.
- [6] Bartłomiej Bosek, Yann Disser, Andreas Emil Feldmann, Jakub Pawlewicz, and Anna Zych-Pawlewicz. Recoloring Interval Graphs with Limited Recourse Budget. In Proc. 17th Scandinavian Symposium and Workshops on Algorithm Theory (SWAT 2020), volume 162 of Leibniz International Proceedings in Informatics (LIPIcs), pages 17:1–17:23, Dagstuhl, Germany, 2020. doi:10.4230/LIPIcs.SWAT.2020.17.
- [7] Gabriel L. Duarte, Hiroshi Eto, Tesshu Hanaka, Yasuaki Kobayashi, Yusuke Kobayashi, Daniel Lokshtanov, Lehilton L. C. Pedrosa, Rafael C. S. Schouery, and Uéverton S. Souza. Computing the largest bond and the maximum connected cut of a graph. Algorithmica, 83:1421–1458, January 2021. doi:10.1007/S00453-020-00789-1.
- [8] F. Hadlock. Finding a maximum cut of a planar graph in polynomial time. SIAM J. Comput., 4(3):221–225, 1975. doi:10.1137/0204019.
- [9] Monika Henzinger, Stefan Neumann, and Andreas Wiese. Explicit and implicit dynamic coloring of graphs with bounded arboricity. CoRR, abs/2002.10142, 2020. arXiv:2002.10142.
- [10] Manas Jyoti Kashyop, N. S. Narayanaswamy, Meghana Nasre, and Sai Mohith Potluri. Trade-offs in dynamic coloring for bipartite and general graphs. Algorithmica, 85(4):854–878, 2023. doi:10.1007/s00453-022-01050-7.
- [11] Rajmohan Rajaraman and Omer Wasim. Competitive capacitated online recoloring. In Timothy Chan, Johannes Fischer, John Iacono, and Grzegorz Herman, editors, 32nd Annual European Symposium on Algorithms, ESA 2024, September 2-4, 2024, Royal Holloway, London, United Kingdom, volume 308 of LIPIcs, pages 95:1–95:17. Schloss Dagstuhl – Leibniz-Zentrum für Informatik, 2024. doi:10.4230/LIPICS.ESA.2024.95.
- [12] Daniel D. Sleator and Robert E. Tarjan. Amortized efficiency of list update and paging rules. Comm. ACM, 28(2):202–208, 1985. doi:10.1145/2786.2793.
- [13] Shay Solomon and Nicole Wein. Improved dynamic graph coloring. ACM Trans. Algorithms, 16(3):1–24, June 2020. doi:10.1145/3392724.