1 Introduction

Coloring problems deal with partitioning the objects of a graph into classes according to different criteria, and appear in many areas with seemingly no connection with coloring: time tabling and scheduling [3], frequency assignment [17], register allocation [4], printed circuit board testing [10], pattern matching [15] or analysis of biological and archeological data [2]; see also [16] for descriptions of the first four mentioned applications.

The classical coloring problem uses proper colorings: a k-proper coloring is an assignment of k colors to the vertices of a graph so that no edge has both endpoints of the same color. This is an NP-hard problem for three or more colors (and polynomial for two colors), which has received a large attention in the literature, not only for its real world applications, but also for its theoretical aspects and computational difficulty; see, for instance [5, 9].

Other different criteria have been considered in coloring problems as the equitable partition, that is, partitioning the vertex set of a graph into equal or almost equal subsets. Formally, a graph is equitable k-colorable if it admits a k-proper coloring such that the cardinalities of any two color classes differ by at most one.

Equitable coloring of graphs was introduced by Meyer [14] for modeling problems in an operations research context, and has since been widely investigated due to its many practical applications in sequencing and scheduling; see for example [8] and the references therein, in particular, [7] for a specific application in scheduling. As explained in [8], this type of coloring models situations in which one desires to split a system into equal or almost equal conflict-free subsystems. However, not every system admits such a division, and other criteria are needed in order to approach as much as possible the equitable partition; here arises the robust coloring problem (RCP, for short) that can be stated as follows:

Let \(G=(V(G),E(G))\) be an unweighted and simple graph with chromatic number \(\chi (G)\). Given a subgraph H of its complement graph \({\overline{G}}\) and a positive integer \(k\ge \chi (G)\), find a k-proper coloring \(\phi \) of G that minimizes, over all those k-proper colorings, the number of monochromatic edgesFootnote 1 in the induced coloring on H. We say that \(\phi \) is a k-robust coloring of (G, H), and m(GHk) is such minimum.

The original statement of the problem introduced in [19] considers H to be a weighted graph, and the goal is to minimize the sum of the weights of the monochromatic edges. Our statement establishes all edge weights in H to be 1, as both versions are equivalent for most of the questions addressed in this work, and for those that are not, our arguments can be adapted. We will be more precise on this issue in each of the sections below, once the different problems that we approach have been described in detail.

Applications of robust coloring are summarized in [12, 19]; among them, it highlights applications to timetabling and scheduling problems, geographical maps, and aircraft assignment. For example, the aircraft assignment problem can be modeled as a graph coloring problem where each vertex in the graph G represents a flight route and each color represents one aircraft. There is an edge between two vertices if an aircraft cannot serve the two flight routes represented by the two vertices. If flight-delays are taken into account, the overlap relationship between flight routes changes, and this information is captured by the edges of a new graph H. The monochromatic edges in H represent cancelled flights, and the goal is to minimize the number of flights that must be cancelled when there are k aircrafts.

Related work. As it was mentioned before, the RCP was introduced in [19], where the authors also describe several applications of this coloring model, and conclude that the decision problem is NP-complete for \(k\ge 3\). They also present a binary programming model and outline a genetic algorithm. Due to their complexity result, most papers in the topic search for heuristics. In [18] the authors develop several meta-heuristics to solve the RCP including genetic algorithm, simulated annealing and tabu search. A column generation-based heuristic algorithm is presented in [20]. A study on the robust aircraft assignment is developed in [12]; the authors propose new techniques for an approximate solution of the problem, such as the partition based encoding and several meta-heuristics (local search, simulated annealing, tabu search and hybrid method). Other references in this direction are [1, 6]. Almost no progress has been made in other directions: we can only refer the reader to [13] for a theoretical study on the RCP for the case of G and H being paths on the same set of vertices and the value \(k=3\). The authors present an exact but exponential algorithm to find a 3-robust coloring of (GH), and a randomized algorithm and a greedy algorithm analyzing the cost of their output. They also apply their randomized algorithm to obtain bounds on the problem of maximizing the sum of the weights (costs) of the monochromatic edges of H, and pose two conjectures related with bounding the number of monochromatic edges of H induced by a 3-coloring of G.

Our results. We present a non-heuristic approach to the RCP for general graphs. In Sect. 2, we first prove that robust coloring is the model that better approaches the equitable partition even when the graph has no equitable coloring; if the graph admits such a coloring, we extend the known connection between robust colorings of \((G, {\overline{G}})\) and equitable colorings of G to a broad class of subgraphs H. The NP-complete nature of the decision problem of robust coloring is then established in Sect. 2.1 for the unsolved case of two colors, in contrast to the corresponding decision problems for classical graph coloring and equitable coloring. Section 2.2 focuses on the modifications required by the greedy algorithm for classical graph coloring in order to guarantee an optimal solution (for some vertex ordering) when dealing with robust colorings and equitable colorings. We introduce the robust-greedy algorithm as the variation satisfying that property. This algorithm is key in Sect. 3, where we first obtain a tight upper bound on m(GHk) for arbitrary graphs G and subgraphs H, and then for graphs defined as \(\alpha \)-greedy orientable (this includes trees, some series–parallel graphs and bipartite outerplanar graphs). In Sect. 4, we prove in the affirmative a conjecture posed by López-Bracho et al. [13] on m(GH, 3) for G and H being two paths on the same set of vertices, and extend the result to H being a vertex-disjoint union of paths; the solution of this conjecture illustrates very well the complexity of dealing with robust colorings.

We assume \(k<\textrm{min}\{|V(G)|, \chi (G)\chi (H)\}\) for otherwise \(m(G,H,k)=0\) as there are always enough colors to obtain a proper coloring in G and also in H. In addition, for short, we omit the term proper and simply say coloring when no confusion may arise.

2 Robust Colorings as an Approach to Equitable Colorings

When a graph G has an equitable coloring, one obtains a uniform distribution of colors on the vertices, and the question is whether this decreases the number of monochromatic edges in a subgraph H of \({{\overline{G}}}\), but this question can not be answered for an arbitrary H as the answer would completely depend on its structure. Thus, it makes sense to study the connection between equitable colorings and robust colorings when H is the whole \({\overline{G}}\). In this section, we go further by setting H as the induced subgraph in \({\overline{G}}\) by a subset of vertices \(S\subseteq V(G)\). We denote this graph as \({\overline{G}}[S]\), see Fig. 1 for some examples.

Fig. 1
figure 1

A 3-coloring of \(K_{3,3}\), and the induced edge colorings in \(\overline{K_{3,3}}\), \(\overline{K_{3,3}}[S']\), and \(\overline{K_{3,3}}[S'']\); the sets \(S'\) and \(S''\) admit an equitable 3-coloring, and S does not

For graphs G that admit an equitable coloring, it is known that a k-coloring of G is equitable if and only if it is a k-robust coloring of \((G, {\overline{G}})\); this can be deduced, for instance, from [19, Proposition 3.1]. We first prove that, even if G does not admit an equitable coloring, robust coloring is the model that better approaches the uniform distribution of colors.

Let \(S\subseteq V(G)\), and consider the color classes \(C_1, \ldots ,C_k\) that partition V(G) by a k-coloring \(\phi \) of G (each class contains the vertices with the corresponding color). Let \(P_{\phi , S}=(n_1, \ldots , n_k)\) be the partition of |S| associated to the coloring \(\phi \), where \(n_i=|C_i\cap S|\). We say that \(\phi \) is equitable over S if \(P_{\phi , S}\) satisfies that \(|n_i-n_j| \le 1\) for \(1\le i, j \le k\); with some abuse of the language, we may indistinctly say that S admits an equitable k-coloring (see Fig. 1). There are monochromatic edges in the induced edge coloring of \({\overline{G}}[S]\) if and only if \(n_i>1\) for some \(1\le i\le k\); each pair of vertices of S in the same color class \(C_i\) determines a monochromatic edge, and so the total number of monochromatic edges induced by the partition \(P_{\phi , S}\) in \({\overline{G}}[S]\), denoted by \(m(P_{\phi , S})\), is

$$\begin{aligned} m(P_{\phi , S}) = \sum _{1\le i \le k, n_i>1} {n_i \atopwithdelims ()2},\end{aligned}$$
(1)

which can be rewritten as

$$\begin{aligned} m(P_{\phi , S})=\frac{1}{2} \sum _{i=1}^{k} (n_i^2-n_i)=\frac{1}{2} \sum _{i=1}^{k} \left( \left( n_i-\frac{1}{2}\right) ^2-\frac{1}{4}\right) = -\frac{k}{8}+\frac{1}{2} d^2(P_{\phi , S},Q), \end{aligned}$$

where \(d(P_{\phi , S}, Q)\) is the Euclidean distance between the point \(P_{\phi , S}{=}(n_1, \ldots , n_k)\) and the point \(Q=(\frac{1}{2},\dots ,\frac{1}{2})\) in a k-dimensional space. (Note that, in the above equation, we include in the sum the case \(n_i=1\) since \(n_i^2-n_i=0\).)

We can thus conclude that \(m(P_{\phi , S})\) is mimimum over all k-colorings \(\phi \) of G if and only if \(d(P_{\phi , S}, Q)\) is minimum. Hence, minimizing the number of monochromatic edges in the induced coloring of \({\overline{G}}[S]\) is equivalent to finding the point \(P_{\phi , S}\) in the hyperplane described by the equation \(n_1+n_2+ \ldots +n_k=|S|\) that minimizes the distance to Q. Further, \(d(P_{\phi , S}, Q)\) is minimum if and only if \(d(P_{\phi , S}, P_{|S|,k})\) is minimum, where \(P_{|S|,k}=(\frac{|S|}{k}, \ldots , \frac{|S|}{k})\) is the orthogonal projection of Q onto that hyperplane. Observe that \(P_{|S|,k}\) represents the ideal uniform distribution into the k color classes. This distribution may not exist (|S| might not even be divisible by k) but we have shown that the k-robust coloring is the closest to it under the Euclidean metric; this is the content of the following theorem.

Theorem 2.1

A k-coloring \(\phi \) of a graph G is a k-robust coloring of \((G, {\overline{G}}[S])\) if and only if \(d(P_{\phi }, P_{|S|, k})\) is minimum over all k-colorings of G.

Consider now a k-robust coloring \(\phi \) of \((G, {\overline{G}}[S])\) and the partition \(P_{\phi , S}=(n_1,\dots , n_k)\). Suppose that \(n_i<n_j\) for some \(1\le i,j\le k\), and let \(P=(n_1, \ldots , n_i+1, \ldots ,n_j-1, \ldots n_k)\); this is a k-partition of |S| that is not necessarily associated to a k-coloring but, with some abuse of notation, we set m(P) as

$$\begin{aligned} m(P)= {n_i+1 \atopwithdelims ()2} +{n_j-1 \atopwithdelims ()2}+\sum _{\ell \ne i,j} {n_{\ell } \atopwithdelims ()2}. \end{aligned}$$

By Eq. (1), we have \(m(P_{\phi , S})-m(P) = n_j-n_i-1\ge 0\), and so \(m(P_{\phi , S})\ge m(P)\). Therefore, any partition of |S| satisfying that any two of its elements differ by at most one is a minimum of the function \(m(\cdot )\) over all k-partitions of |S|. Thus, we have proved the following proposition, where we also give the minimum value of the function \(m(\cdot )\), which is straightforward.

Proposition 2.1

For every \(k\ge \chi (G)\) it holds that:

$$\begin{aligned} m(G,{\overline{G}}[S],k)\ge (k-r) {s \atopwithdelims ()2} + r {s+1 \atopwithdelims ()2}, \end{aligned}$$

where \(s=\left\lfloor \frac{|S|}{k}\right\rfloor \) and \(r=|S|-sk\). Moreover, the bound is tight if and only if S admits an equitable k-coloring.

The preceding lower bound is the number of monochromatic edges in the induced edge coloring of \({\overline{G}}[S]\) by an equitable k-coloring over S, if it exists. Thus, we extend the known connection between equitable colorings and robust coloring to the graph \({\overline{G}}[S]\).

Theorem 2.2

Let \(S\subseteq V(G)\) be a subset of vertices that admits an equitable k-coloring. Then, a k-coloring \(\phi \) of G is equitable over S if and only if \(\phi \) is a k-robust coloring of \((G, {\overline{G}}[S])\).

We next illustrate the previous results with some examples.

Example 2.1

Figure 2 shows a 4-equitable coloring of a graph G, which by the relation between equitable colorings and robust colorings, is a 4-robust coloring of \((G, {\overline{G}})\). The problem arises when a graph has no equitable coloring for some value k. This happens to the complete bipartite graph \(K_{3,3}\) when setting \(k=3\) since any 3-coloring generates color classes \(C_1, C_2, C_3\) of cardinality 1, 2, 3, respectively. See Fig. 1. Theorem 2.1 establishes that the closest partition of the vertex set to an equitable partition is given by a 3-robust coloring of \((G, {\overline{G}})\). Further, Theorem 2.2 allows us to study the scenario for subsets S of vertices in \(K_{3,3}\). All subsets S containing at most two vertices of class \(C_3\) admit an equitable 3-coloring. Moreover, \(m(G, {\overline{G}}[S],3)\) is either 1 or 2 (depending on the set S considered).

Example 2.2

The argument to prove Proposition 2.1 can be used to obtain robust colorings of \((G, {\overline{G}}[S])\) when the graph G does not admit equitable colorings. For instance, the wheel graph \(W_{1,7}\) with 8 vertices has no equitable colorings as there is always a color class of cardinality 1 (determined by the central vertex). For \(k=4\), the above mentioned argument establishes that the partition (1, 1, 3, 3) can not be associated to a 4-coloring of \(W_{1,7}\) that is a 4-robust coloring of \((W_{1,7}, \overline{W_{1,7}})\), but (1, 2, 2, 3) gives such a robust coloring.

2.1 Complexity of Robust Colorings

The classical graph coloring decision problem is NP-complete for \(k\ge 3\) colors, but polynomial for \(k=2\) [9]. The same happens for equitable k-coloring [8]. Now, consider the following problem:

Robust-Coloring

Instance: A graph G, a subgraph H of \({\overline{G}}\), a positive integer \(k\le |V(G)|\), and \({\overline{m}}\in {\mathbb {N}}\).

Question: Does a k-coloring of G exist such that the number of monochromatic edges in the induced coloring on H is at most \({\overline{m}}\)?

A reduction to graph coloring shows the NP-completeness of Robust-Coloring for \(k\ge 3\) [19, Proposition 3.2]. We next prove that, surprisingly, this decision problem is NP-complete even for \(k=2\).

Theorem 2.3

Robust-Coloring is an NP-complete problem for \(k=2\).

Proof

The problem is in NP since one can compute in polynomial time the number of monochromatic edges induced in H by a given k-coloring of G, and check whether this number is at most \({\overline{m}}\). Consider now the following NP-complete problem [11]:

Simple-Max-Cut

Instance: A graph \(G=(V,E)\), \(\ell \in {\mathbb {N}}\).

Question: Does there exist a set \(S\subset V\) such that \(|\{su\in E \, | \, s\in S, u\in V-S\}| \ge \ell \)?

We next reduce Simple-Max-Cut to our decision problem, thus proving the result. Let \(G=(V,E)\) be a graph with n vertices, and let \(\ell \in {\mathbb {N}}\). Let \(V_n\) be the trivial graph with n vertices (i.e., it has no edges); the graph G is a subgraph of \(\overline{V_n}\). Any 2-coloring of \(V_n\) induces a partition of V into two subsets S and \(V-S\) such that the bichromatic edges in the induced coloring on G are precisely the set \(\{su\in E \, | \, s\in S, \, u\in V-S\}\). Therefore,

$$\begin{aligned} |\{su\in E \, | \, s\in S, u\in V-S\}| \ge \ell \Longleftrightarrow m(V_n, G, 2)\le |E|-\ell . \end{aligned}$$

The inequation \(m(V_n, G, 2)\le |E|-\ell \) is equivalent to the existence of a 2-coloring of \(V_n\) such that the number of monochromatic edges in the induced coloring on G is at most \(|E|-\ell \). \(\square \)

Fig. 2
figure 2

A graph G that admits 4-equitable colorings (as the one shown), which are 4-robust colorings of \((G,{{\overline{G}}})\). None of them can be obtained by the greedy algorithm with any of the 8! possible vertex orderings

2.2 Robust-Greedy Algorithm

For classical graph coloring, it is well-known that there always exists a vertex ordering in any graph such that the greedy algorithmFootnote 2 gives an optimal proper coloring, that is, a proper coloring using the minimum number of colors. However, this is not true for robust coloring, and neither for equitable coloring as the example in Fig. 2 shows. We next introduce a variation of the greedy algorithm, called the robust-greedy algorithm, which captures the constraints of the robust colorings and gives, for some ordering of the vertices of any graph, the closest partition to the equitable partition. Further, this algorithm will lead, together with the notion of \(\alpha \)-greedy orientable graph (introduced in Sect. 3.1), to upper bounds on m(GHk) for well-known families of graphs G and arbitrary subgraphs H of \({\overline{G}}\).

As the classical greedy algorithm for graph coloring, the robust-greedy algorithm also processes the vertices of a graph G in a given ordering, and there is an ordered list of colors (they are simply taken in order). In addition, we must keep track of the number of monochromatic edges on a fixed subgraph H of \({\overline{G}}\).

Robust-greedy algorithm

Each vertex v of G is given the first color c of the list satisfying the two following properties:

  1. (a)

    color c is available for v, i.e., it has not been assigned to the already colored neighbours of v in G;

  2. (b)

    it minimizes, among all available colors for v, the number of monochromatic edges on H with v as an endpoint.

The algorithm stops when all vertices of G have been colored.

As we pointed out before, some questions on robust coloring cannot be approached for general subgraphs H of \({{\overline{G}}}\) since the answer would depend on the structure of H, and it makes then sense to set \(H={\overline{G}}\). This happens in the following theorem.

Theorem 2.4

Let G be a graph, and let \(k\ge \chi (G)\) be a positive integer. There always exists a vertex ordering of G such that the robust-greedy algorithm provides a k-robust coloring of \((G, {\overline{G}})\).

Proof

Let \(\phi \) be a k-robust coloring of \((G, {\overline{G}})\), and consider the color classes \(C_i=\{u_1^i, \ldots , u_{n_i}^i\}\), \(1\le i\le k\), in which \(\phi \) partitions V(G). Assume that the classes are ordered by increasing cardinality: \(n_i\le n_j\) for \(1\le i<j\le k\).

Let \({\mathcal {O}}\) be a vertex ordering obtained by choosing a vertex from each class \(C_i\) in a cyclic way (in increasing order) until there are no vertices left in any of the classes, for example, \({\mathcal {O}}\) could be: \(u_1^1, u_1^2, \ldots , u_1^k, u_2^1, u_2^2, \ldots , u_2^k, \ldots , u_{n_1}^1, \ldots , u_{n_1}^k, u_{n_1+1}^2, \ldots , u_{n_1+1}^k, \ldots , u_{n_k}^k\).

The robust-greedy algorithm assigns color 1 to \(u_1^1\) (the same first color as \(\phi \)), and when it processes \(u_1^2\) it may happen that: (i) \(u_1^1u_1^2 \in E(G)\) and so \(u_1^2\) would be assigned color 2 by condition (a) of the algorithm, or (ii) \(u_1^1u_1^2 \in E({\overline{G}})\) and so, by condition (b) of the algorithm, \(u_1^2\) would also be assigned color 2 (this color minimizes, among colors 1 and 2, the number of monochromatic edges in \({\overline{G}}\) with \(u_1^2\) as endpoint). Hence, the robust-greedy algorithm assigns the same colors as \(\phi \) to \(u_1^1\) and \(u_1^2\). This argument can be extended to the first \(kn_1\) vertices, to which the algorithm assigns the same colors as \(\phi \) generating k color classes with the same size \(n_1\) (after processing the vertices \(u_1^1, u_1^2, \ldots , u_1^k, \ldots , u_{n_1}^1, \ldots , u_{n_1}^k\) of the ordering \({\mathcal {O}}\)).

Now, the algorithm could assign the same colors as \(\phi \) to the remaining vertices but, if at some later stage, the robust-greedy algorithm assigns to a vertex a different color than that assigned by \(\phi \), we stop the algorithm and color the remaining vertices with the same colors as \(\phi \), obtaining a new k-coloring \(\psi \). The associated partitions \(P_{\phi ,V(G)}\) and \(P_{\psi , V(G)}\) only differ in one element: roughly speaking, one vertex has changed from a bigger color class to a smaller one. Following the same argument as for Proposition 2.1, we obtain that \(m(P_{{\phi },V(G)})\ge m(P_{{\psi },V(G)})\). Since \(\phi \) is a robust coloring then \(m(P_{{\phi },V(G)})= m(P_{{\psi },V(G)})\). For each change of color produced by the robust-greedy algorithm, we can argue as above obtaining a sequence of k-robust colorings of \((G, {\overline{G}})\) that lead to the desired k-robust coloring generated by the algorithm. \(\square \)

The analogous of Theorem 2.4 for equitable partitions of vertex sets is obtained from Theorem 2.2 by setting \(S=V(G)\).

Corollary 2.1

For every equitable k-colorable graph G, there always exists a vertex ordering such that the robust-greedy algorithm provides an equitable k-coloring of its vertices.

3 Upper Bounds on m(GHk) for Arbitrary H

In this section we deal with arbitrary subgraphs H of \({\overline{G}}\).Footnote 3 We first present a tight upper bound on m(GHk) for every graph G, for which we need the following technical lemma, where two distinct colorings are considered, one of them not necessarily proper. Thus, to avoid any confusion, the term proper will not be omitted in Lemma 3.1 and Theorem 3.1.

Lemma 3.1

Let \(t\ge 2\). For every proper t-coloring of a graph G and every positive integer \(t'\in [1,t]\) there exists a \(t'\)-coloring of G that induces at most \(|E(G)|\cdot \frac{2(t-t')}{tt'}\) monochromatic edges in G.

Proof

The result is straightforward for \(t'=1\) as |E(G)| is the number of monochromatic edges induced by any 1-coloring of G and \(\frac{2(t-1)}{t}\ge 1\) for \(t\ge 2\). If \(t'=t\) the result establishes that there are no induced monochromatic edges, which is true for any proper t-coloring of G.

Assume now that \(1<t'<t\), and let \(\phi \) be a proper t-coloring of G, which induces an edge coloring of G (according to the colors of the endpoints of the edges) with \({t \atopwithdelims ()2}\) edge color classes. On average, each of these classes contains \(\mu _0 = |E(G)|/{t\atopwithdelims ()2}\) bichromatic edges. Consider a color class with smallest cardinality, say that it corresponds to color ij. We obtain a \((t-1)\)-coloring \(\phi '\) from \(\phi \) by identifying colors i and j. Observe that the number of monochromatic edges induced by \(\phi '\) in G is at most \(\mu _0\). The same argument applies to the coloring \(\phi '\) and the value \(\mu _1 = |E(G)|/{t-1\atopwithdelims ()2}\). Thus, after a reduction of \(t-t'\) colors, we obtain a \(t'\)-coloring of G and the corresponding values \(\mu _0, \mu _1, \ldots ,\mu _{t-t'+1}\); this coloring induces at most the desired number of monochromatic edges:

$$\begin{aligned} \mu _0+\mu _1+\dots +\mu _{t-t'+1}{} & {} =|E(G)|\cdot \left[ \frac{1}{{t\atopwithdelims ()2}}+\frac{1}{{t-1\atopwithdelims ()2}}+\dots +\frac{1}{{t-t'+1\atopwithdelims ()2}}\right] \\{} & {} =|E(G)|\cdot \frac{2(t-t')}{tt'} \end{aligned}$$

\(\square \)

With Lemma 3.1 in hand, we obtain an upper bound on m(GHk) for general graphs G and arbitrary subgraphs H of \({{\overline{G}}}\), in terms of several parameters: the chromatic numbers of G and H, the number of edges of H, and the value k.

Theorem 3.1

Let G be a graph with \(\chi (G)=p\), and let H be a subgraph of \({{\overline{G}}}\) with \(\chi (H)=q\). For every \(k\ge \textrm{max}\{p,q\}\) it holds that

$$\begin{aligned} m(G,H,k)\le \frac{2|E(H)|}{pq}\left[ \frac{(p-r)(q-s)}{s}+\frac{r(q-s-1)}{(s+1)}\right] , \end{aligned}$$

where \(s = \left\lfloor \frac{k}{p}\right\rfloor \) and \(r=k-ps\). Moreover, the bound is tight.

Proof

Let \(\phi \) be a p-proper coloring of G with color set \(\{1,2,\ldots ,p\}\) and color classes \(C_1,\ldots , C_p\) that partition V(G). The induced coloring on H partitions E(H) into the sets \(E_b\) and \(E_{m,i}\) that contain, respectively, the bichromatic edges and the edges with assigned color i in both endpoints for \(1\le i \le p\). Assume that the sets \(E_{m,i}\) are ordered by increasing cardinality.

Let \(H_i\) be the graph with vertex set \(C_i\) and edge set \(E_{m,i}\); this graph might have a number of isolated vertices as there could be vertices of G in \(C_i\) that are endpoints of no monochromatic edge in \(E_{m,i}\). By construction, \(E(H_i)\subset E(H)\) and so \(\chi (H_i)\le \chi (H)=q\). Thus, there exists a q-proper coloring of \(H_i\) and, by Lemma 3.1, for every \(1\le i \le p-r\) there is an s-coloring \(\phi _i\) of \(H_i\) that induces at most \(|E_{m,i}|\cdot \frac{2(q-s)}{qs}\) monochromatic edges in \(H_i\). Note that Lemma 3.1 can be applied by setting \(t=q\) and \(t'=s\) since it is assumed that \(k<\textrm{min}\{|V(G)|, pq\}\), which implies \(s = \left\lfloor \frac{k}{p}\right\rfloor <q\). Analogously, for every \(p-r+1\le i\le p\), we obtain at most \(|E_{m,i}|\cdot \frac{2(q-s-1)}{q(s+1)}\) monochromatic edges in \(H_i\) induced by an \((s+1)\)-coloring \(\psi _i\) (Lemma 3.1 is here applied for \(t=q\) and \(t'=s+1\); note that \(s+1\le q\).)

The union of all s-colorings \(\phi _i\) and all \((s+1)\)-colorings \(\psi _i\) is a k-proper coloring of G since each coloring is acting on a class \(C_i\) whose vertices can have the same color. Further, this union of colorings, when restricted to V(H), is a k-coloring of H with at most

$$\begin{aligned} \frac{2(q-s)}{qs}\sum _{i=1}^{p-r} |E_{m,i}|+\frac{2(q-s-1)}{q(s+1)}\sum _{i=p-r+1}^{p} |E_{m,i}| \end{aligned}$$

monochromatic edges. This value can be rewritten as

$$\begin{aligned} \frac{2(q-s-1)}{q(s+1)}\sum _{i=1}^{p} |E_{m,i}|+\left[ \frac{2(q-s)}{qs}-\frac{2(q-s-1)}{q(s+1)}\right] \sum _{i=1}^{p-r} |E_{m,i}|.\end{aligned}$$
(2)

Let \(\mu =\frac{1}{p}(\sum _{i=1}^{p} |E_{m,i}|)\). As \(\frac{2(q-s)}{qs}>\frac{2(q-s-1)}{q(s+1)}\) and \(|E_{m,i}|\le |E_{m,j}|\) for \(i\le j\), expression (2) is at most

$$\begin{aligned} \frac{2(q-s-1)}{q(s+1)}p\mu +\left[ \frac{2(q-s)}{qs}-\frac{2(q-s-1)}{q(s+1)}\right] (p-r)\mu , \end{aligned}$$

which is

$$\begin{aligned} \frac{2\sum _{i=1}^{p}|E_{m,i}|}{pq}\left[ \frac{(p-r)(q-s)}{s}+\frac{r(q-s-1)}{s+1}\right] . \end{aligned}$$

The desired bound is thus obtained as \(\sum _{i=1}^{p} |E_{m,i}|\le |E(H)|\). Further, it is attained by the graph G and the subgraph H of \({\overline{G}}\) in Fig. 3, and the value \(k=3\); the subgraph H is isomorphic to \({\overline{G}}[S]\) for \(S=\{a,b,c\}\). We have \(\chi (G)=p=3\) and \(\chi (H)=q=2\). For \(k=3\), we obtain \(s=0\) and \(r=1\). The upper bound is then equal to 1, and \(m(G,H,3)=1\) (this follows from the fact that G has a unique 3-proper coloring, also shown in Fig. 3.) \(\square \)

Fig. 3
figure 3

An example of graph G that attains the bound of Theorem 3.1 together with the graph \({\overline{G}}[S]\) for \(S=\{a,b,c\}\) and the value \(k=3\). On the right it is shown the unique 3-proper coloring of G, which generates only one monochromatic edge in \({\overline{G}}[S]\)

Remark 3.1

For \(s = \left\lfloor \frac{k}{p}\right\rfloor =1\), which is the most frequent case (in general the value k does not double the chromatic number of the graph), the upper bound of Theorem 3.1 is

$$\begin{aligned} m(G,H,k)\le \frac{| E(H) |}{p} \left( p- \frac{2r}{q} \right) . \end{aligned}$$

3.1 \(\alpha \)-Greedy Orientable Graphs

We now focus on graphs that satisfy a property called \(\alpha \)-greedy orientable; among this type of graphs highlight: trees, simple series–parallel graphs with chromatic number 3, and simple bipartite outerplanar graphs. To define this key property, we first fix a vertex ordering in a graph G and consider the induced orientation on its edges, that is, vertex u is the tail and v is the head of the oriented edge (uv) if and only if \(u<v\) in the ordering. Let \(\overrightarrow{G}\) be the resulting oriented graph, and let \(\Delta ^{-}(\overrightarrow{G})\) be its maximum in-degree. Observe that the greedy algorithm applied to our vertex ordering gives a coloring of G with at most \(\Delta ^{-}(\overrightarrow{G})+1\) colors, and so \(\chi (G)\le \Delta ^{-}(\overrightarrow{G})+1\). We say that G is \(\alpha \)-greedy orientable for \(\alpha \ge 0\) if there is an ordering of its vertices such that \(\Delta ^{-}(\overrightarrow{G})=\chi (G)-1+\alpha \). Figure 4 illustrates an example.

Our interest is to find vertex orderings whose associated \(\alpha \) is the smallest possible value; this will give interesting upper bounds on m(GHk) as we show next.

Fig. 4
figure 4

For the graph G in (a) we consider two vertex orderings in (b) and (c), and their respective greedy colorings. The ordering in (b) shows that G is 1-greedy orientable, and G is 0-greedy orientable with the ordering in (c)

Consider an \(\alpha \)-greedy orientable graph G, and let \(k\ge \alpha +\chi (G)\). When we apply the robust-greedy algorithm (see Sect. 2.2) to the vertex ordering in G associated to \(\alpha \), there are always \(k-\Delta ^{-}(\overrightarrow{G})\) available colors when a vertex v is processed by the algorithm, that is, \(k-\chi (G)+1-\alpha \) available colors. Further, v is assigned a color that minimizes, at that stage, the number of monochromatic edges in H with v as endpoint. This implies that at most one \((k-\chi (G)+1-\alpha )\)–th of the edges with v as an endpoint are monochromatic. This proves the following upper bound for arbitrary subgraphs H of \({\overline{G}}\).

Theorem 3.2

Let G be an \(\alpha \)-greedy orientable graph, and let \(k\ge \alpha +\chi (G)\). Then,

$$\begin{aligned} m(G,H,k)\le \frac{|E(H)|}{k-\chi (G)+1-\alpha } \end{aligned}$$

for every subgraph H of \({\overline{G}}\).

Fig. 5
figure 5

The reverse order of the series–parallel reduction generates a vertex ordering (numbers in brackets); the associated oriented graph is shown on the right. For short, the deletion of the parallel edges ec and bc is not indicated

The preceding theorem leads to upper bounds on m(GHk) for well-known families of graphs; to apply it, we must obtain values of \(\alpha \) for which these graphs are greedy orientable.

Proposition 3.1

The following statements hold.

  1. (i)

    Trees are the unique bipartite graphs that are 0-greedy orientable.

  2. (ii)

    Simple series–parallel graphs with chromatic number 3 are 0-greedy orientable.

  3. (iii)

    Simple bipartite outerplanar graphs are 1-greedy orientable.

  4. (iv)

    Every \(\ell \)-treeFootnote 4 with chromatic number \(\ell +1\) is 0-greedy orientable.

Proof

  1. (i)

    Let T be a tree, viewed as a rooted tree, and consider all edges oriented away from the root. This gives a vertex ordering satisfying that \(\Delta ^{-}(\overrightarrow{T})=1\) and so T is 0-greedy orientable. Now, if a bipartite graph G is 0-greedy orientable then \(\Delta ^{-}(\overrightarrow{G})=1\), which implies that G cannot contain a cycle as any vertex ordering in the cycle would force at least one vertex to have in-degree bigger than 1. Thus, G is a tree.

  2. (ii)

    By definition, any simple series–parallel graph G can be turned into \(K_2\) by a sequence of two operations: identifying any vertex v of degree two with one of its adjacent vertices (so the two incident edges with v are replaced by one), and deleting parallel edges (leaving just one copy). This series–parallel reduction produces a vertex ordering in G such that \(\Delta ^{-}(\overrightarrow{G})=2\). Indeed, it suffices to label the vertices of G following the sequence in the reverse order: the vertices of \(K_2\) are assigned 1 and 2, and every time a new vertex appears in the sequence is given the following number; see Fig. 5. Since \(\chi (G)=3\), then \(\alpha =\Delta ^{-}(\overrightarrow{G})-\chi (G)+1=0\).

  3. (iii)

    The result follows from the fact that any outerplanar graph G is series–parallel. Thus, we can take the same vertex ordering as above, which gives \(\Delta ^{-}(\overrightarrow{G})=2\). Since G is also bipartite, we have \(\chi (G)=2\) and \(\alpha =\Delta ^{-}(\overrightarrow{G})-\chi (G)+1=1\).

  4. (iv)

    The inductive construction of an \(\ell \)-tree G when \(\ell =\chi (G)-1\) provides a vertex ordering in G satisfying that \(\Delta ^{-}(G)=\chi (G)-1\) (the vertices of the original complete graph are labelled and every vertex that is added has in-degree \(\ell \), equal to the number of neighbors at that stage of the construction). Thus, \(\alpha =\Delta ^{-}(\overrightarrow{G})-\chi (G)+1=0\). \(\square \)

Theorem 3.2 and Proposition 3.1 yield the following upper bounds.

Corollary 3.1

Let H be any subgraph of the complement of a graph G.

  1. (i)

    If G is a tree then \( m(G,H,k) \le \frac{|E(H)|}{k-1}\).

  2. (ii)

    If G is a simple series–parallel graph with \(\chi (G)=3\) then \( m(G,H,k) \le \frac{|E(H)|}{k-2}\).

  3. (iii)

    If G is a simple bipartite outerplanar graph, then \( m(G,H,k) \le \frac{|E(H)|}{k-2}\) for \(k>2\).

  4. (iv)

    If G is an \(\ell \)-tree with chromatic number \(\ell +1\) then \( m(G,H,k)\le \frac{|E(H)|}{k-\ell }\).

4 Robust Coloring on Paths

The seemingly simple setting of paths reflects the complexity of dealing with robust colorings. López-Bracho et al. [13] posed the following conjecture.

Conjecture 4.1

 [13] Let G and H be two paths with n edges on the same vertex set. There exists a 3-coloring of G such that the number of monochromatic edges of H is at most \(\left\lfloor \frac{n+1}{4}\right\rfloor \).

The authors pointed out that their upper bound would be tight by the construction in Fig. 6a. Theorem 4.1 below proves in the affirmative Conjecture 4.1. We use the number of edges in G that are bridgesFootnote 5 of \(G\cup H\), denoted by s, to extend the result from H being a path (\(s=0\)) to H being a vertex-disjoint union of paths (\(s>0\)); see Fig. 6. Our proof illustrates how having the control on the number of monochromatic edges induced in H by a coloring of G is a difficult problem even for paths.

Fig. 6
figure 6

a The construction given in [13]: G is the horizontal path, and H is a path on the same vertex set (monochromatic edges in red and bichromatic ones in blue), b G is the same horizontal path but now H is a vertex-disjoint union of paths (Color figure online)

Theorem 4.1

Let G be a path on \(n\ge 3\) vertices, and let \(H\subseteq {\overline{G}}\) be a vertex-disjoint union of paths. Then,

$$\begin{aligned} m(G,H,3)\le \left\lfloor \frac{|E(H)|+1+s}{4}\right\rfloor \end{aligned}$$

where \(s\ge 0\) is the number of edges in G that are bridges of \(G\cup H\). Moreover, the bound is tight.

Proof

The case \(n=3\) is trivial as \(m(G,H,3)=0\). It is also easy to check the bound for \(n=4\) since \(m(G,H,3)=0\) if \(G\cup H \subset K_4\), and \(m(G,H,3)=1\) if \(G\cup H \simeq K_4\). (Note that we could have set \(n\ge 2\) but, for \(n=2\), the graph H would be empty.) We may assume then that \(n>4\) and also \(|E(H)|\ge 4\) (otherwise the result is straightforward).

We first prove by induction on n that the result holds for \(s>0\). Let \(e\in E(G)\) be a bridge of \(G\cup H\). The graph \((G\cup H) {\setminus } e\)Footnote 6 has two connected components, say \(G_1\cup H_1\) and \(G_2\cup H_2\), such that \(|E(H)|=|E(H_1)|+|E(H_2)|\) and \(s=s_1+s_2+1\), where \(s_i\) denotes the number of edges in \(G_i\) that are bridges of \(G_i\cup H_i\). Hence, \(m(G,H,3)=m(G_1,H_1,3)+m(G_2,H_2,3)\), and by induction we have

$$\begin{aligned} m(G,H,3)\le & {} \left\lfloor \frac{|E(H_1)|+1+s_1}{4}\right\rfloor +\left\lfloor \frac{|E(H_2)|+1+s_2}{4}\right\rfloor \\\le & {} \left\lfloor \frac{|E(H_1)|+|E(H_2)|+2+s_1+s_2}{4}\right\rfloor \end{aligned}$$

which equals the desired upper bound. It may happen that \(H_1\) (or \(H_2\)) is an empty graph in which case \(m(G,H,3)=m(G_2,H_2,3)\) (analogous for \(H_2\)).

Suppose now that \(s=0\). Let \(\{u_1, \ldots , u_n\}\) be the set of vertices of the path G (viewed as an horizontal path) ordered from left to right. We distinguish three cases.

Case 1: There is a vertex \(u_i\), \(i\ne n\), satisfying that there exists a unique edge \(u_ju_k\) in H such that \(j<i\) and \(k>i\) (one endpoint of the edge is to the left and the other to the right of \(u_i\)). We proceed by induction on n. Let \(G_1\) and \(G_2\) be, respectively, the sub-paths of G on vertices \(\{u_1, \ldots , u_i\}\) and \(\{u_{i+1}, \ldots , u_n\}\), that is, \(G=G_1\cup G_2 \cup \{u_iu_{i+1}\}\). Similarly, we consider the graph \(H=H_1\cup H_2 \cup \{u_ju_k\}\), where \(H_i\) is the subgraph of H contained in \(\overline{G_i}\). Every 3-robust coloring of (GH) can be modified to make the edge \(u_ju_k\) bichromatic: it suffices to maintain the coloring of \(G_1\) and change the color of \(u_k\) with other color in \(G_2\), if needed. Thus, \(m(G,H,3)=m(G_1,H_1,3)+m(G_2,H_2,3)\), and by induction the result follows.

Case 2: Vertex \(u_n\) has degree three in \(G\cup H\). Again, we use induction on n. Let \(e_1,e_2\) be the two edges of H incident with \(u_n\). Starting from \(u_{n-1}\), from right to left, consider the two first right endpoints \(u_k, u_j\), \(j\le k\), of edges in H; the corresponding edges are denoted, respectively, by \(e_3\) and \(e_4\). Let \(G_1\) be the sub-path of G on vertices \(\{u_1, \ldots , u_j\}\), and let \(H_1\subset \overline{G_1}\) be either \(H\setminus \{e_i \, | \, 1\le i\le 3\}\) (if \(u_k\ne u_j\)) or \(H\setminus \{e_i \, | \, 1\le i\le 2\}\) (if \(u_k = u_j\)). The difference between a 3-robust coloring of (GH) and one of \((G_1,H_1)\) relies on at most one edge more that can be monochromatic. Indeed, once the vertices of \(G_1\) have been colored, we color the vertices from \(u_n\) to \(u_{j+1}\): there is one available color for \(u_n\) to make \(e_1\) and \(e_2\) bichromatic, and the induced coloring on \(e_4\) always comes from the coloring in \(G_1\). Thus, \(e_3\) would be the unique edge that could increase the number of monochromatic edges when \(u_k\ne u_j\). Hence, \(m(G,H,3)\le m(G_1,H_1,3)+1\), and the desired bound is obtained by induction.

Case 3: The pair (G, H) satisfies neither case 1 nor case 2. We present a vertex coloring procedure in which we first go from left to right assigning colors to the vertices so that as long as possible no monochromatic edge is generated in \(G\cup H\). If we can color all the vertices, then \(m(G,H,3)=0\); otherwise a saturated vertex \(u_i\), \(3<i<n\), is found: a vertex is saturated if its degree in \(G\cup H\) is four and, when it is first visited, three of its neighbours have already been colored with the three available colors. In this case, vertex \(u_i\) is not assigned a color, and we continue visiting vertices without coloring until the first conditioned vertex \(u_j\) is found: a non-colored vertex (at some stage) \(u_j\) is conditioned if it is an endpoint of an edge of H whose other endpoint \(u_t\) has already been colored (\(t<i\)); the edge \(u_tu_j\) is said to be semi-colored. Observe that at this stage vertices from \(u_1\) to \(u_{i-1}\) are colored, and those from \(u_i\) to \(u_n\) are not (including \(u_j\)). Note also that vertex \(u_j\) must exist as \(s=0\) and \(u_i\ne u_n\). As an example, in Fig. 7, vertex \(u_i\) is saturated and vertices \(u_j\) and \(u_k\) are conditioned.

We next describe how our procedure obtains a proper coloring of G with the property that the total number of monochromatic edges in H equals the number of saturated vertices found during the process. More concretely, when a saturated vertex is visited, there are four or five edges of H involved of which only one has to be monochromatic.

If vertex \(u_j\) has two semi-colored edges \(e_1\) and \(e_2\), we first assign a color to \(u_j\) to make both edges bichromatic. Then, vertices from \(u_{j-1}\) to \(u_i\) are colored (from right to left) to maintain the proper coloring in G; this gives one monochromatic edge among the two edges of H incident with \(u_i\). Assume now that \(u_j\) has a unique semi-colored edge \(e_1\), and let \(u_k\) be the first (from left to right) conditioned vertex in \(\{u_{j+1}, \ldots ,u_n\}\); this vertex must exist since otherwise \(e_1\) would be the unique edge with one endpoint to the left and the other to the right of \(u_i\) (case 1). If \(u_k\) has two semi-colored edges \(e_2\) and \(e_3\) (see Fig. 7a), we first color \(u_k\) and \(u_j\) so that edges \(e_i\), \(1\le i\le 3\) are bichromatic. Then, from right to left, vertices \(\{u_{k-1}, \ldots u_{j+1}\}\) and \(\{u_{j-1}, \ldots u_{i}\}\) can be properly colored. Finally, suppose that vertex \(u_k\) has a unique semi-colored edge \(e_2\).

(i) If \(u_j\) has either degree 3 in \(G\cup H\) or an incident edge \(e_3\) with the other endpoint \(u_{\ell }\) between \(u_i\) and \(u_j\) (\(i<\ell <j\)), we first visit, from right to left, vertices \(\{u_k, \ldots , u_j\}\) assigning colors to make \(e_1\) and \(e_2\) bichromatic. Then we color, again from right to left, \(\{u_{j-1}, \ldots , u_i\}\) so that \(e_3\) (if it exists) is bichromatic; this is possible since we are coloring from right to left so, when \(u_{\ell }\) is visited, there are two available colors. Refer to Fig. 7b.

Fig. 7
figure 7

Edges of G in black, and edges of H in red; vertices \(\{u_1,\ldots , u_{i-1}\}\) have already been colored (colors 1–3). Vertex \(u_k\) has two semi-colored edges in (a) and one in (b) and (c); the difference between these two cases is the position of the endpoint \(u_{\ell }\) of \(e_3\)

(ii) If \(u_j\) has an incident edge \(e_3\) with the other endpoint \(u_{\ell }\) between \(u_j\) and \(u_k\) (\(j<\ell <k\)), we randomly assign to \(u_k\) one of the two colors that make \(e_2\) bichromatic, and proceed to color from right to left vertices \(\{u_{k-1}, \ldots ,u_j\}\) using only the color of \(u_k\) and that of the other endpoint of \(e_2\). Our aim is that \(e_1\) and \(e_3\) are bichromatic, but it may happen that, with our assignment, they can not be both bichromatic while maintaining the proper coloring in G; this happens for example giving color 1 to \(u_k\) in Fig. 7c. In this case, we change the color of all vertices in \(\{u_{k}, \ldots ,u_{j+1}\}\) that have the same color as \(u_k\) by the other color that preserves \(e_2\) as bichromatic (in our example, we would change color 1 by color 3). Then, we color vertices from \(u_{j-1}\) to \(u_i\).

We thus conclude that, when a saturated vertex is visited, our procedure generates one monochromatic edge in H, and at least three bichromatic ones. Hence, \(m(G,H,3)\le \left\lfloor \frac{|E(H)|}{4}\right\rfloor \). Figure 6 illustrates examples for \(s=0\) and \(s>0\) where the bound is tight. \(\square \)

5 Concluding Remarks

In this work we have presented the first non-heuristic study for general graphs on the robust coloring model. We delved into the connection beetween robust colorings and equitable colorings, encompassing a complexity study. We also obtained the first general bounds on the parameter m(GHk), and solved an intriguing conjecture on paths. These are important steps on this difficult and challenging problem that leave different types of open questions for future research:

  • The problem of deciding whether a general graph has an equitable k-coloring with a given number of colors \(k\ge 3\) is NP-complete [8]. However, it would be interesting to find a broad class of graphs for which a polynomial time algorithm could be designed. The algorithm could also be applied to robust coloring by means of Theorem 2.2.

  • In order to improve the upper bounds of Sect. 3, we think that new techniques must be developed, rather than trying to enhance them by using a similar approach to the one presented in this paper.

  • The proof of Theorem 4.1 shows the complexity of studying the RCP even for paths. Thus, for a better understanding of this coloring model, it would be worth studying if the ideas of that proof could be extended to other families of graphs.