Discrete Applied Mathematics 160 (2012) 810–833
Contents lists available at SciVerse ScienceDirect
Discrete Applied Mathematics journal homepage: www.elsevier.com/locate/dam
The complexity of minimum convex coloring✩ Frank Kammer, Torsten Tholey ∗ Institut für Informatik, Universität Augsburg, 86135 Augsburg, Germany
article
info
Article history: Received 28 February 2010 Received in revised form 9 September 2011 Accepted 24 September 2011 Available online 27 October 2011 Keywords: Convex coloring Approximation algorithm Treewidth Maximum disjoint paths problem Set cover
abstract A coloring of the vertices of a graph is called convex if each subgraph induced by all vertices of the same color is connected. We consider three variants of recoloring a colored graph with minimal cost such that the resulting coloring is convex. Two variants of the problem are shown to be N P -hard on trees even if in the initial coloring each color is used to color only a bounded number of vertices. For graphs of bounded treewidth, we present a polynomial-time (2 + ϵ)-approximation algorithm for these two variants and a polynomial-time algorithm for the third variant. Our results also show that, unless N P ⊆ DTIME (nO(log log n) ), there is no polynomial-time approximation algorithm with a ratio of size (1 − o(1)) ln ln N for the following problem: given pairs of vertices in an undirected N-vertex graph of bounded treewidth, determine the minimal possible number l for which all except l pairs can be connected by disjoint paths. © 2011 Elsevier B.V. All rights reserved.
1. Introduction A partially colored graph (G, C ) is a tuple consisting of a graph G and a partial coloring C of G, i.e., a function assigning each vertex v to a color that is either 0 or a so-called real color. A vertex colored with 0 is also called uncolored. A partially colored graph (G, C ) is called totally colored if it has no uncolored vertices, and in this case C is also called a total coloring. A partial coloring is an (a, b)-coloring if the color set used for coloring the vertices contains at most a real colors and if each real color is used to color at most b vertices. Two equal-colored vertices u and v in a colored graph (G, C ) are C -connected if there is a path from u to v whose vertices are all colored by C with the color of u and v . A subgraph H of a graph G with a coloring C is called C -connected if every pair u, v of vertices of H is C -connected, i.e., if all its vertices have the same color. H is also called a C -connected component if additionally there is no other c-connected subgraph H ′ ̸= H of G with H being a subgraph of H ′ . For a partially colored graph (G, C1 ), another arbitrary partial coloring C2 of G is also called a recoloring of (G, C1 ). We then say that C1 is the initial coloring of G and that C2 recolors or uncolors a vertex v of G if C2 (v) ̸= C1 (v) and C2 (v) = 0, respectively. The cost of a recoloring C2 of a partially colored graph (G, C1 ) with G = (V , E ) is v∈V :0̸=C1 (v)̸=C2 (v) w(v), where w(v) denotes the weight of v with w(v) = 1 in the case of an unweighted graph. This means that we have to pay for recoloring or uncoloring a real colored vertex, but not for recoloring an uncolored vertex. Clearly, for each recoloring C2 of a partially colored graph, we can color each maximal connected set S of uncolored vertices with a new color to obtain another recoloring C2′ that is a total coloring and has the same costs as C2 . This is the reason why, instead of problems in which a total coloring is replaced by a new total coloring with minimum costs, we want to consider the more complicated versions of replacing a partial coloring by a new partial coloring of minimum costs. Therefore, in the following opposite to the standard definition of Moran and Snir [15] we use coloring and colored graph as an abbreviation for a partial coloring and a partially colored graph. We call a partial coloring C to be convex if all pairs of vertices colored with the same real color are
✩ A preliminary version of this paper appeared in Kammer and Tholey (2008) [10].
∗
Corresponding author. Fax: +49 821 598 2385. E-mail addresses:
[email protected] (F. Kammer),
[email protected] (T. Tholey).
0166-218X/$ – see front matter © 2011 Elsevier B.V. All rights reserved. doi:10.1016/j.dam.2011.09.022
F. Kammer, T. Tholey / Discrete Applied Mathematics 160 (2012) 810–833
811
Fig. 1. An instance of a colored graph, where each vertex is a router. The white computers are considered as uncolored vertices.
Fig. 2. An optimal convex recoloring for the instance in Fig. 1.
Fig. 3. The colored graph of Fig. 1 with routers and laptops (clients). The white computers are considered as uncolored vertices.
C -connected. For a non-total coloring, this is again different from the standard definition in [15], where a non-total coloring is called convex if its uncolored vertices can be colored in such a way that the resulting total coloring is convex. In the minimum convex recoloring problem (MCRP) we are given a colored graph possibly with a positive weight-function w, and we search for a convex recoloring with minimal cost. The MCRP describes a basic problem in graph theory with different applications in practice: a first systematic study of the MCRP on trees is from Moran and Snir [15] and was motivated by applications in biology. Further applications are so-called multicast communications in optical wavelength division multiplexing networks; see, e.g., [7] for a short discussion of these applications. Here we focus on the MCRP as a special kind of routing problem. Suppose we are given a telecommunication or transportation network modeled by a graph whose vertices represent routers. Moreover, assume that each router can establish a connection between itself and an arbitrary set of adjacent routers. Then routers of the same initial color could represent clients that want to be connected by the other routers to communicate with each other or to exchange data or commodities. More precisely, connecting clients of the same color means finding a connected subgraph of the network containing all the clients, where the subgraphs for clients of different colors should be disjoint. If we cannot establish a connection between all the clients, we want to give up connecting as few clients to the other clients of the same color as possible in the unweighted case (w(v) = 1 for all vertices v ) or to give up a set of clients with minimal total weight in the weighted case. Hence, our problem reduces to the MCRP, where the initially uncolored vertices that are recolored by a color c represent exactly the routers used to connect clients of color c. Fig. 1 shows an example instance and Fig. 2 an optimal solution for it. The case in which routers can connect a constant number of disjoint sets of adjacent routers can be handled by duplicating vertices representing a router. We also introduce a new restricted version of the problem above that we call the minimum restricted convex recoloring problem (MRRP). In this problem we ask for a restricted convex recoloring C ′ , i.e., a convex recoloring that does not recolor any real colored vertex with a different real color. In practice clients often cannot be used for routing connections for other clients so that a clear distinction between clients and routers should be made. This can be modeled by the MRRP, where a client that cannot be connected to the other clients of the same color may only be uncolored. See Fig. 3 for an example instance and Fig. 4 for an optimal solution. One could also think of a variant of the MRRP that should construct a total instead of a partial coloring. However, then the MRRP reduces to the problem, given disjoint vertex sets V1 , . . . , Vk of a graph G, find
812
F. Kammer, T. Tholey / Discrete Applied Mathematics 160 (2012) 810–833
Fig. 4. An optimal restricted convex recoloring for the instance in Fig. 3.
Fig. 5. An optimal block recoloring for the instance in Fig. 1.
vertex-disjoint connected subgraphs G1 , . . . , Gk with Gi containing all vertices in Vi for all i ∈ {1, . . . , k}. This problem is well studied and is shown to be solvable in polynomial time by Robertson and Seymour [19] if k is fixed, and to be NP-hard if k is not fixed [12,13]. Moreover, it is easy to see that this problem is solvable in linear time on trees even if k is not fixed as already observed in [15]. One just has to test whether, for each vertex initially colored with a color c, it is possible to color its ancestors with c until reaching the lowest common ancestor of all vertices initially colored with c, without coloring any vertex with more than one color. This is the reason why we define the MRRP as the more complicated problem to output partial instead of total colorings. By allowing the initial colorings to be partial colorings we only increase the number of possible instances. Finally, we consider a variant of the MCRP, where we search for a convex recoloring, but assign a cost to each real color c. We have to pay the cost for color c if at least one vertex of color c is recolored. We call this recoloring problem the minimum block recoloring problem (MBRP). In an unweighted version we assign cost 1 to each color. The MBRP is useful if it is not enough in an application to connect only a proper subset of clients (of the same color) that want to be connected. See also Fig. 5. The MCRP, the MRRP, and the MBRP can also be considered as generalizations of the maximum disjoint paths problem (MDPP) and the disjoint paths problem (DPP), where in the first case a maximum number and in the second case all pairs of given pairs of vertices of a graph are to be connected by vertex-disjoint paths, if possible. Indeed any algorithm solving one of our recoloring problems on (∞, 2)-colorings to optimality can solve the DPP, too. Given an algorithm for the MBRP one can also solve the problem of connecting a subset of a given set of weighted vertex pairs (s1 , t1 ), . . . , (sl , tl ) by disjoint paths such that the sum of the weights of the connected pairs is maximized. Previous results. The MDPP is NP-hard (see the paper of Karp [12], where the NP-hardness proof is referred to Knuth, and Lynch [13]). Moreover, this problem cannot be approximated on N-vertex graphs in polynomial time within a ratio of size ≤ log1/3−ϵ N unless NP ⊆ ZPTIME (npoly log(n) ) as shown by Andrews and Zhang [2]. The NP-hardness of the unweighted MCRP, MRRP, and MBRP—even when restricted to initial (∞, 2) colorings—follows directly from the NP-hardness of the MDPP. The unweighted versions of the MCRP and the MRRP are still NP-hard on (2, ∞)-colorings as shown by Moran et al. [16] for the MCRP and by Chor et al. [8] for the MRRP. Non-approximability results for our recoloring problems do not follow from corresponding results for the MDPP since the latter problem is a maximization and not a minimization problem. Moran and Snir [15] showed that the unweighted MCRP on (∞, ∞)-colorings remains NP-hard on strings—i.e. trees with two leaves—even if it is required that the initial coloring is a total coloring. The NP-hardness of the unweighted MRRP on trees follows implicitly from the results in [15] concerning leaf-colored trees. Moran and Snir showed implicitly in [15] that the weighted MCRP on trees is solvable in polynomial time if the initial colorings on n-vertex trees are restricted to O(f (n), ∞)-colorings for a function f ∈ O(log n). In [14] they presented a polynomial-time 2-approximation algorithm for the weighted MCRP on strings and a polynomial-time 3-approximation algorithm for the weighted MCRP on trees. Bar-Yehuda et al. [3] could improve the approximation ratio on trees to 2 + ϵ . New results. In contrast to the work of Moran, Snir [14,15] as well as of Bar-Yehuda et al. [3], here we consider usually initial (a, b)-colorings with a or b being different from ∞. In addition, we also consider graphs of bounded treewidth instead of only trees.
F. Kammer, T. Tholey / Discrete Applied Mathematics 160 (2012) 810–833
813
Table 1 Complexity results for graphs with bounded treewidth on (a, b)-colorings. a ∈ O(log n)
MCRP MRRP MBRP
∈P ∈P ∈P
a=∞ b = 2, 3
b≥4
NP-hard ∈P ∈P
NP-hard NP-hard ∈P
Surprisingly, the three variants of our recoloring problem all have different complexities on graphs of bounded treewidth, as we prove in Sections 2 and 3. Table 1 summarizes our results on graphs of bounded treewidth. We will see that the MCRP is NP-hard even on unweighted trees initially colored with (∞, 2)-colorings, whereas the MRRP can be solved in polynomial time for the more general (∞, 3)-colorings as input colorings even on weighted graphs of bounded treewidth. In this paper by a slight modification compared to the preliminary version of the paper we show that our NP-hardness result for (∞, 2)colorings still holds if we additionally require that the initial coloring is total. Moreover, recently Kanj and Kratsch [11] have shown that one can additionally restrict the trees to be strings. We also observe the NP-hardness of the unweighted MRRP on trees colored with (∞, 4)-colorings. Even though it is not mentioned explicitly in the preliminary version [10] of this paper, our reduction directly shows that this also holds if we restrict the instances to trees with only their leaves being colored. Another proof for the same fact was recently given by Kanj and Kratsch [11] who also studied the connection between the 2-coloring problems MCRP and MRRP and the maximum independent set problem. Thereby they provide alternative proofs for the NP-hardness results given in Table 1 and present a polynomial time algorithm for the MRRP on trees with an (2, ∞)and (3, ∞)-coloring. Beside the results in the table we also present a polynomial-time algorithm for the MBRP on weighted graphs of bounded treewidth for general colorings, i.e., (∞, ∞)-colorings. Extending the result of Bar-Yehuda et al. we present a polynomial-time (2 + ϵ)-approximation algorithm for the MCRP and the MRRP on weighted colored graphs of bounded treewidth. However, if we follow their approach in a straightforward way, we would have to store too much information at each node of a so-called tree decomposition. Therefore, we would obtain a running time Ω (nk+1 ) with k being the treewidth of the graph considered. Additional ideas allows us to guarantee a running time quadratic in n. Besides our results on graphs of bounded treewidth we show that the unweighted versions of our recoloring problems on an N-vertex graph cannot be approximated in polynomial time within an approximation ratio of (1 − o(1)) ln ln N unless NP ⊆ DTIME(nO(log log n) ) even if the initial colorings are (∞, 2)-colorings. As a consequence of this result, NP ̸⊆ DTIME(nO(log log n) ) implies that there is no polynomial-time approximation algorithm with constant approximation ratio for the following problem: given pairs of vertices, find the minimal l such that all except l pairs can be connected by disjoint paths. Determining l can be considered as some kind of inverse of the MDPP problem. 2. Hardness results 2.1. Hardness for general graphs In this subsection we show a hardness result concerning the minimum convex recoloring problem on general graphs. Theorem 2.1. Given an unweighted N-vertex graph with an (∞, 2)-coloring, no polynomial-time algorithm for the MCRP, the MRRP or the MBRP has an approximation ratio (1 − o(1)) ln ln N unless NP ⊆ DTIME(nO(log log n) ). Proof. Given a tuple (U , F ), where U is a finite set and F is a collection of different subsets of U such that F ∈F F = U, the minimum set-cover problem asks for a collection of a minimal number of sets in F whose union covers U. Such a collection F ∗ is called a set cover for (U , F ) and the number of sets in F ∗ is called the size of the set cover. Feige [9] has shown that there is no polynomial-time approximation algorithm of ratio (1 − o(1)) ln |U | for the minimum set-cover problem of (U , F ) unless NP ⊆ DTIME(nO(log log n) ). In the following we prove Theorem 2.1 by a reduction from the minimum set-cover problem. Given a set-cover instance (U , F ), we create a colored graph (G, C ). W.l.o.g. we assume that |U | > 5 and that F contains only sets with cardinality ≤ (|U | − 2), i.e., in particular |F | ≤ 2|U | − |U |. For each set Z in F , we define an ordering σ1 , σ2 , . . . , σr of the elements of Z and introduce in G a path consisting of new vertices Z′ , Zσ1 , Zσ2 , . . . , Zσr , Z′′ in this order. For each u ∈ U, we add vertices u′ and u′′ to G. Moreover, for each Z ∈ F and each u ∈ Z, we add edges {Zu , u′ } and {Zu , u′′ } (see Fig. 6). For each set Z ∈ F and each u ∈ U, we define new colors cZ and cu , respectively, different from the other colors and color the vertices Z′ and Z′′ with cZ and the vertices u′ and u′′ with color cu . All other vertices remain uncolored. We next show that each set cover for (U , F ) of size k can be used to construct a convex recoloring of (G, C ) with cost k for each of the three coloring problems in polynomial time and vice versa. Since the constructed graph G has N ≤ 2|F | + (|U | − 2)|F | + 2|U | = |U | · (|F | + 2) ≤ |U |2|U | ≤ e|U | vertices and because of the non-approximability result for the set-cover problem, no polynomial-time algorithm can solve our three recoloring problems with an approximation ratio (1 − o(1)) ln |U | ≥ (1 − o(1)) ln ln N unless NP ⊆ DTIME(nO(log log n) ).
814
F. Kammer, T. Tholey / Discrete Applied Mathematics 160 (2012) 810–833
Fig. 6. Reduction from minimum set cover to a recoloring problem.
Given a set cover F ∗ ⊆ F of size k, we can find a recoloring C ′ of G with cost k as follows: for each set Z ∈ F \ F ∗ , we recolor the inner vertices of the paths from Z′ to Z′′ with color cZ . For each set Z = {σ1 , σ2 , . . . , σr } ∈ F ∗ , we uncolor Z′′ and color Zσi with cσi for all 1 ≤ i ≤ r. Since F ∗ is a set cover, for each u ∈ U, there exists a set Z ∈ F ∗ with u ∈ Z. Therefore, our recoloring guarantees that, for each u ∈ U, the vertices u′ and u′′ are C ′ -connected because of the recoloring of Zu with color cu for some Z ∈ F ∗ . For each set Z ∈ F \ F ∗ , the vertices Z′ and Z′′ are also C ′ -connected. Since each remaining color cZ with Z ∈ F ∗ is used by C ′ to color only one vertex, C ′ is a convex recoloring. The cost for the recoloring C ′ with respect to the MCRP, MRRP, or MBRP is |F ∗ | = k since the only real-colored vertices with respect to C that are recolored by C ′ are the vertices in {Z′′ | Z ∈ F ∗ }. Let us now assume that there is a convex recoloring C ′ for the MCRP, MRRP, or MBRP with cost k in G. We now prove that we can find a set cover of size at most k. For each set Z = {σ1 , . . . , σr } in F , let us define the desired vertices for color cZ as the set {Z′ , Zσ1 , Zσ2 , . . . , Zσr , Z′′ }. We start to show that we can assume without loss of generality that the following properties hold for the recoloring C ′ . (1) For each Z ∈ F , the graph induced by the vertices v with C ′ (v) = cZ either consists only of one vertex of {Z′ , Z′′ } or is a simple path from Z′ to Z′′ . (2) For each u ∈ U, at most one vertex v ̸∈ {u′ , u′′ } is colored with cu by C ′ and, if such a vertex exists, it is equal to Zu for some Z ∈ F with u ∈ Z. (3) For each Z ∈ F , C ′ colors only desired vertices for cZ with color cZ . Property (1) follows from the fact that each vertex v ̸∈ {Z′ , Z′′ } with C ′ (v) = cZ can be uncolored without increasing the cost of the recoloring—note explicitly that this is true for all three recoloring variants. Therefore, if neither Z′ or Z′′ are recolored, it suffices to color a simple path from Z′ to Z′′ with color cZ . If exactly one of {Z′ , Z′′ } is colored with cZ by C ′ , no vertex v ̸∈ {Z′ , Z′′ } must be colored with cZ . Note also that uncoloring both vertices of {z ′ , z ′′ } cannot help to decrease the costs. For property (2) it is again easy to see that w.l.o.g. the vertices of color cu consist either of a single vertex in {u′ , u′′ } or of the vertices of a simple path from u′ to u′′ . But each simple path from u′ and u′′ must use a node Zu for some Z ∈ F with u ∈ Z. Then we can uncolor all vertices v ̸∈ {u′ , u′′ , Zu } with C ′ (v) = cu without increasing the costs and still have a convex recoloring. To guarantee the property (3), let us consider a coloring C ′ for which the properties (1)–(2) hold. Let Z be the set of all Z ∈ F for which C ′ colors at least one non-desired vertex for cZ with the color cZ . Moreover, let C ′′ be the coloring obtained from C ′ by first uncoloring all vertices v ̸= Z′ with C ′ (v) = cZ for each set Z ∈ Z , and second by choosing, for each u ∈ U for which this is possible, a set Z ∈ Z with cZ ∈ {C ′ (u′ ), C ′ (u′′ )} and coloring u′ , u′′ , and Zu with cu . Let U ′ ⊆ U be the subset of elements of U for which there is a Z ∈ Z with cZ ∈ {C ′ (u′ ), C ′ (u′′ )}. It is easy to see that, for an element u ∈ U with u′ and u′′ being C ′ -connected, the vertices u′ and u′′ are also C ′′ -connected, where we implicitly use property (2). Therefore, replacing the coloring C ′ by C ′′ can increase the costs by at most |Z | − |U ′ | (note that the increase of the costs is only caused by the uncoloring of Z′′ for all Z ∈ Z ). Since by property (1), for each Z ∈ Z , the vertices colored by C ′ must induce a path, there are at least two vertices in {u′ , u′′ | u ∈ U } being colored with cZ . We can conclude that
|Z | ≤
1 2
|{u′ , u′′ | u ∈ U ′ }| ≤ |U ′ |.
This shows that the cost of C ′′ are at most that of C ′ . Moreover, C ′′ is a convex recoloring for which the properties (1)–(3) hold. Hence in the following w.l.o.g. we assume that all three properties hold for C ′ . Let F1∗ be the collection of all sets Z ∈ F for which at least one of Z′ or Z′′ is recolored by C ′ . The recoloring cost for all vertices in {Z′ , Z′′ | Z ∈ F1∗ } is at least |F1∗ | even in the case of the MBRP. Let us remove from G the desired vertices for cZ for all Z ∈ F1∗ , all vertices u′ and u′′ with u ∈ U being covered by F1∗ , and all edges being incident to at least one removed vertex. Let U ∗ ⊆ U be the set of elements u for which u′ and u′′ remain in G. Note that, for each u ∈ U ∗ , no common neighbor of u′ and u′′ was removed. For each set Z ∈ F \ F1∗ , we know by combining property (1) and (3) that the path from Z′ to Z′′ is colored with cZ . Consequently, for all u ∈ U ∗ , the vertices u′ and u′′ cannot be C ′ -connected—this follows from the fact that all common neighbors of u′ and u′′ are already colored with cZ for some Z ∈ F \ F1∗ . Therefore and since C ′ is a convex recoloring, for each u ∈ U ∗ , one of the vertices u′ and u′′ must be uncolored. This means that we have an additional recoloring cost of size |U ∗ |. Since our recoloring has cost of at most k, |U ∗ | ≤ k − |F1∗ |. We can easily find a collection F2∗ ⊆ F consisting of at most |U ∗ | sets that covers all elements of U ∗ . Hence F1∗ ∪ F2∗ is a set cover of (F , U ) of size at most k.
F. Kammer, T. Tholey / Discrete Applied Mathematics 160 (2012) 810–833
815
Fig. 7. The figure shows parts of the graph obtained by the reduction from a formula in 3-CNF with a clause x ∨ y ∨ z to MCRP.
By the same reduction and a result from Alon et al. [1] one can also show that under the weaker assumption P ̸= NP none of our recoloring problems on general graphs has an approximation algorithm of ratio c log log N for an appropriate chosen constant c > 0. 2.2. Hardness in unweighted trees We now show hardness results for two of our three recoloring problems on trees even for the case that each color is used to color only a bounded number of vertices. This of course implies also the hardness on graphs of bounded treewidth. Alternative proofs based on a reduction from maximum independent set can also be found in the paper of Kanj and Kratsch [11]. Theorem 2.2. The MCRP on initial total (∞, 2)-colorings and the MRRP on initial partial (∞, 4)-colorings are NP-hard on unweighted trees. Proof. For both problems, we use a reduction from 3-SAT. Let F be an instance of 3-SAT, i.e., F is a Boolean formula in 3-CNF. W.l.o.g. we assume that each clause in F has exactly three literals. Let n and m be the number of variables in F and the number of clauses of F , respectively. In addition, let r be the minimal number such that each literal in F appears at most r times in F . The following construction of an instance IMCRP for the MCRP is illustrated by Fig. 7. We construct G by introducing for each variable x a so-called gadget Gx consisting of
• • • •
a vertex vx , leaves vxL,i , vxR,i colored with a color cxi for each i ∈ {0, 1}, an edge {vxL,i , vx } for each i ∈ {0, 1}, and two internally vertex-disjoint paths of length r + 1, one from vx to vxR,0 , and the other from vx to vxR,1 .
Let us call the internal vertices of the path connecting vx and vxR,1 the positive and those of the path connecting vx and v the negative vertices in the gadget Gx . For each clause K , we introduce a similar gadget GK consisting of R ,0 x
• • • •
a vertex vK , R ,j j L,j leaves vK , vK colored with a color cK for each j ∈ {1, 2, 3}, L,j
an edge {vK , vK } for each j ∈ {1, 2, 3}, and
R ,1
R ,2
R ,3
three internally vertex-disjoint paths that have length 2, start in vK , and end in vK , vK , and vK , respectively.
In addition, we also introduce 2nr extra vertices without any incident edges called the free vertices of G. From this forest we obtain a tree T if we simply connect all gadgets and all free vertices by the following three steps. See also Fig. 8. First, add a path of length five consisting of vertices v 0 , . . . , v 4 to G where we define C (v 0 ) = c ′ , C (v 1 ) = · · · = C (v 3 ) = c ′′ , and C (v 4 ) = c ′′′ for new colors c ′ , c ′′ , and c ′′′ . Second, for each variable x, connect vx to v 1 and color it with c ′′′ . Third, for each clause K and each free vertex v , connect vK and v both to v 3 and set C (vK ) = c ′ . Concerning the coloring C of T , we color further vertices of T . For each literal ℓ = x or ℓ = x in a clause K , color one positive (in the case ℓ = x) or one negative (in the case ℓ = x) vertex of Gx as well as one of the non-leaves adjacent to vK with a new color cK ,ℓ . If after these colorings there is at least one uncolored positive or negative vertex, we take for each such vertex u a new color cu and assign it to u as well as to exactly one uncolored free vertex. If there are uncolored free vertices at the end, remove them. Let us call a pair of equal-colored vertices a literal–clause pair if it contains a positive or negative vertex. The construction of an instance IMRRP for the MRRP can be obtained from above by uncoloring vx and vK for each variable x and clause K and by the following modification for each vertex v being part of a literal–clause pair. Add two new vertices v ∗ and v ∗∗ to T ,
816
F. Kammer, T. Tholey / Discrete Applied Mathematics 160 (2012) 810–833
Fig. 8. Sketch of the construction to connect the gadgets and the free vertices.
connect each of them with an edge to v , and move the color c of v to v ∗ and v ∗∗ , i.e., color both new vertices with c and uncolor v . The vertices v ∗ and v ∗∗ are called an agent pair of v . It remains to show that the following three statements are equivalent. 1. F is satisfiable, i.e., F ∈ 3-SAT. 2. IMCRP has a convex recoloring C ′ with cost at most 2n + 3m + 2nr. 3. IMRRP has a restricted convex recoloring C ′′ with cost at most n + 2m + 4nr. 1 ⇒ 2: Let B be a satisfying assignment of F . We can construct a convex recoloring C ′ as follows. For each variable x, if x is true with respect to B, we recolor all negative vertices of the gadget Gx as well as vx with color cx0 , and otherwise we recolor the positive vertices of the gadget Gx and vx with color cx1 . Moreover, for each clause K , we choose one literal ℓ being true R ,j
with respect to B. We then search for the vertex u with color cK ,ℓ adjacent to a leaf vK for some j ∈ {1, 2, 3} and recolor
vK and u by the color
j cK .
Next, for each literal–clause pair with both vertices still being colored, we uncolor one of the two. L,j
Finally, we uncolor for all i ∈ {0, 1}, j ∈ {1, 2, 3}, for all variables x and all clauses K the leaves vxL,i and vK that do not have the same color as the rules above have assigned to vx and vK , respectively. Note that for each variable x and each clause K , one pair of initially equal-colored leaves in Gx and GK , respectively, are C ′ -connected. The vertices v1 and v3 are also C ′ connected. All other colors not used for these C ′ -connections are only used to color exactly one vertex. Altogether, we can observe that C ′ is a convex recoloring that is obtained by uncoloring 2m leaves of the gadgets for the clauses and n leaves of the gadgets for the variables, by recoloring one vertex for each of the 2nr literal–clause vertex-pairs, and by recoloring vx and vK for each of the n variables x and m clauses K . Therefore, C ′ has cost 2n + 3m + 2nr. 2 ⇒ 3: We modify a solution C ′ for the IMCRP to obtain a solution C ′′ for the IMRRP with cost at most n + 2m + 4nr by setting C ′′ (v ∗ ) = C ′ (v) and C ′′ (v ∗∗ ) = C ′ (v), if C ′ (v) = C (v), and otherwise, C ′′ (v ∗ ) = C ′′ (v ∗∗ ) = 0 for each vertex v of a literal–clause pair. Note that C ′′ is convex since C ′ is convex and since we color a vertex v ∗ and v ∗∗ with a color c only if their neighbor v is colored with c, too. We next show that C ′′ has cost at most n + 2m + 4nr by analyzing the difference between the costs of C ′′ and C ′ . For each vertex v with C ′ (v) ̸= C (v) that is part of a literal–clause pair, C ′′ has to recolor v ∗ and v ∗∗ . This may double the costs for the literal–clause pairs. On the other side, whereas C ′ has to pay for each recoloring of vx and vK for a variable x and a clause K , this is not true for C ′′ since vx and vK are initially uncolored in IMRRP . Hence, our bound for the costs of C ′′ follows if we can show that C ′ recolors at most 2nr vertices part of a literal–clause pair and recolors vx for each variable x and vK for each clause K . This is what we do next. Note that, for each variable x, C ′ has to recolor two of the four leaves of the gadget Gx or one of the four leaves of Gx and additionally vx . Similarly, for each clause K , C ′ has to recolor three of the six leaves of the gadget GK or two of the six leaves of GK and additionally vK . The reason for this is that the vertices vx and vK can have only one color. Thus, apart from these (2n + 3m) recolorings, C ′ can only recolor at most 2nr further vertices. Assume that C ′ uncolors the three vertices v 1 , v 2 , and v 3 (possibly in order to C ′ -connect v 0 or v 4 with another vertex or to C ′ -connect a literal–clause pair). Then, for each of at least 2nr − 1 remaining literal–clause pairs, exactly one of the two vertices must be uncolored, i.e., at least 2nr − 1 vertices are to be uncolored by costs of at most 2nr − 3. Since this is not possible, at least one vertex of {v 1 , v 2 , v 3 } is not uncolored, i.e., v 0 and v 4 are not C ′ -connected to another vertex and, for each literal–clause pair, one of the two vertices is recolored. Since we have 2nr literal–clause pairs, C ′ has to uncolor exactly one vertex of each such literal–clause pair and cannot recolor any further vertices, in particular, none of {v0 , . . . , v4 } can be recolored. Therefore, for each variable x and clause K , C ′ (vx ) ̸= c ′′′ = C (v4 ) and C ′ (vK ) ̸= c ′ = C (v0 ). 3 ⇒ 1: We now show that, if there is a restricted convex recoloring C ′′ for IMRRP with cost at most n + 2m + 4nr, then F has a truth assignment. Let us assign to a variable x the value 1 (true) if and only if C ′′ does not recolor vxL,0 and vxR,0 , i.e., if and only if C ′′ (vxL,0 ) = C (vxL,0 ) = cx0 = C (vxR,0 ) = C ′′ (vxR,0 ). To show that F is a truth assignment, let us first observe that C ′′ has to recolor at least n + 2m leaves of the variable and clause gadgets since the vertices vx and vK can have only one color. Thus, C ′′ can recolor only 4nr further vertices. Similar to the arguments used in last reduction, no vertex of {v 1 , v 2 , v 3 } is recolored and exactly the two vertices of one of the two
F. Kammer, T. Tholey / Discrete Applied Mathematics 160 (2012) 810–833
817
agent pairs for the 2nr literal–clause pairs are recolored by C ′′ . Thus, C ′′ cannot recolor any further vertices, in particular, no further leaves, i.e.,
∀ variables x ∃i ∈ {1, 2} : C ′′ (vxL,i ) = C (vxL,i ) = cxi = C (vxR,i ) = C ′′ (vxR,i ),
(1)
∀ clauses K ∃j ∈ {1, 2, 3} : C ′′ (vKL,j ) = C (vKL,j ) = cKj = C (vKR,j ) = C ′′ (vKR,j ).
(2)
We next show that our assignment makes a literal true in each clause. Let us consider a clause K and a j ∈ {1, 2, 3} such that L,j R ,j Eq. (2) holds. Note that, for the path connecting the leaf vK with the leaf vK , the inner vertex v ̸= vK disconnects an agent pair P. Let cK ,ℓ be the initial color of the vertices of P, where ℓ ∈ {x, x} for some variable x. Thus, at least one vertex of P is recolored. By the observations of the last paragraph this means that both vertices of P are recolored and that the vertices of the other agent pair Q ̸= P that was also initially colored with cK ,ℓ are not recolored. Let us consider the gadget Gx . If ℓ = x, then one of the two leaves vxL,0 and vxR,0 is recolored by C ′′ since the path connecting these leaves has a common vertex with the path connecting the two vertices of Q . Therefore, our assignment sets x = 0 (false), i.e., ℓ = x = 1 makes K true. Otherwise, ℓ = x. Similarly to what was the case above, now one of the two leaves vxL,1 and vxR,1 is recolored by C ′′ . By Eq. (1), the other pair vxL,0 and vxR,0 of leaves in Gx is not recolored and ℓ = x = 1, i.e., our assignment makes K true. To sum up, in each clause K we have a literal that makes K true, i.e., F is satisfied by our assignment. 3. Exact algorithms 3.1. Tree width and tree decomposition In this section, we present exact algorithms for our coloring problems on graphs with bounded treewidth. For defining graphs of bounded treewidth we have to define tree decompositions. Tree decompositions and treewidth were introduced by Robertson and Seymour [18] and a survey for both is given by Bodlaender [5]. Definition 3.1. A tree decomposition of width k for a graph G = (V , E ) is a pair (T , B), where T = (VT , ET ) is a tree and B is a mapping that maps each node w of VT to a subset B(w) of V such that (1) w∈VT B(w) = V , (2) for each edge (u, v) ∈ E, there exists a node w ∈ VT such that {u, v} ⊆ B(w), (3) B(w1 ) ∩ B(w3 ) ⊆ B(w2 ) for all w1 , w2 , w3 ∈ VT with w2 being a node on the path from w1 to w3 in T , (4) |B(w)| ≤ k + 1 for all w ∈ VT .
Moreover, a tree decomposition is called nice if (5) T is a rooted and binary tree, (6) B(w) = B(w1 ) = B(w2 ) holds for each node w of T with two children w1 and w2 , (7) |B(w) ∪ B(w1 )| − |B(w) ∩ B(w1 )| = 1 holds for all nodes w of T with exactly one child w1 (intuitively B(w) and B(w1 ) differ in exactly one vertex). The treewidth of a graph G is the smallest number k for which a tree decomposition of G with width k exists. Bodlaender [4] has shown that one can construct a tree decomposition (T , B) with n nodes and of width k for every n-vertex graph of constant treewidth k in O(n) time. Given such a tree decomposition (T , B) for an n-vertex graph G of treewidth k, one can also determine a nice tree decomposition (T ′ , B′ ) with T ′ consisting of O(n) nodes in O(k2 n) time [6]. In the following subsections we often consider a colored graph (G, C ) and a nice tree decomposition (T , B) for G of width k − 1 (k ∈ N). If so, we refer to nodes instead to vertices if we mean the vertices of T . For clarity, we use the letter w to denote nodes of T . By wl and wr we denote the left and the right child, respectively, of a node w in T . In addition, if w has only one child, we define it to be a left child. For each node w in T , we let
• G(w) be the subgraph of G induced by all vertices contained in at least one set B(w′ ) of a node w′ contained in the subtree of T rooted in w . • G(¬w) be the subgraph of G induced by all vertices contained in at least one set B(w ′ ) of a node w′ of T not contained in the subtree of T rooted in w . The main idea of our algorithm for solving the MCRP is to use a dynamic-programming algorithm that during a bottom–up traversal of T , for each non-leaf w of T , constructs a coloring for G(w) by extending already computed colorings for G(wl ) and G(wr ). More precisely, for a subgraph G1 of a graph G2 , a coloring C2 of G2 extends a coloring C1 of G1 if C2 (v) = C1 (v) holds for all vertices v of G1 that are real colored by C1 . C2 strongly extends C1 if C2 (v) = C1 (v) holds for all vertices of G1 instead of only for the real colored vertices. The running time of our algorithm for the MCRP in Section 3.5 is O(n2 + n(4s sO(k) f (k))) for an appropriately chosen function f (k) ≤ (16k3 )4k and s—which is defined more precisely in the later parts of this paper—being bounded by the number β of so called bad colors, i.e., the number of colors c for which not all pairs of vertices of color c are C -connected with respect to the initial coloring C . Since k is independent from n, whereas s may by of size Ω (n) this is faster than the
818
F. Kammer, T. Tholey / Discrete Applied Mathematics 160 (2012) 810–833
running time O(n∆β β n) of the algorithm from Moran and Snir [15], where ∆ is the maximum degree of a vertex in the tree. The reason is that the running time on binary trees is much better than that on arbitrary trees. Thus, even for trees it can be useful to ‘‘pack’’ them into a binary tree decomposition. A similar improvement of a running time for the MCRP restricted to trees was also given by Ponta, Hüffner, and Niedermeier [17]. They improved the running time to O(3β · β n). Since it seems that β also can be replaced by the parameter used in our analysis, this improves our running time on trees. 3.2. Some preliminary definitions We need some further simple definitions before we can describe a simple version of our algorithm. For a vertex set S and a coloring C of a graph G containing a subgraph H with vertex set S, we define C (H ) = C (S ) = {C (v) | v ∈ S }. We also write G[S ] to denote the subgraph of G induced by the vertices in S. In order to restrict the number of possible colors used by a recoloring of a colored graph (G, C ), we only want to compute an expanding (re-)coloring C ′ of (G, C ), which is a recoloring C ′ of (G, C ) such that, for each real color c assigned by C ′ , there is a vertex u of G with c = C (u) = C ′ (u). As observed by Bar-Yehuda et al. [3, Observation 3] as well as by Moran and Snir [15, Observation 2.1], for each recoloring C ′′ of (G, C ), there is an expanding recoloring C ′ of (G, C ) of at most the same costs than that of C ′′ —to obtain C ′ one simply has to uncolor all vertices in (G, C ′′ ) with a color c for which there is no vertex u with c = C (u) = C ′′ (u). This means that we can restrict the real colors of a recoloring to the colors of the initial coloring. Let us next assume that we are given a tree decomposition (T , B) of a colored graph (G, C ) and a node w of T . One necessary condition that a coloring Cw of G(w) can be strongly extended to a convex coloring of G is the following: for each maximal Cw -connected component colored with a real color c and not containing any vertex of B(w), there is no other maximal Cw -connected component also colored with c. Let us call a coloring Cw with this property semiconvex (with respect to w ). Let us now consider a semiconvex coloring Cw of G(w). If there is a convex coloring C ′ strongly extending Cw , then C ′ must use the same colors as Cw for the vertices in G(w). Therefore we only need to focus on the coloring of the vertices in G − G(w). For finding a coloring of these vertices such that the resulting coloring C ′ is convex it is not necessary to know all the colors already assigned to the vertices in G(w). However, we need to know (1) for each vertex v ∈ B(w) the color Cw (v), (2) which of the vertices colored with the same color are already Cw -connected, and (3) the real colors not in Cw (B(w)) that are used by Cw for coloring a vertex in G(w) since these colors may not be used to color a vertex in G − G(w). We thus define a characteristic Q of a node w in T to be a tuple (f , P , S ) with (1) f being a function assigning to each vertex v ∈ B(w) a color in C (V ). (2) P being a partition of B(w) into non-empty vertex disjoint sets V1′ , . . . , Vk′ with B(w) = V1′ ∪ · · · ∪ Vk′ . (3) S being a subset of C (V ) \ {0}. Moreover, we define a semiconvex coloring C ′ of G(w) with colors in C (V )∪{0} to be good for Q if the following properties (p1)–(p3) hold and to be optimal for Q if additionally (p4) holds. (p1) (p2) (p3) (p4)
C ′ colors each vertex v ∈ B(w) with f (v). There is a set {(VU , EU ) | VU ⊇ U , U ∈ P } of vertex-disjoint C ′ -connected subgraphs of G(w). S = C ′ (G(w)) \ (C ′ (B(w)) ∪ {0}). C ′ has minimal costs among all semiconvex colorings of G(w) with the properties (p1)–(p3).
3.3. A simple algorithm for the MCRP In this subsection, we present a simple, but inefficient dynamic-programming algorithm for solving the MCRP for a colored graph (G, C ) with a vertex set V and a nice tree decomposition (T , B) of width k − 1 with T having O(|V |) nodes. The main idea is to compute an optimal coloring CQ for each possible characteristic Q = (f , P , S ) of a node w of T by a bottom–up traversal of T . Note that, for each expanding convex recoloring C ′ of G, there is a characteristic Q = (f , P , S ) of the root r of T such that C ′ is good for Q. We just set f (v) = C ′ (v) for all v ∈ B(r ), let each set U of P be a set of maximal size such that the vertices of U belong to the same C ′ -connected component, and define S = C ′ (V ) \ (C ′ (B(r )) ∪ {0}). Therefore, as a solution for the MCRP we can take the coloring with the minimal recoloring costs among the colorings that are optimal for a characteristic (f , P , S ) of r belonging to the following set C of characteristics. C should be the set of that characteristics (f , P , S ) of r that are computed by our algorithm and for which there is no pair of vertices belonging to different vertex sets of P being colored by f with the same real color. Note that this together with the fact that the computed colorings are semiconvex guarantees that the coloring returned is convex. What remains to show is how we can compute, for each characteristic Q of a node w , a coloring CQ that is optimal for Q. Before that, let us describe more explicitly what we exactly mean by ‘‘computing a coloring’’. One could think of representing a coloring C ′ of a graph H by an array A indexed by the vertices of H with A[v] storing the color of v . If, for each coloring CQ computed as an optimal coloring for a characteristic Q = (f , P , S ) of a node w of T , we construct a new array, this could take up to O(|Vw |) time, where Vw should be the vertex set of G(w). To reduce this running time, we use the fact that our algorithm will choose CQ as a coloring strongly extending colorings Cl and Cr that are optimal for characteristics Ql of wl and possibly Qr of wr . Given the characteristic Q, we can construct the coloring CQ if beside Q, from which we can read off the colors that CQ assigns to the vertices in B(w), we are only given pointers to the colorings Cl and Cr instead
F. Kammer, T. Tholey / Discrete Applied Mathematics 160 (2012) 810–833
819
of the colorings themselves. More precisely, since Cl and Cr can be constructed recursively in the same way, it suffices to store pointers to the characteristics Ql and Qr . For efficiently determining the costs of the recolorings we store with each characteristic Q a value costQ that is equal to the costs of an optimal coloring for Q or equal to ∞ if such a coloring does not exist. As we will see, for each characteristic Q of a node w , we can read off costQ directly from the costs stored with the characteristics for the children of w . After our bottom–up traversal, as described above we can read off the minimal recoloring cost for a solution of the MCRP as the minimal value costQ among a set of characteristics Q of the root of T . A convex recoloring of G of minimal costs can then be constructed as an optimal coloring CQ for Q by a subsequent top–down traversal of T spending not more than O(k) time at each node of T . In the following we describe the computation of costQ during the bottom–up traversal of T in detail. 3.3.1. Considering a leaf For a leaf w , finding optimal colorings is easy. We enumerate all possible colorings of the vertices in B(w) with colors in C (V ) ∪ {0}. For each such coloring Cw , we take all possible partitions P of B(w) into account such that each set of P induces a Cw -connected subgraph of G(w). We then take Cw as a good coloring for the characteristic Q = (f , P , S ) with S = ∅ and f (v) = Cw (v) for each v ∈ B(w). Among all good colorings computed for a characteristic Q, we finally choose one with minimal recoloring cost and store its cost in costQ . 3.3.2. Considering a node with two children We next consider a node w with two children. Recall that in this case B(w) = B(wl ) = B(wr ). For an optimal coloring Cw for a characteristic Q = (f , P , S ) of w , there exist characteristics Ql = (fl , Pl , Sl ) of wl and Qr = (fr , Pr , Sr ) of wr such that the following properties hold for Ql , Qr , and the colorings Cl and Cr obtained from Cw by restricting them to G(wl ) and G(wr ), respectively. (c1) fl (v) = f (v) = fr (v) for all v ∈ B(w). (c2) Pl and Pr are refinements of P, i.e., for all U ′ ∈ Pl ∪ Pr , there is a vertex set U ∈ P with U ′ ⊆ U. (c3) If {u1 , u2 } ⊆ U for a set U ∈ P, then u1 and u2 are connected in the graph (B(w), {e | e is an edge of G[B(w)] or ∃U ′ ∈ Pl ∪ Pr : e ⊆ U ′ }). (c4) Sl ∪ Sr = S and Sl ∩ Sr = ∅. (c5) Cl and Cr are optimal for Ql and Qr . Indeed, we can choose Pl and Pr as the partition that we obtain by dividing each U ∈ P into non-empty sets of maximal size such that the vertices of each set are Cl -connected in G(wl ) and Cr -connected in G(wr ), respectively. Moreover, Sl should be chosen such that (p3) holds for wl , i.e., Sl = C ′ (G(wl )) \ (C ′ (B(wl )) ∪ {0}). Sr is defined analogously. Then (c1)–(c5) easily follow from the fact that we have chosen Cw as an optimal coloring for Q. In particular, the reason that the costs of Cl and Cr must be minimal among all good colorings for Ql and Qr is that the properties above imply that costQ is costQl + costQr minus the doubly counted recoloring costs for the vertices in B(w) and that costQl does not depend on costQr and vice versa. In the reverse direction, when searching for a coloring Cw that is optimal for a characteristic Q of a node w , we only need to consider all pairs of precomputed optimal colorings Cl and Cr for characteristics Ql of wl and Qr of wr such that the properties (c1)–(c5) hold. If we then define Cw to be the coloring of G(w) with Cw (v) = Cl (v) for all v ∈ G(wl ) and Cw (v) = Cr (v) for all v ∈ G(wr ), we obtain a good coloring for Q. Note explicitly that Cw is well defined because of (c1) and the fact that the common vertices of G(wl ) and G(wr ) consist of the vertices in B(w). In detail, if we define Cw in this way, (c1) guarantees that (p1) holds, (c3) guarantees that (p2) holds, and (c4) guarantees that Cw is semiconvex and that (p3) holds. We also can compute the recoloring costs of Cw as the sum of the recoloring costs of Cl and Cr minus the recoloring costs of the vertices in B(w), i.e., as costQl + costQr − {v∈B(w)|0̸=C (v)̸=f (v)} w(v). Among all good colorings computed for Q—if there are any—we finally choose one of minimal recoloring cost and assign its cost to costQ . (c5) then implies (p4). Summing up, we can compute costQ for all characteristics Q of w with the following algorithm. (1) For all characteristics Q = (f , P , S ) of w (2) costQ = ∞ (3) For all pairs (Ql , Qr ) of characteristics for wl and wr such that (c1)–(c4) hold (4) If costQl ̸= ∞ and costQr ̸= ∞ then (5) costQ = min{costQ , costQl + costQr − {v∈B(w)|0̸=C (v)̸=f (v)} w(v)}. 3.3.3. Considering a node with one child For a node w with one child wl , we consider two subcases. First assume that B(wl ) ⊂ B(w), and let u be the vertex in B(w) \ B(wl ). For an optimal coloring Cw for a characteristic Q = (f , P , S ) of w , it is easy to see that there is a characteristic Ql = (fl , Pl , Sl ) of wl such that the following properties hold for Ql and the coloring Cl obtained from Cw by restricting it to G(wl ). (d1) fl (v) = f (v) for all v ∈ B(wl ). (d2) Pl is obtained from P by removing u from the set U ∈ P containing u and, if U \ {u} ̸= ∅, additionally splitting U \ {u} into disjoint subsets with each of them containing a vertex v adjacent to u in G.
820
F. Kammer, T. Tholey / Discrete Applied Mathematics 160 (2012) 810–833
(d3) Sl = S. (d4) Cl is optimal for Ql . In the reverse direction, when searching for a coloring that is optimal for Q, we only need to consider precomputed optimal colorings Cl for a characteristic Ql of wl with the properties defined above. If we then define Cw to be the coloring of G(w) with Cw (v) = Cl (v) for all v ∈ G(wl ) and Cw (u) = f (u), we obtain possibly a good coloring for Q. In detail, if we define Cw in this way, (d1) and our setting of Cw (u) = f (u) guarantees that (p1) holds, and (d3) guarantees that (p3) holds and that Cw is semiconvex, if additionally f (u) ̸∈ S. Finally (d2) guarantees that (p2) holds. We also can compute the recoloring costs of Cw as the sum of the recoloring costs of Cl and the recoloring costs for u, where the recoloring costs of u are w(u) if 0 ̸= C (u) ̸= f (u), and 0 otherwise. Among all good colorings computed for Q—if there are any—we finally choose one of minimal recoloring cost and assign its cost to costQ . Then, (d4) implies (p4). In the second subcase, we assume that B(w) ⊂ B(wl ), i.e., there is a vertex u in B(wl ) \ B(w). For an optimal coloring Cw for characteristic Q = (f , P , S ) of w , it is easy to see that there is a characteristic Ql = (fl , Pl , Sl ) of wl such that the following properties hold for Ql and the coloring Cl obtained from Cw by restricting it to G(wl ). (e1) (e2) (e3) (e4)
fl (v) = f (v) for all v ∈ B(w). Pl is obtained from P either by adding u to one of the sets in P or by adding a new set {u}. Sl = S \ {fl (u) | if u is the only vertex in B(wl ) colored with fl (u)}. Cl is optimal for Ql .
In the reverse direction, when searching for a coloring that is optimal for Q, we only need to consider precomputed optimal colorings Cl for characteristics Ql of wl with the properties defined above. If we then define Cw to be the coloring of G(w) with Cw (v) = Cl (v) for all v ∈ G(w), we obtain a good coloring for Q. In detail, if we define Cw in this way, (e1) guarantees that (p1) holds. (e2) guarantees that (p2) holds except in the case, where the single set {u} is part of P, fl (u) ̸= 0, and there is another vertex u′ ∈ B(wl ) with fl (u) = fl (u′ ). In the excluded case, we cannot guarantee that (p2) holds for Cw and we break off the computation of costQ from Ql . By that we mean that we do not classify Cw as a good coloring of Q and skip to the next possible characteristic for wl . (e3) guarantees that Cw is a semiconvex coloring and that (p3) holds. The recoloring costs of Cw are the same than that of Cl since we added no new vertex. Among all good colorings computed for Q—if there are any—we finally choose one of minimal recoloring cost and assign its cost to costQ . This and (e4) guarantee (p4). Summing up, for all characteristics Q = (f , P , S ) of a node w with exactly one child, costQ can be computed by the following algorithm similar to that for a node with two children. (1) For all characteristics Q = (f , P , S ) of w (2) costQ = ∞ (3) For each characteristic Ql of wl such that (i) or (ii) holds, and such that we do not have to break off the computation (i) (d1)–(d4) and B(wl ) ⊂ B(w) (ii) (e1)–(e4) and B(w) ⊂ B(wl ) (4) If (∃u ∈ B(w) \ B(wl )) and (0 ̸= C (u) ̸= f (u)) then costu = w(u) else costu = 0 (5) If costQl ̸= ∞ then (6) costQ = min{costQ , costQl + costu }. 3.4. Improving the running time for the MCRP Unfortunately, for a given colored graph (G, C ), the number of characteristics that have to be considered by the algorithm of Section 3.3 is exponential in the number of colors used by the initial coloring since there is an exponential number of possible sets for the forbidden colors. For reducing the number of possible characteristics, if the instance is a colored tree (T , C )—instead of a colored graph of bounded treewidth—Moran and Snir [15] used the fact that it suffices to construct an expanding coloring. Then, for each vertex v ∈ T , after constructing a convex recoloring Cv for the subtree Tv of T rooted in v , we need not consider any coloring C ′ extending Cv that colors vertices above v in T with a color c that is not used by C to color any vertices outside Tv : if C ′ colors vertices above v with c, then the coloring C ′′ obtained from C ′ by uncoloring all vertices u with C ′ (u) = c above v cannot have larger recoloring costs. This means in particular that we need not explicitly store such a color c in the set S of a characteristic Q = (f , P , S ) for v . For a similar approach on a colored graph (G, C ) with a nice tree decomposition (T , B) of width k − 1, for each node w of T , we define LOW(C , w) to be the real colors in C (G(wl )) ∪ C (G(wr )). Similarly, we let UP(C , w) be the real colors in C (G(¬w)), or in the special, where w is the root of T , we define UP(C , w) = C (B(w)). We also define SEP(C , w) = LOW(C , w) ∩ UP(C , w). The hope is now that, for each node w , we only have to consider characteristics Q = (f , P , S ) with S ⊆ SEP(C , w). Unfortunately, we are not in the same situation as on trees. If a real color c is used by C only to color vertices outside G(w), a recoloring C ′ of G may possibly also want to recolor a set U of vertices in G(w) with c in order to C ′ -connect some vertices with color c. However, the cost for recoloring vertices of G(w) with c is independent of the exact value of c and can be computed as the cost of uncoloring all vertices of U (since
F. Kammer, T. Tholey / Discrete Applied Mathematics 160 (2012) 810–833
821
C (v) ̸= c by our choice of c for all v in G(w)) and the cost of recoloring it (without any costs) with color c. Therefore, when considering recolorings of the graph G(w), we do not allow to color any vertex v ∈ G(w) with a real color c ̸∈ C (G(w)). Instead of this, if we want to color v with c, we uncolor v and leave it uncolored until we later reach an ancestor w ′ of w with c ∈ C (G(w ′ )), and at this time we allow to recolor v with c. This also allows us to consider at each node w exclusively expanding colorings of G(w). However, when determining an extendable coloring Cw good for a characteristic of w from colorings Cwl and Cwr for the children, we still search for an extension of Cwl and Cwr , but possibly not a strong one. Of course, then our algorithm has to be modified as is described later. Let us also consider the case that a recoloring Cw of G(w) colors a vertex set U with a real color c that is only used by C to color vertices of G(w). Then possibly some vertices of U are not already Cw -connected, but can be C ′ -connected by a coloring C ′ extending Cw . The recoloring costs of C ′ with respect to c can be divided into the recoloring costs already be counted in Cw and that for the vertices outside G(w). For any vertex v outside G(w), the cost for setting C ′ (v) = c can be computed again independently of the exact color assigned to U: we have to pay the weight of v as cost if v is real-colored by C and cost zero otherwise. Therefore the idea is to introduce a pseudocolor x just to denote the fact that U is real colored with a color c ̸∈ UP(C , w). We then set f (v) = x instead of f (v) = c in a characteristic Q = (f , P , S ) of w . More precisely, since Cw may have several vertex sets U1 , . . . , Uy colored with different real colors that are used by C to color only vertices of G(w), we use a set X = {x1 , . . . , xk } of pseudocolors, and set f (v) = xi for all i ∈ {1, . . . , k} to denote the fact that v is colored with a color c ̸∈ UP(C , w) that is the same as that of all other vertices u with f (u) = xi , but different from the color of vertices u with f (u) = xj for an j ̸= i. The modifications above allow us to redefine a characteristic to be a tuple Q = (f , P , S ) as defined before, but with f being a function from B(w) to C (B(w)) ∪ SEP(C , w) ∪ {0, x1 , . . . , xk } and S being restricted to the colors in SEP(C , w). This reduces the number of possible characteristics and later helps us to find an efficient approximation algorithm. However, the fact that we now also use pseudocolors x1 , . . . , xk and search only for extending, but not necessarily strongly extending colorings makes it necessary to modify our dynamic-programming algorithm as it is described in the following section. 3.5. The modified algorithm for the MCRP As for the simple algorithm let us assume that we are given an instance consisting of a colored graph (G, C ) with G = (V , E ) as well as a nice tree decomposition (T , B) of width k − 1 for G. Moreover, T should have O(|V |) nodes. Because of our modifications we redefine a good coloring for a characteristic Q = (f , P , S ) of a node w to be an expanding and semiconvex coloring C ′ of G(w) such that the following properties (P1a)–(P3) hold and we call it optimal if additionally (P4) holds for all v, v1 , and v2 in B(w). (P1a) (P1b) (P2) (P3) (P4)
f (v) = C ′ (v) if C ′ (v) ∈ UP(C , w) ∪ {0}. Otherwise f (v) ∈ {x1 , . . . , xk }. C ′ colors v1 and v2 with the same color iff f (v1 ) = f (v2 ). There is a set {(VU , EU ) | VU ⊇ U , U ∈ P } of vertex-disjoint C ′ -connected subgraphs of G(w). S = SEP(C , w) ∩ (C ′ (G(w)) \ C ′ (B(w))). C ′ has minimal costs among all colorings of G(w) being expanding and semiconvex for which the properties (P1a)–(P3) hold.
Property (P1a) helps us to reduce the number of possible functions f since vertices colored with colors of a possible large set C (V ) \ (UP(C , w) ∪ {0}) are now mapped to O(k) pseudocolors. However, because of property (P1b) the pseudocolors still allow us to decide which vertices of B(w) have the same color and which vertices have different colors. The other properties are the same than in our simple algorithm, except that in (P3) S is restricted to the set SEP(C , w) and in P4 we additionally want C ′ to be an expanding coloring. Similar to the simple algorithm, in a first step our new algorithm computes the costs of an optimal coloring CQ for each characteristic Q in a bottom–up traversal of T . At the root r of T , we compare the recoloring costs for the optimal colorings of that characteristics (f , P , S ) for which there is no pair of vertices belonging to different sets of P with these vertices being colored with the same real color or pseudocolor. After determining such a characteristic Q for which an optimal coloring CQ has minimal costs, we can again construct an optimal coloring C ′ by a subsequent top–down traversal and return it as a solution for the MCRP. In more detail, if during the bottom–up traversal, at a node w we have replaced a real color c assigned to a vertex v by a pseudocolor x, then reaching w in the top–down traversal, we know that because of property (P2) there is a C ′ -connected subgraph containing v that has to be recolored by c. It remains to describe the computations of the costs of the optimal colorings in the bottom–up traversal for the modified algorithm. In contrast to the simple algorithm, for each characteristic Q of an inner node w , we want to compute the costs of colorings CQ that extends—but not necessarily strongly extends—colorings constructed for the characteristics of the children of w . This means that we possibly color some previously uncolored vertices v with a real color c. The only case in which a coloring C ′ good for a characteristic of a node w is not allowed to color a vertex v with c even though this is possible for colorings extending C ′ , is the case in which the graph G(w) does not contain any vertex u with C ′ (u) = C (u) = c. Since we only want to construct expanding colorings, the idea is to change the color of v to c when we have for the first time at a node w ˜ of T an vertex v ′ with C (v ′ ) = c in G(w) ˜ . This is the reason why in the following, when constructing (the costs of) a coloring Cw good for a characteristic Q = (f , P , S ) of w by extending a coloring Cw′ optimal for a characteristic Q′ = (f ′ , P ′ , S ′ ) for a child w ′ of w , we only allow to change f ′ (v) = 0 into f (v) = c for a real color c if one of the following
822
F. Kammer, T. Tholey / Discrete Applied Mathematics 160 (2012) 810–833
cases is given: either G(w) − G(w ′ ) contains a single vertex u with Cw (u) = c, which is added to the vertex set U ∈ P ′ containing v , i.e., U ∪ {u} ∈ P, or Cw is constructed from a pair (Cw′ , Cw′′ ) of colorings such that the set U ∈ P containing v contains at least one vertex u with Cw′′ (u) = c. We next describe the modifications in detail. Our algorithm starts with a preprocessing phase in which it computes, for each node w of T , the sets SEP(C , w), LOW(C , w), and UP(C , w). It stores these sets in Boolean arrays SEPw , LOWw , and UPw indexed with the colors in C (V ), i.e., it sets SEPw [c ], LOWw [c ], and UPw [c ] to TRUE if and only if c is contained in the corresponding set. It is not hard to see that the preprocessing can be done in O(|V 2 |) time. Afterwards we start a bottom–up traversal similar to that of the simple algorithm. The next subsections describe what we have to do at each node w . 3.5.1. Considering a leaf For a leaf w finding optimal colorings is easy. We enumerate all (k + 1)k possible colorings of the vertices in B(w) with colors in C (B(w)) ∪ {0}. For each such coloring Cw , we take all possible partitions P of B(w) into disjoint non-empty Cw connected subgraphs into account. Note that splitting a maximal Cw -connected component might be necessary for a maximal uncolored component since different parts of it may be later used to C ′ -connected different pairs of vertices for a coloring C ′ extending Cw . For maximal colored Cw -connected components this is not necessary, but it will not increase the asymptotic running time of our whole algorithm. In detail, we can determine the partitions by considering all up to kk partitions P into non-empty sets and by testing in O(k) time whether all sets U ∈ P of such a partition are Cw -connected. Given a coloring Cw and a partition P as defined above, we consider all of at most kk possibilities to choose a pseudocolor for each set in P that is colored by Cw with a color not in UP(C , w) ∪ {0}. In O(k) additional time, we test whether different sets of P colored with different colors with respect to Cw obtain different pseudocolors by our choice. If so, again in O(k) time, we compute the cost of Cw and the idea is to store it as costQ for the characteristic Q = (f , P , S ) with S = ∅ and f being defined as follows: f (v) = Cw (v) for each v ∈ B(w) with Cw (v) ∈ UP(C , w), and otherwise f (v) is the pseudocolor chosen for the set U ∈ P containing v . More precisely, if there are several recolorings whose costs should be stored as costQ , we define costQ as the minimum of these costs. Running time: We spend O(k) time for each of maximal O((k + 1)k kk kk ) = O((k + 1)3k ) chosen characteristics, i.e., the total running time for a leaf is bounded by O((k + 1)3k+1 ). 3.5.2. Considering a node with two children We next consider a node w with two children. Our computation is based on the following lemma. Lemma 3.2. For an optimal coloring CQ of a characteristic Q = (f , P , S ) for w , there exist characteristics Ql = (fl , Pl , Sl ) of wl as well as Qr = (fr , Pr , Sr ) of wr and colorings Cl of G(wl ) as well as Cr of G(wr ) such that CQ extends Cl as well as Cr and the following properties hold. (C1) For all v ∈ B(w), for the set U ∈ P containing v , and for Fl = {fl (v ′ ) | v ′ ∈ U } \ {0} and Fr = {fr (v ′ ) | v ′ ∈ U } \ {0}, we have (a) (f (v) = c for a real color c ) ⇒ Fl ∪ Fr = {c }. (b) (f (v) = xi for i ∈ {1, . . . , k}) ⇒ Either Fl ∪ Fr = {c } for c ∈ C (V ) or one of Fl and Fr is ∅ and the other {xi }. (C2) Pl and Pr are refinements of P, i.e., for all U ′ ∈ Pl ∪ Pr , there is a vertex set U ∈ P with U ′ ⊆ U. (C3) If {u1 , u2 } ⊆ U for a set U ∈ P, then u1 and u2 are connected in the graph (B(w), {e | e is an edge of G[B(w)] or ∃U ′ ∈ Pl ∪ Pr : e ⊆ U ′ }). (C4) S = SEP(C , w) ∩ (Sl ∪ Sr ) and Sl ∩ Sr = ∅. (C5) Cl and Cr are optimal for Ql and Qr . Before we prove the lemma, let us compare the properties to that of the simple algorithm. The properties (C1a)–(C1b) replace the equality fr (v) = f (v) = fl (v) in property (c1). This equation in (c1) needs not hold anymore since in our modified algorithm we allow extending colorings by coloring uncolored vertices. Note that, if fl (v) = xi , this means that, for all colorings optimal for Ql , xi is colored with a color cl not in UP(C , wl ) ⊇ C (G(wr )). An expanding coloring of G(wr ) can therefore not color any vertex of G(wr ) with cl . This is the reason why we only allow one of the sets Fl and Fr to contain pseudocolors. (C4) changes slightly in comparison to (c4) because S is now restricted to SEP(C , w). All remaining properties are similar to that of our simple algorithm. Proof of Lemma 3.2. Define Cl′ to be the coloring obtained from CQ by restricting this coloring to G(wl ). Then we obtain Cl from Cl′ by uncoloring all Cl -connected components that do not contain any vertex v with Cl′ (v) = C (v). Concerning Ql , we then set fl (v) = 0 for each uncolored vertex v ∈ B(w). Moreover, for a vertex that remains colored with a real color c by Cl , if we have f (v) = xi for some i ∈ {1, . . . , k}, we set fl (v) = c if c ∈ UP(C , wl ) and otherwise fl (v) = xi so that (P1a) also holds for Cl . For all remaining vertices, we set fl (v) = f (v). Cr and fr are defined analogously. Since we have chosen CQ as an expanding coloring, it is easy to see that our definition of Cl and Cr implies that (C1) holds and that these colorings are expanding. Note also that fl (v) = c for a real color c implies that c ∈ C (G(wl )) by construction of fl and that c ∈ C (B(w)) ∪ SEP(C , w) since (f , P , S ) was chosen as a characteristic. Since B(w) = B(wl ) and since
F. Kammer, T. Tholey / Discrete Applied Mathematics 160 (2012) 810–833
823
C (G(wl )) ∩ SEP(C , w) ⊆ C (B(wl )) ∪ SEP(C , wl ), fl is a function from B(wl ) to C (B(wl )) ∪ SEP(C , wl ) ∪ {0, x1 , . . . , xk }, which is a necessary condition for fl being part of a characteristic. As in the simple algorithm, we choose Pl and Pr as the partition that we obtain by dividing each U ∈ P into non-empty sets of maximal size such that the vertices of each set are Cl -connected in G(wl ) and Cr -connected in G(wr ), respectively. Since (C2) = (c2) and (C3) = (c3), the same arguments as for the simple algorithm show that (C2) and (C3) hold. Similar to the simple algorithm, let us choose Sl such that (P3) holds for wl , Sl and Cl instead of w , S and C ′ . Sr should be chosen analogously. Then for CQ being a semiconvex coloring, we must have Sl ∩ Sr = ∅. It is also easy to see that S = SEP(C , w) ∩ (CQ (G(w)) \ CQ (B(w))) is a superset of SEP(C , w) ∩ (Sl ∪ Sr ). For each color c in S ⊆ SEP(C , w) \ CQ (B(w)), by CQ being expanding and by the properties of S there is a vertex v ∈ G(w) not contained in B(w) with CQ (v) = C (v) = c. Hence c ∈ SEP(C , wl )∩ C (G(wl )) or c ∈ SEP(C , wr )∩ C (G(wr )). Since we also have c ̸∈ CQ (B(w)) and CQ (B(w)) ⊇ Cl (B(wl )) as well as CQ (B(w)) ⊇ Cr (B(wr )), we can conclude that c ∈ Sl ∪ Sr . This shows S ⊆ SEP(C , w) ∩ (Sl ∪ Sr ) and that (C4) also holds. Concerning property (C5), we have already shown that (P1a) holds for fl and Cl instead of f and C ′ . It is not hard to see that (P1b) also holds. As for the simple algorithm, the fact that CQ is an optimal coloring for Q implies that (P2) holds for the colorings Cl and Cr and that these colorings are semiconvex. We also have defined Sl and Sr such that (P3) holds. Since we have already shown that Cl and Cr are expanding, we can conclude that Cl and Cr are good for Ql and Qr . Note finally, that
costQ = costQl + costQr −
w(v).
{v∈B(w)|0̸=C (v)̸=f (v)}
Here we use the fact that the coloring of uncolored vertices when extending Cl or Cr to CQ does not increase the costs. We can also observe that costQl is independent from costQr and vice versa. Since CQ is optimal for Q, we can therefore conclude that Cl and Cr are also optimal colorings for Ql and Qr . In the reverse direction, Algorithm 1 computes the cost of an optimal coloring for a characteristic Q of a node w from the costs of colorings Cl and Cr being optimal to characteristics Ql of wl and Qr of wl such that CQ extends Cl and Cr and such that the properties (C1)–(C5) hold. Algorithm 1: The computation at a node w with two children Input: A characteristic Q = (f , P , S ) of w , and the costs of all characteristics for the children Output: costQ (1) costQ = ∞ (2) If no set U ∈ P contains two vertices u1 , u2 with f (u1 ) ̸= f (u2 ) then (3) For all fl : B(wl ) → C (B(wl )) ∪ SEP(C , wl ) ∪ {0, x1 , . . . , xk } and fr : B(wr ) → C (B(wr )) ∪ SEP(C , wr ) ∪ {0, x1 , . . . , xk } s.t. (C1) holds (4)
For all possible refinements Pl and Pr of P // (C2) holds
(5)
G′ = (B(w), {e | e is an edge of G[B(w)] or ∃U ∈ Pl ∪ Pr : e ⊆ U })
(6)
If all sets U ∈ P are connected in G′ then // (C3) holds
(7) (8) (9)
For all Sl ⊆ SEP (C , wl ) and Sr ⊆ SEP (C , wr ) with Sl ∩ Sr = ∅ If S = SEP(C , w) ∩ (Sl ∪ Sr ) then // (C4) holds If {f (v) | f (v) ∈ C (V )} ⊆ UP(C , w) ∪ {0} then
(10)
If for all v ∈ B(w) with f (v) ∈ {x1 , . . . , xk }
(11)
Ql = (fl , Pl , Sl ), Qr = (fr , Pr , Sr )
(12)
If costQl < ∞ and costQr < ∞ then
we have {fl (v), fr (v)} ∩ UP(C , w) = ∅ then
(13)
costQ = min{costQ , costQl + costQr −
{v∈B(w)|0̸=C (v)̸=f (v)} w(v)}
(14) Return costQ Correctness of Algorithm 1: Line (2) excludes some characteristics for which (P2) cannot hold. In the lines (3)–(8) the algorithm enumerates all possibilities to choose Ql and Qr such that (C1)–(C4) hold and hence (C5) holds for colorings being optimal to these characteristics. The additional tests in line (9) and line (10) exclude a wrong usage of the pseudocolors. If one of these cases is not given, we obtain a contradiction to (P1a). In more detail, in line (10) we use the fact that, for a coloring Cw extending colorings optimal for Ql and Qr , we must have Cw (v) = c if {fl (v), fr (v)} ∩ UP(C , w) = {c } for a real color c. We next show that, if there are colorings Cl and Cr that are optimal for characteristics Ql and Qr computed by our algorithm, then there is a coloring Cw extending Cl and Cr that is good for Q. We choose Cw as follows: for each vertex v with f (v) ̸= 0, contained in a set U ∈ P, we choose a vertex u ∈ U such that at least one of the values fl (u) and fr (u) is different from 0. Such a value must exist because of (C1). By symmetry, let us assume w.l.o.g. that fl (u) ̸= 0. Then Cl
824
F. Kammer, T. Tholey / Discrete Applied Mathematics 160 (2012) 810–833
colors v with a real color c. (C1) also guarantees that no vertex of U is colored by Cl or Cr with a real color different from c. For all vertices contained in an uncolored set U ′ ∈ Pl ∪ Pr with U ′ ⊆ U, we color these vertices with c, which is the only possibility to color the vertices of U ′ without violating (P1b). Moreover, if (VU ′ , EU ′ ) is the vertex-disjoint subgraph containing the vertices of U ′ in property (P2) with respect to Pl or Pr , then we also recolor all vertices of VU ′ with c. Then the resulting coloring Cw clearly extends the colorings Cl and Cr and together with (C3) we can conclude that (P2) holds. Since Cl and Cr are semiconvex, the same is true for Cw . Note also that Cl and Cr are expanding. Then because of (C3) and the fact that, for each set U ∈ P with f (v) ̸= 0 for the vertices v ∈ U, there is a vertex u ∈ U with at least one of fl (u) and fr (u) being different from 0, we can conclude that Cw is also expanding. Since for each U ∈ P we color all vertices with the same color, we can guarantee (P1b). The additional tests in the lines (9)–(10) guarantee that (P1a) holds. Finally (P3) holds because of (C4). Since therefore Cl and Cr can be extended to a good coloring for Q and the coloring of uncolored vertices does not increase the costs, line (14) correctly returns costQ . Running time: Recall that |B(w)| ≤ k. It is not hard to see that in line (5) G′ can be constructed in O(k2 ) time and that the tests of the lines (6), (9), (10) run also in this time if we are given the arrays SEPw and UPw computed in the preprocessing phase. Line (8) runs in O(|SEP(C , w)|) time. If A is the number of pairs of characteristics (Ql , Qr ) that are considered in the algorithm, the whole running time of Algorithm 1 is therefore O(A · (|SEP(C , w)| + k2 )). Let us analyze, for a single vertex v ∈ B(w), how many choices we have to choose colors for fl (v) and fr (v). Let us say that one of these values dominates the other value if either it is different from 0 or if both values are 0. Moreover, let s = max{|SEP(C , w)| : w is a node of T }. Then we have to choose either fl (v) and fr (v) as the dominating value. If f (v) = 0, the dominating value must be also 0. If f (v) = c, it can be either 0 or c. If f (v) = xi , we have the choice between s + k + 2 values in C (B(wl )) ∪ SEP(C , wl ) ∪ {0, xi }. For the other value of fl (v) and fr (v), there remain at most two possibilities, namely to choose it equal to the dominating value or to be 0. Altogether we have at most O((k + s + 2)k 4k ) possibilities to choose fl (v) and fr (v). There are at most kk possibilities to choose Pl and the same is true for Pr . Note that in line (7) there are at most 2s possibilities to choose Sl . For a node w of T and a fixed set Sl , there are only O(2k ) possibilities to choose Sr such that the condition in line (8) is satisfied. Consequently, the running time for Algorithm 1 can be bounded by O(2s 2k (k + s + 2)k 4k kk kk (s + k2 )) = O(2s sO(k) f (k)) for some fixed function f . 3.5.3. Considering a node with one child For a node w with one child wl , we consider two subcases. First assume that B(wl ) ⊂ B(w), and let u be the only vertex in B(w) \ B(wl ). Then our algorithm is based on the following lemma. Lemma 3.3. For an optimal coloring CQ for a characteristic Q = (f , P , S ) of w , there exists a characteristic Ql = (fl , Pl , Sl ) of wl and a coloring Cl of G(wl ) such that CQ extends Cl and such that the following properties hold. (D1) For all v ∈ B(w), for the set U ∈ P containing v , and for Fl = {fl (v ′ ) | v ′ ∈ U \ {u}} \ {0}, we have (a) (f (v) = c ) ⇒ ((Fl = {c }) or (Fl = ∅, c = C (u), and u ∈ U )). (b) (f (v) = xi ) ⇒ (Fl is a subset of {xi } ∪ C (V ) of size 1 or (Fl = ∅, C (u) ̸∈ UP(C , w), and u ∈ U )) (D2) Pl is obtained from P by removing u from the set U ∈ P containing u and, if U \ {u} ̸= ∅, additionally splitting U \ {u} into disjoint subsets with each of them containing a vertex v adjacent to u in G. (D3) S = SEP(C , w) ∩ Sl . (D4) Cl is optimal for Ql . Before we prove the lemma, let us explain the property (D1). When extending a coloring of G(wl ) to a coloring of G(w), u is the only vertex that may be added to an Cl -connected subgraph. Let U ∈ P as described in (D1). Then, as mentioned before our detailed descriptions, we only want to change the color of the vertices of U if u ∈ U. This is why, in the case of u ̸∈ U, we must have Fl = {c } if f (v) = c and Fl ∈ {xi } ∪ C (V ) if f (v) = xi . Only in the case u ∈ U, we may possibly have Fl = ∅ and recolor the vertices of U with the initial color C (u) of u, i.e., we must either have f (v) = xi , if C (U ) ̸∈ UP(C , w), or f (v) = C (u), otherwise. Proof of Lemma 3.3. Define Cl′ to be the coloring obtained from CQ by restricting this coloring to G(wl ). Then as in the proof of Lemma 3.2, we obtain Cl from Cl′ by uncoloring all Cl -connected components that do not contain any vertex v with Cl′ (v) = C (v). Concerning Ql , we then set fl (v) = 0 for each uncolored vertex v ∈ B(w). Moreover, for a vertex that remains colored with a real color c by Cl , if we have f (v) = xi for some i ∈ {1, . . . , k}, we set fl (v) = c if c ∈ UP(C , wl ) and otherwise fl (v) = xi so that (P1a) also holds for Cl . For all remaining vertices, we set fl (v) = f (v). Since we have chosen CQ as expanding coloring, it is easy to see that our definition of Cl implies that (D1) holds and Cl is expanding. Note also that fl (v) = c for a real color c implies that c ∈ C (B(w)) ∪ SEP(C , w) since (f , P , S ) was chosen as a characteristic for w . Since B(w) = B(wl ) ∪ {u} and since each color in C (G(wl )) ∩ SEP(C , w) must either belong to C (B(wl )) or to SEP(C , wl ), fl is a function from B(wl ) to C (B(wl )) ∪ SEP(C , wl ) ∪ {0, x1 , . . . , xk }, which is a necessary condition for fl being part of a characteristic. We also choose Pl such that (D2) holds. As in the simple algorithm, let us choose Sl such that (P3) holds for wl , Sl and Cl instead of w , S and C ′ . For each color c in S ⊆ SEP(C , w) \ CQ (Bw ), by C ′ being expanding and by the properties of S there is a vertex v ∈ G(w) not contained in B(w) with CQ (v) = C (v) = c. Hence c ∈ SEP(C , wl ) ∩ C (G(wl )). Since we also have c ̸∈ CQ (B(w)) and CQ (B(w)) ⊇ Cl (B(wl )), we can conclude that c ∈ Sl . This shows that (D3) also holds.
F. Kammer, T. Tholey / Discrete Applied Mathematics 160 (2012) 810–833
825
Concerning property (D4), we have already shown that (P1a) holds also for fl and Cl instead of f and C ′ . It is not hard to see that (P1b) also holds. Since the vertex sets of G(w) and G(wl ) only differ in vertex u, CQ being optimal for Q, also implies that (P2) holds for Cl and that this coloring is semiconvex. Finally we have chosen Sl such that (P3) holds. We hence can conclude that Cl is good for Ql . The recoloring costs for costQ consist of the sum of the recoloring costs for u and costQl since the coloring of uncolored vertices when extending Cl to CQ does not increase the costs. Since costQl is independent from the recoloring costs for u, Cl must be an optimal coloring for Ql . In the reverse direction, Algorithm 2 computes the cost of an optimal coloring for a characteristic Q of a node w from the costs of colorings Cl optimal for characteristics Ql of wl such that CQ extends Cl and such that the properties (D1)–(D4) hold. Algorithm 2: The computation at a node w with one child wl Subcase: ∃u ∈ B(w) \ B(wl ) Input: A characteristic Q = (f , P , S ) of w , and the costs of all characteristics for the child Output: costQ (1) costQ = ∞ (2) If no set U ∈ P contains two vertices u1 , u2 with f (u1 ) ̸= f (u2 ) then (3) For all fl such that (D1) holds (4) (5) (6) (7) (8) (9)
For all choices of Pl according to (D2). For all Sl ⊆ SEP (C , wl ) IfS = SEP(C , w) ∩ Sl then // (D3) holds If f (u) ̸∈ S then If {f (v) | f (v) ∈ C (V )} ⊆ UP(C , w) ∪ {0} then If {fl (v) | v ∈ B(w), f (v) ∈ {x1 , . . . , xk }}∩ UP(C , w) = ∅ then
(10)
Ql = (fl , Pl , Sl )
(11)
If f (u) = C (u) or
(12) (13) (14)
(f (u) ∈ {x1 , . . . , xk } and {fl (u) | u ∈ U } ⊆ {0, C (u)}) then costQ = min{costQ , costQl } Else costQ = min{costQ , costQl + w(u)}
(15) Return costQ Correctness of Algorithm 2: Line (2) excludes some characteristics for which (P2) cannot hold. In the lines (3)–(6) the algorithm enumerates all possibilities to choose Ql such that (D1)–(D3) hold and hence (D4) holds for colorings optimal to Ql . Line (7) excludes the cases in which the simple algorithm breaks off the computation. The additional tests in line (8) and line (9) exclude a wrong usage of the pseudocolors as in the case of w having two children. We next show that, if there is a coloring Cl optimal for one of the computed characteristics Ql , then there is a coloring Cw extending Cl that is good for Q. We choose Cw as follows: for each set U ∈ P, for which there is at least one vertex v ∈ U with fl (v) ̸= 0, Cl colors u with a real color c. (D1) and line (2) guarantee that no vertex of U is colored by Cl with a real color different from c. For all vertices contained in an uncolored set U ′ ∈ Pl with U ′ ⊆ U, we let Cw color these vertices with c, which is the only possibility to color the vertices of U ′ without violating (P1b). If there is no vertex in U with fl (v) = 0, then by property (D1) we must either have f (v) = C (u) or f (v) ∈ {x1 , . . . , xk } and C (u) ̸∈ UP(C , w). Hence, we let Cw color the vertices of U by C (u). Then Cw extends Cl . Recall that we want to allow color changes of a vertex only when extending an Cl -connected subgraph by adding additional vertices to the subgraph such that one of the additional vertices is colored by its original color. Therefore, besides Cw we do not need to consider any other colorings extending Cl . (P2) holding for Pl , Cl being semiconvex, and (D2) guarantee that Cw is also semiconvex and that (P2) holds for Cw . Since Cl is expanding the same holds for Cw , where we use the fact that u is either added to an Cl -connected subgraph containing at least one vertex v with Cl (v) = C (v) or u is colored with C (u). Since for each U ∈ P we color all vertices with the same color, we can guarantee (P1b). The additional tests in the lines (8)–(9) guarantee that (P1a) holds. Finally (P3) holds because of (D3). Since therefore Cl can be extended to a good coloring for Q and the coloring of uncolored vertices does not increase the costs, lines (11)–(14) correctly compute costQ . Running time: Let s = max{|SEP(C , w)| : w is a node of T }. Recall that |B(w)| ≤ k. Each single execution of the lines in the algorithm can be easily implemented within O(s + k2 ) time. Hence the whole running time is bounded by O(A(s + k2 )), where A is the number of possible characteristics to be considered. It is not hard to see that this number is not larger than that of the pairs of characteristics that we consider in the case of a node with two children. Therefore the running time is dominated by the running time of O(2s sO(k) f (k)) for the function f used in the running time analysis of a node with two children.
826
F. Kammer, T. Tholey / Discrete Applied Mathematics 160 (2012) 810–833
Let us next consider the second subcase in which we have B(w) ⊂ B(wl ). Let u be the only vertex in B(wl ) \ B(w). Then our algorithm is based on the following lemma. Lemma 3.4. For an optimal coloring CQ for a characteristic Q = (f , P , S ) of w , there exists a characteristic Ql = (fl , Pl , Sl ) of wl and a coloring Cl of G(wl ) such that CQ extends Cl and such that the following properties hold. (E1) For all v ∈ B(w), we have (a) (f (v) = c ) ⇒ (fl (v) = c ). (b) (f (v) = xi ) ⇒ (fl (v) ∈ {xi } ∪ (C (V ) \ {0})). (E2) Pl is obtained from P either by adding u to one of the sets in P or by adding a new set {u}. (E3) S = SEP(C , w) ∩ (Sl ∪ ({fl (u)} \ {fl (v) | v ∈ B(w)})). (E4) Cl is optimal for Ql . Note that G(w) = G(wl ). Hence, when extending a coloring Cl of G(wl ) to a coloring Cw of G(w), we do not want to make any color changes. This is the reason why in (E1) we can assume that a vertex colored by Cw must already be colored with the same color by Cl . In a characteristic we only may have to change a real color to a pseudocolor. Proof of Lemma 3.4. Since G(w) = G(wl ), we chose Cl = CQ . Then because of Cw being semiconvex and expanding, the same is true for Cl . For each vertex v colored by Cw with a color c ∈ UP(C , wl )\ UP(C , w), i.e. in particular f (v) ∈ {x1 , . . . , xk }, we set fl (v) = c, whereas in all other cases we set fl (v) = f (v). Then (E1) holds. Moreover, (P1a) and (P1b) then holds with respect to Cl and Ql since they hold with respect to CQ and Q. Similar as in the proof of Lemma 3.3 we can also show that fl is a function from B(wl ) to C (B(wl )) ∪ SEP(C , wl ) ∪ {0, x1 , . . . , xk }, which is a necessary condition for fl being part of a characteristic. As partition Pl we choose the partition obtained from P by dividing each U ∈ P into non-empty sets of maximal size such that the vertices of each set are Cl -connected in G(wl ). Then the fact that (P2) holds with respect to Q implies that it also holds with respect to Ql , and that (E2) holds additionally. As in the simple algorithm, let us choose Sl such that (P3) holds for wl , Sl and Cl instead of w , S and C ′ . It is not hard to show that S ⊇ SEP(C , w) ∩ (Sl ∪ ({fl (u)} \ {fl (v) | v ∈ B(w)})). Since CQ is optimal for Q, the properties of S imply that, for each color c in S ⊆ SEP(C , w) \ CQ (B(w)), there is a vertex v ∈ G(w) not contained in B(w) with CQ (v) = C (v) = c. If CQ (v) ̸= CQ (u) which also implies v ̸= u, we also have c ∈ SEP(C , wl ) ∩ C (G(wl )) as well as c ̸∈ Cl (B(wl )). This means c ∈ Sl . In contrast, the color CQ (u) is not contained in Sl , but it is contained in S if and only if u is the only vertex in B(wl ) colored with CQ (u) and CQ (u) ∈ SEP(C , w). This shows that (E3) holds. Concerning property (E4), we have already shown that (P1) and (P2) hold with respect to fl and Cl . (P3) holds by definition. We hence can conclude that Cl is good for Ql . The recoloring costs for costQ are the same than that of costQl since the colorings CQ and Cl do not differ. Since CQ is optimal for Q, Cl must be also optimal for Ql . In the reverse direction, Algorithm 3 computes the cost of an optimal coloring for a characteristic Q of a node w from the costs of colorings Cl optimal to characteristics Ql of wl such that CQ extends Cl and such that the properties (E1)–(E4) hold. Algorithm 3: The computation at a node w with one child wl Subcase: ∃u ∈ B(wl ) \ B(w) Input: A characteristic Q = (f , P , S ) of w , and the costs of all characteristics for the child Output: costQ (1) costQ = ∞ (2) If no set U ∈ P contains two vertices u1 , u2 with f (u1 ) ̸= f (u2 ) then (3) (4)
For all fl such that (E1) holds For all Pl such that (E2) holds
(5)
For all Sl ⊆ SEP(C , wl )
(6)
If S = SEP(C , w) ∩ (Sl ∪ ({fl (u)} \ {fl (v) | v ∈ B(w)})) then // (E3)
(7) (8)
Let U be the set in Pl with u ∈ U. If |U | > 1 or fl (u) = 0 or @v ∈ B(wl ) \ {u} with fl (u) = fl (v) then
(9) (10)
If {f (v) | f (v) ∈ C (V )} ⊆ UP(C , w) ∪ {0} then If {fl (v) | v ∈ B(w), f (v) ∈ {x1 , . . . , xk }} ∩ UP(C , w) = ∅ then
(11)
Ql = (fl , Pl , Sl )
(12)
costQ = min{costQ , costQl }
(13) Return costQ
F. Kammer, T. Tholey / Discrete Applied Mathematics 160 (2012) 810–833
827
Correctness of Algorithm 3: Line (2) excludes some characteristics for which (P2) cannot hold. In the lines (3)–(6) the algorithm enumerates all possibilities to choose Ql such that (E1)–(E3) hold and hence (E4) holds for colorings optimal to Ql . Line (8) excludes the case in which the simple algorithm breaks off the computation. The additional tests in line (9) and line (10) exclude a wrong usage of the pseudocolors as in the case of w having two children. We next show that, if there is a coloring Cl optimal for one of the computed characteristics Ql , then this coloring is good for Q. The tests in line (9) and line (10) guarantee that (P1a) holds. (P1b) also holds since it holds with respect to fl . Line (8), the fact that (P2) holds with respect to Pl and Cl , and the fact that Cl is semiconvex with respect to G(wl ) guarantee that Cl is semiconvex with respect to G(w) and that (P2) holds with respect to P and Cl . (P3) holds because of (E3). Finally, Cl is an expanding coloring. Since therefore Cl is good for Q, line (12) correctly computes costQ . Running time: Let s = max{|SEP(C , w)| : w is a node of T }. Recall that |B(w)| ≤ k. With the exception of the lines (3)–(5) in which we encounter the several possibilities for the characteristics, each line of the algorithm can be easily implemented such that it runs in O(s+k2 ) time. Hence the whole running time is bounded by O(A(s+k2 )), where A is the number of possible characteristics to be considered. It is not hard to see that this number is not larger than that of the pairs of characteristics that we consider in the case of a node with two children. Therefore the running time is dominated by the running time of O(2s sO(k) f (k)) for the function f used in the running time analysis for a node with two children. We bounded the running time for Algorithms 1, 2, and 3 by O(2s sO(k) f (k)) for some fixed function f . Unfortunately, we have to run each of these algorithms for each node w of T and each possible characteristic Q of w . By arguments similar to that used in the running time analysis for single algorithms it is easy to see that there are at most O(2s sO(k) g (k)) possible characteristics for each node of T , where g is some appropriately chosen function. Summing up the time for the preprocessing phase and the running time for the computation at each node of T , we therefore obtain the following theorem. Theorem 3.5. Given a colored graph (G, C ) and a nice tree decomposition (T , B) of width k − 1, the MCRP can be solved in O(n2 + n(4s sO(k) f (k))) time for some fixed function f , where s = max{|SEP(C , w)| : w is a node of T }. It is easy to modify the algorithm above such that it solves the MRRP within the same time bound: in each bottom–up step we only have to explicitly forbid that an initially real colored vertex is colored with another real color. Theorem 3.6. Given a colored graph (G, C ) and a nice tree decomposition (T , B) of width k − 1, the MRRP can be solved O(n2 + n(4s sO(k) f (k))) time for some fixed function f , where s = max{|SEP(C , w)| : w is a node of T }. For the rest of Section 3, we want to call for each characteristic Q = (f , P , S ) the colors in S the forbidden colors of Q since a coloring extending a good coloring for Q cannot use these colors. The only reason that the algorithms above for the MCRP and the MRRP are exponential in s = max{|SEP(C , w)| : w is a node of T } is that we have to encounter 2s different possible sets of forbidden colors. Recall that storing forbidden colors in a characteristic of a node w of T is necessary to distinguish between recolorings that color a subgraph of G(w), but no vertex in B(w) with a forbidden color c from recolorings that do not use color c. The good news concerning the MBRP on a general initial coloring and the MRRP with its initial coloring being an (∞, 3)-coloring is that we can omit to store the forbidden colors explicitly. We next describe the necessary modifications. 3.6. An exact algorithm for the MBRP For the MBRP we use the same basic algorithm as for the MCRP. However, we compute as a solution for the MBRP w.l.o.g. only recolorings that, for each real color c, either recolor none or all of the vertices initially colored with c. Following this approach, a characteristic of a node w should only represent recolorings that, for each real color c, either recolor all or none of the vertices v in G(w) for which C (v) = c holds. If in the latter case there is a vertex in G(w) and also a vertex outside G(w) initially colored with c, we claim that a vertex of B(w) is also colored with c since, otherwise, the recoloring cannot be extended to an expanding convex recoloring not recoloring any vertex of c. This implies an additional rule for constructing characteristics: Assume that—as in our basic algorithm—we want to construct a characteristic Q = (f , P , S ) of a non-leaf w from a characteristic Qx = (fx , Px , Sx ) of a child wx of w . Then we are only allowed to use a real color c as a value for f if (1) for all vertices v in B(w) that are initially colored with c, we have f (v) = c and (2) either Qx also contains a vertex v ∈ B(wx ) with fx (v) = c or c ̸∈ C (G(wx )). To test condition (2) efficiently, we construct in a preprocessing phase for each node w an array Aw with the following entries: for each color c ∈ C (G), Aw [c ] = 1 if G(w) contains a vertex v with C (v) = c. Otherwise Aw [c ] is defined to be 0. If the array is computed by a bottom–up traversal of T , the preprocessing phase takes O(n2 ) time. After the preprocessing phase we can test, for each characteristic Q of a node w constructed from characteristics Ql and possibly Qr of its children and each color c, in O(k) time whether (1) and (2) hold. Hence, the asymptotic running time of our algorithm does not increase. Moreover, our additional rule enables us to find out, for each real color c, whether a vertex of G(wx ) (x ∈ {l, r}) is colored with c by considering Awx [c ] and by testing whether fx assigns c to a vertex. Hence, there is no need to store the forbidden colors, i.e., for the MBRP, it is enough to define a characteristic as a tuple Q = (f , P ). Theorem 3.7. Given a graph with a tree decomposition (T , B) of bounded width the MBRP can be solved in polynomial time.
828
F. Kammer, T. Tholey / Discrete Applied Mathematics 160 (2012) 810–833
3.7. An exact algorithm for the MRRP More complicated modifications are necessary for our new algorithm for the MRRP on (∞, 3)-instances. We first give an overview over the main ideas. We still want to use an algorithm very similar to that of our old algorithm for the MRRP at the end of Section 3.5. However, extending a coloring C1 of a subgraph H of a colored graph (G, C ) to a coloring C2 of G should now mean that C2 (v) = C1 (v) for all vertices v of H that are real colored by either C1 or C . We also restrict the set of recolorings of a colored graph (G, C ) with G = (V , E ) to a smaller set C of recolorings that does not contain all possible recolorings of (G, C ), but at least all expanding convex recolorings C ′ of (G, C ) that, for each color c, have the following additional property1 :
(P5)c C ′ colors either none or at least two of the vertices initially colored with c, i.e. |{v ∈ V | C ′ (v) = C (v) = c }| ∈ {0, 2, 3}. The restriction helps us to simplify our algorithm for the MRRP. More precisely, we designate some few nodes of a nice tree decomposition (T , B) for G as so-called c-connection nodes. At such a node w , when constructing a recoloring C ′ of G(w), we decide which of the initially with c colored vertices should be colored with c by a recoloring C ∗ of G extending C ′ . For a characteristic Q = (f , P , S ) of a node w , we also slightly change the meaning of the function f . For a real color c , f (v) = c now should not only mean that C ′ (v) = c for each good coloring C ′ for Q. It should also mean that every coloring C ∗ of G extending C ′ should C ∗ -connect v to another initially with c colored vertex. More exactly, for the nearest proper ancestor w′ of w being a c-connection node, and the subtree T ′ of T rooted in the child of w ′ containing w , setting f (v) = c means the following. For at least one initially with c colored vertex u that is contained in at least one bag outside T ′ , v should be C ′ -connected to u for all recolorings C ′ of G extending a good coloring for Q. To guarantee such a connection we will use the following restriction when constructing a good coloring C ′ for a characteristic Q = (f , P , S ) of a non-c-connection node w ˜ = (f˜ , P˜ , S˜ ) of a child w by extending a good coloring C˜ for a characteristic Q ˜ of w: if there is a vertex v ∈ B(w) ˜ with f˜ (v) = c, there must be also a vertex v ∈ B(w) with f (v) = c. Intuitively, this restriction means that a color cannot disappear, when ˜ . Note that the possible disappearance of colors was the only reason for the introduction of forbidden constructing Q from Q colors. Hence there is no need to store any forbidden color anymore. The only remaining problem is the restriction to the colorings in C . Therefore, we modify the cost stored with a characteristic such that we still can consider only recolorings in C , but at the end of our algorithm we can read off the costs of an optimal solution from the costs stored with the characteristics for G. We next describe our modifications in detail. Let us assume that we are given a colored graph (G, C ) with G = (V , E ) and a nice tree decomposition (T , B) of width k − 1 such that T has O(|V |) nodes. We next describe the modifications for a color c for which there are exactly three vertices initially colored with c. For each such color c, we choose a node w ˆ c as a node of largest depth such that G(w ˆ c ) contains all vertices initially colored with c. Let us denote u1 , u2 , and u3 to be these vertices of color c. The definition of w ˆ c is unique if, for no node w of T , the bag B(w) contains all three vertices u1 , u2 , and u3 . Let Tc be the subtree of T rooted in w ˆ c . For i ∈ {1, 2, 3}, let wi be the node of smallest depth in Tc with B(wi ) containing ui . For two nodes w, w ′ of T , we let lca(w, w ′ ) be the lowest common ancestor of w and w ′ . Then, the c-connection nodes of T consist of the nodes in {lca(wi , wj ) | 1 ≤ i < j ≤ 3}, which in detail consist of the node w ˆ c and possibly one further node. All other nodes in Tc are called non-c-connection nodes. In a first step we modify our old algorithm for the MRRP such that it computes a solution for the MRRP without making explicit use of forbidden colors. As in our old algorithm for the MRRP, we compute the cost of a characteristic Q = (f , P , S ) at a non-leaf w by considering characteristics Ql and possibly Qr for the children wl and wr . A first change of our new algorithm is the following. If w is a non-c-connection node with c ̸∈ {f (v) | v ∈ B(w)}, then it excludes all pairs of characteristics Ql = (fl , Pl , Sl ) and Qr = (fr , Pr , Sr ) from the computations for which c ∈ {fl (v) | v ∈ B(wl )} ∪ {fr (v) | B(wr )}. We call this the upcoloring rule. This rule excludes some coloring from our computations, but it will not exclude any coloring for which property (P5)c holds for each real color c. Roughly speaking, by contraposition the upcoloring rule means that from characteristics Ql and Qr assigning a color c to a vertex in B(wl ) or B(wr ), we can only construct characteristics Q assigning the color c to at least one vertex in B(w). In particular, at a node w of T with the subtree Tw of T rooted in w not containing any c-connection nodes, there is no need to store c as forbidden color. If a vertex of G(w) is colored with c, then B(w) must also contain a vertex of color c, i.e., the color c cannot disappear. We next describe the modification of the computations at the c-connection node w ̸= w ˆ c —if it exists. By definition, w = lca(wi , wj ) for some i, j ∈ {1, 2, 3} with i ̸= j. Say, w = lca(w1 , w2 ). Let again Ql = (fl , Pl , Sl ) and Qr = (fr , Pr , Sr ) be characteristics of wl and wr —if wl or wr exist—that are considered by our old algorithm during the computation of the cost of a characteristic Q = (f , P , S ) for w . First we want to show that with our upcoloring rule we can easily determine the colors assigned to the vertices u1 and u2 for each good coloring C ′ of Q extending good colorings Cl for Ql and Cr for Qr . For i ∈ {1, 2}, we argue for ui as follows. If wi = w , we have C ′ (ui ) = f (ui ). Otherwise, wi is contained in one of the subtrees Tl rooted in wl or Tr rooted in wr . Moreover, w3−i is not contained in the subtree containing wi . By our upcoloring rule, if wi ∈ Tl , we must have C ′ (ui ) = Cl (ui ) = c if and only if c ∈ {fl (v) | v ∈ B(wl )}. Analogously, if wi ∈ Tr , then C ′ (ui ) = c if
1 For an easier intuition, the reader may replace ‘‘at least’’ by ‘‘exactly’’. It would be possible to explicitly forbid all colorings without this property, but some few parts of the algorithm are easier to describe without this explicit restriction.
F. Kammer, T. Tholey / Discrete Applied Mathematics 160 (2012) 810–833
829
and only if c ∈ {fr (v) | v ∈ B(wr )}. After finding out which vertices of {u1 , u2 } are colored with c by all colorings being good for Q, we apply the following changes in comparison to our old algorithm. If none of the vertices in {u1 , u2 } is colored with c, there are no changes. If exactly one of u1 and u2 is colored with c and if there is a vertex v ∈ B(wl ) \ B(w) with {v} = {u | fl (u) = c }, we break off the computations of costQ from Ql —note that in this case for no coloring extending a coloring good for Ql the property (P5)c holds. By this modification we can guarantee that, if there is at least one vertex of {u1 , u2 } colored with c, then there is also a vertex v ∈ B(w) with f (v) = c. Consequently, our upcoloring rule for the non-c-connection nodes above w guarantees that each coloring C ′′ of G extending a good coloring C ′ for Q must color a least one vertex in each of the bags above w and below w ˆ c with c. This is as we want it to be since, in this case, the colored vertex of {u1 , u2 } should be C ′′ -connected to u3 —recall that we only need to consider colorings with property (P5)c and in the overview of our algorithm we slightly changed the meaning of a characteristic. Since the first node above w that is also an ancestor of w3 is w ˆ c , the bags of the treepath from w to w ˆ c must indeed contain a vertex with color c. If u1 and u2 are both colored with c, the expanding convex recolorings of (G, C ) extending C ′ can be divided into two subclasses. The first subclass consists of the colorings C ′′ that C ′′ -connect u1 and u2 to u3 , and the second class of the colorings C ′′ that only C ′′ -connect c1 and c2 , but uncolor u3 . For the first class there is again no problem with our upcoloring rule when setting f (v) = c for a vertex v ∈ B(w). Note that, for some colorings C ′′ of the second class, there may be bags on the treepath from w to w ˆ c with no vertex of these bags being colored with c by C ′′ . Our upcoloring rule for the non-cconnection nodes would forbid this disappearance of the color c. Therefore, we introduce a new color c ′ as well as a new characteristic Q′ = (f ′ , P , S ) for w that we obtain from Q if we replace f (v) = c by f ′ (v) = c ′ for all vertices v ∈ B(w) with f (v) = c. Setting f (v) = c ′ intuitively means that C ′ (v) = c, but, for each expanding convex coloring C ′′ of (G, C ) extending a good coloring for Q′ , the C ′′ -connected component containing v contains not u3 . This is the reason why our upcoloring rule should not hold for the newly introduced colors. Our new algorithm uses the same subalgorithm as our old algorithm to compute costQ , but it assigns these costs also to the characteristic Q′ . Whereas Q represents the colorings of our first class, Q′ represents the colorings of the second class. Since w may be a ci -connection node for at most k colors ci (i ∈ {1, . . . , k}), a characteristic Q can introduce up to 2k new different characteristics for all combinations of replacing or not replacing a color ci by ci′ . By the modifications above, for all colorings C ′′ extending a good coloring for a characteristic Q∗ = (f ∗ , P ∗ , S ∗ ) of w, C ′′ colors at least one of the vertices in {u1 , u2 } with c if and only if {c , c ′ } ∩ {f (v) | v ∈ B(w)} ̸= ∅. Let us next analyze what changing c to c ′ means with respect to the forbidden colors. Recall that our upcoloring rule does not hold for c ′ . When ˜ = (f˜ , P˜ , S˜ ) constructing a characteristic Q∗ = (f ∗ , P ∗ , S ∗ ) for a node w ∗ being a proper ancestor of w from a characteristic Q of a child w ˜ of w ∗ with f˜ assigning the color c ′ to at least one vertex of B(w) ˜ , we now do not guarantee that f ∗ also assigns c ′ to a vertex of B(w ∗ ). However, if w ∗ is a non-c-connection node and no vertex in a set U ∗ ∈ P ∗ was already contained in ˜ then f ∗ (u∗ ) ̸∈ {c , c ′ } holds for all vertices of u∗ ∈ U ∗ . This holds since G(w ∗ ) a set U˜ ∈ P˜ with f˜ (˜u) ∈ {c , c ′ } for all u˜ ∈ U, does not contain any vertices outside G(w) initially colored with c. Therefore, once again there is no need to store c or c ′ as forbidden color for the computation of the cost for a characteristic of a non-c-connection node. We next describe the changes necessary when considering the node w = w ˆ c . Once again, let Ql = (fl , Pl , Sl ) and Qr = (fr , Pr , Sr ) be characteristics of wl and wr —if existing—that are considered by our old algorithm during the computation of the cost for a characteristic Q = (f , P , S ) of w . We want to show how one can find out without making use of the forbidden colors whether good colorings Cl for Ql and Cr for Qr can be extended to a good coloring C ′ for Q such that the semiconvexity with respect to c is not destroyed. We distinguish between several cases. Let us first consider the case, where |B(w) ∩ {w1 , w2 , w3 }| ≥ 2, and the case, where |B(w) ∩ {w1 , w2 , w3 }| = 1 and no subtree of T rooted in a child of w contains more than one vertex of {w1 , w2 , w3 }. In both cases, w is the only c-connection node. Hence, by our modifications, for any coloring Cl of G(wl ), all vertices v in G(wl ) with Cl (v) = c are Cl -connected to at least one vertex of B(wl ). Roughly speaking Cl is semiconvex with respect to c. Since an analogous property holds for Cr , there is no need to explicitly store c as forbidden color to find out if Sl or Sr contains c. Let us consider the remaining case in which w = w ˆ c must have a child such that the subtree rooted in this child contains at least two of the nodes {w1 , w2 , w3 }. The subtree then contains exactly two of these nodes since otherwise w ˆ c is not chosen correctly. Say that the subtree Tl rooted in wl contains w1 and w2 , and hence not w3 . Note also that by our choice of w no bag below w can contain u3 . Assume first that c ∈ {fl (v) | v ∈ B(wl )}. By the upcoloring rule and by the fact that we only consider expanding colorings, for any good coloring for Ql , at least one of u1 or u2 is colored by c. Since there is only one c-connection node in Tl , namely w ′ = lca(w1 , w2 ), and since none of the vertices u1 and u2 appear in a bag of T above w1 and w2 , respectively, i.e., above w ′ , we can conclude that c was not changed to c ′ at w ′ . Hence our upcoloring rule guarantees that each vertex v with Cl (v) = c is Cl -connected to a vertex in B(wl ). Therefore, we know that c ̸∈ Sl . Recall that setting fl (v) = c for a vertex v in G(wl ) should mean that v is c-connected to a vertex ui for which wi is not contained in Tl . In our case v is then c-connected to u3 . Therefore, when extending Cl to a good coloring C ′ for Q, we also want u3 to be colored with c. This is the case if and only if u3 ∈ B(w) and f (u3 ) ∈ {c , x} for some pseudocolor x or if c ∈ {fr (v) | v ∈ B(wr )}. More precisely, this holds because of our upcoloring rule, the fact that neither u1 nor u2 is contained in a bag of Tr , and the fact that good colorings must be expanding colorings. Let us now assume that c ̸∈ {fl (v) | v ∈ B(wl )}. Then possibly a good coloring for Ql may color none of the vertices u1 and u2 . However, it is also possible that a good coloring for Ql colors u1 and u2 —we may have decided at w ′ = lca(w1 , w2 ) to change c to c ′ , i.e., we have to uncolor u3 . Given that c ̸∈ {fl (v) | v ∈ B(wl )},
830
F. Kammer, T. Tholey / Discrete Applied Mathematics 160 (2012) 810–833
we cannot distinguish between the cases of u1 and u2 both being uncolored or both being colored. Therefore, we generally do not allow u3 to be colored if c ̸∈ {fl (v) | v ∈ B(wl )}. More precisely, if this case is given, we break off the computation of costQ using characteristics Ql and Qr and try the next pair. Since we forbid to color u3 if c ̸∈ {fl (v) | v ∈ B(wl )}, there is again no need to store c as forbidden color. Since we forbid that u3 is colored even in the case in which u1 and u2 are uncolored, some convex recolorings are excluded from our computations, but none of the colorings with property (P5)c . For a node w of T not being contained in Tc , there is also no need to store c as a forbidden color since, beside the vertices in {u1 , u2 , u3 }, there are no further vertices initially colored with c in G(¬w). Finally, the case that only two instead of three vertices are initially colored with c can be handled similarly. One can choose a node w ′ as a node of largest depth such that G(w ′ ) contains both vertices of color c. Then w ′ can be handled in the same way than the c-connection node not equal to w ˆ c in the case of three initially colored vertices of color c. The nodes below w ′ are treated as the non-c-connection nodes in our previous description. Summing up, there is no need to store any forbidden color anymore. Therefore, from now on we consider a characteristic as the 2-tuple (f , P ) that we obtain from the old 3-tuple (f , P , S ) by removing the set S of forbidden colors. Recall that we have excluded several convex recolorings C ′ of (G, C ) that color exactly one vertex with color c. In contrast, we have not excluded any coloring that uncolors all vertices of color c even though such a coloring clearly cannot be an optimal solution. Note that if there is an optimal solution C ′ of the MRRP that colors exactly one vertex with color c, then it can be obtained from a coloring uncoloring all vertices of c by undoing the uncoloring of a vertex v initially colored with c that among all such vertices has a maximal weight. For each real color c, we denote this weight by MAX(c ), i.e., MAX(c ) = max{w(v) | v ∈ V , C (v) = c }. One key idea of this subsection is that, for all colorings that uncolor all vertices of color c, we want to store the costs of a recoloring that colors exactly one vertex with c, namely a vertex v with w(v) = MAX(c ) being initially colored with c. Then, even though we consider a wrong set of colorings, we do not consider a wrong set of costs. However, subtracting MAX(c ) from the costs of a coloring is not easy since, as in our old algorithm for the MRRP, we want to compute costs for characteristics instead of costs for each single coloring. In our old algorithm, for a characteristic Q of a node w , we defined costQ as the minimal recoloring costs of a good coloring C ′ for Q. Because our modifications exclude some colorings, we now redefine costQ to be the minimal recoloring costs among the recoloring costs of all colorings consistent to Q, i.e., of all good colorings for Q that were not excluded by our modifications. Let us now specify C more precisely as the set of all expanding convex colorings that are consistent to at least one characteristic for the root of T . Note that, for a real color c and a characteristic Q, there may be different colorings C1 , C2 ∈ C both extending colorings consistent to Q with only one of them coloring vertices with color c. This makes it difficult to subtract the value MAX(c) from the cost of Q. The good news is that we later can show that it is possible, for each color c, to designate one node w with the following property (F)c as a so-called c-decision node. We denote this node by wc .
(F)c For each characteristic Q, either all colorings in C that extend a coloring consistent to Q color no vertex with color c or all colorings in C that extend a coloring consistent to Q color at least one vertex with color c. This property implicitly also implies that, for each coloring C ′ consistent to a characteristic of wc or an ancestor of wc , either all colorings C ′′ ∈ C extending C ′ color at least one vertex with c or all colorings C ′′ ∈ C extending C ′ do not color any vertex with c. For a coloring C ′ consistent to characteristic of a node w of T , we define UPCOL(C ′ ) to be the real colors c ∈ C ′ (G(w)) for which w is an ancestor of wc or equal to wc and for which each coloring in C extending C ′ uncolors all vertices of color c. Whereas we use cost(C ′ ) to denote the (usual) recoloring costs for a coloring C ′ , as mentioned above, we also define modified costs for each coloring C ′ consistent to a characteristic Q of a node w as follows cost∗ (C ′ ) = cost(C ′ ) −
MAX(c )and
c ∈UPCOL(C ′ )
cost∗Q = min{cost∗ (C ′ ) | C ′ is consistent with Q}. Suppose that we can compute the correct value of cost∗Q for each characteristic Q of a node w in T . If w is the root of T , for each color c , w is wc or an ancestor of wc . Hence, for each recoloring C ′ of G consistent with a characteristic of the root w, cost∗ (C ′ ) is equal to the recoloring cost of the coloring C ′′ obtained from C ′ if, for each color c ∈ C (V ) \ C ′ (V ), we undo the recoloring of one vertex v with C (v) = c and w(v) = MAX(c ). Note that any recoloring C ′′ of (G, C ) that is an optimal solution for the MRRP can be obtained by such an operation from a good coloring C ′ for a characteristic Q of the root of T such that (P5)c holds with respect to C ′ for each real color c ∈ C (V ). Since we store with C ′ recoloring costs that are equal to that of C ′′ and since we have not excluded any convex expanding coloring with property (P5)c for all colors c, we can read off the costs of an optimal solution for the MRRP as the minimum of cost∗Q′ among all characteristics Q′ = (f , P ) for the root of T for which there are no two subsets U1 , U2 ∈ P with vertices u1 ∈ U1 , u2 ∈ U2 such that 0 ̸= f (u1 ) = f (u2 ). It remains to show how to find a c-decision node and how to compute cost∗Q for all characteristics. As a c-decision node we can choose the node w being the deepest c-connection node. Let Q = (f , P ) be a characteristic of w . If {c , c ′ } ∩ {f (v) | v ∈ B(w)} ̸= ∅, clearly each coloring C ′′ ∈ C extending a coloring consistent to Q colors at least one vertex with c. For showing that (F)c holds for w , it suffices to show that {c , c ′ } ∩ {f (v) | v ∈ B(w)} = ∅ implies that each coloring C ′′ ∈ C extending a coloring consistent to Q colors no vertex with c. Hence, let us assume that {c , c ′ } ∩ {f (v) | v ∈ B(w)} = ∅. We
F. Kammer, T. Tholey / Discrete Applied Mathematics 160 (2012) 810–833
831
first consider the case that there are two c-connection nodes. Then w is the deeper c-connection node, and the graph G(w) contains exactly two vertices u1 and u2 initially colored with c. We have already shown that in this case a coloring that is consistent to Q colors at least one of the vertices u1 and u2 with c if and only if {c , c ′ } ∩ {f (v) | v ∈ B(w)} ̸= ∅. Hence, in our case no coloring consistent to Q can color u1 and u2 . The same is true for any coloring in C extending such a coloring since in the MRRP, after uncoloring an initially colored vertex, we do not allow coloring the vertex again with a real color. In the case of u1 and u2 being uncolored by our modifications we did not allow any coloring extending a coloring consistent to Q to color u3 with c. Hence (F)c holds at w = wc in the case of two connection nodes. If there is only one c-connection node, w is equal to this node. In this case B(w) must contain at least one vertex of the three initially with c colored vertices in {u1 , u2 , u3 }, say u1 . By our assumption we must have f (u1 ) = 0. If there is a further vertex of {u2 , u3 } in B(w), then B(w) contains at least two initially with c colored vertices to which f assigns the value 0. In this case our modifications explicitly forbid to color u3 with 0 for any coloring in C extending a coloring consistent with Q. The only remaining case is that u2 is contained in exactly one of the graphs G(wl ) and G(wr ) and u3 is contained in the other of these two subgraphs. Say that u2 is in G(wl ). Then, for each coloring in C ′′ ∈ C extending a coloring C ′ consistent to Q, there is a characteristic Ql of wl and a coloring Cl consistent to Ql such that C ′′ as well as C ′ extends Cl . But then we can conclude from {c , c ′ } ∩ {f (v) | v ∈ B(w)} = ∅ that also {c , c ′ } ∩ {fl (v) | v ∈ B(wl )} = ∅. Then our upcoloring rule implies that Cl does not color u2 . This mean that also neither C ′ nor C ′′ colors u2 with c. Analogously, u3 is also not colored with c. In sum (F)c holds for the deepest c-connection node. We next show how cost∗Q can be computed recursively. For each characteristic Q of a node w , let UNCOLOR(Q) be the set of real colors for which w is a c-decision node and for which every coloring in C extending a coloring consistent with Q uncolors all vertices of color c. As shown above, if Q = (f , P ) and w is a c-decision node, then c ∈ UNCOLOR(Q) if and only if {c , c ′ } ∩ {f (v) | v ∈ B(w)} = ∅ so that UNCOLOR(Q) can be easily computed in a time linear in |UNCOLOR(Q)| + k. For each characteristic of a non-leaf, let CHILD(Q) be the pairs (Ql , Qr ) of characteristics—or the characteristics Ql in the case of only one child—that are considered for the computation of the costs of Q even after our modifications. Then by induction one can easily show that cost∗Q for a characteristic Q of a node w can be computed as follows (compare also the corresponding computations in Section 3.5).
• If w is a leaf: we simply use a brute-force algorithm that enumerates all colorings and their costs to determine the costQ′ for all characteristics Q′ . Afterwards we set
cost∗Q = costQ −
MAX(c ).
c ∈UNCOLOR(Q)
• If w has two children, set cost∗Q to min cost∗Ql + cost∗Qr − (Ql ,Qr )∈CHILD(Q)
w(v) −
• If w has a child with B(w) ⊃ B(wl ), ∗
costQ =
min
Ql ∈CHILD(Q)
MAX(c )
c ∈UNCOLOR(Q)
v∈B(w) 0̸=C (v)̸=f (v)
.
costQl + g (Q, Ql , u) − ∗
MAX(c ) ,
c ∈UNCOLOR(Q)
where g (Q, Ql , u) = 0 if the condition of line (11) of Algorithm 2 in Section 3.5 is true, and otherwise g (Q, Ql , u) = w(u). • If w has a child with B(w) ⊂ B(wl ), ∗ ∗ costQ = min costQl − MAX(c ) . Ql ∈CHILD(Q)
c ∈UNCOLOR(Q)
Note once again that in general, for a characteristic of a node w not equal to the c-decision node, there may be colorings C1 , C2 ∈ C extending colorings consistent to Q with only one of C1 and C2 assigning the color c to vertices. That this is not the case for the c-decision node allows us to define the set UNCOLOR(Q), which is essential for our algorithm. Concerning the running time of the MRRP, after the removal of the forbidden colors from the characteristics, we need not encounter all possible sets of forbidden colors. This, for s = maxwnode ofT |SEP(C , w)|, removes the factor 4s in the running time of Theorem 3.6. Hence, we have shown the following theorem. Theorem 3.8. The MRRP restricted to initial (∞, 3)-colorings is solvable in polynomial time on graphs for which a tree decomposition (T , B) of bounded width is known. 3.8. (a, b)-colorings with a = O(log n) Note that the running times for the MCRP and the MRRP on arbitrary initial colorings are polynomial if s, defined as in Theorem 3.5, is of size O(log n). This is the case if an (a, b)-coloring with a = O(log n) is given. Theorem 3.9. On graphs for which a tree decomposition (T , B) of bounded width is known, the MCRP and the MRRP are solvable in polynomial time if the initial coloring is an (a, b)-coloring with a = O(log n).
832
F. Kammer, T. Tholey / Discrete Applied Mathematics 160 (2012) 810–833
4. Simple set-cover instances Since there is little hope to find efficient algorithms that solve or approximate the set-cover problem [1,9], we must constrain the set-cover instances. Recall our reduction in the proof of Lemma 2.1, where for each set-cover instance (S , F ) an unweighted colored graph (G, C ) is constructed. We have shown that solving the MBRP on (G, C ) also solves the set-cover instance (S , F ). Using Lemma 3.7 we can solve the MBRP on graphs of bounded treewidth in polynomial time. Defining U and F as in + Section 2, one can observe that G has bounded treewidth if there exists a collection F with F ∈F + F ⊆ U such that for each F ′ ⊆ F ∪ F + we can find a subset X ∈ F ∪ F + of bounded size such that either F ∈F ′ F ⊆ X or there exist nonempty ′ collections F1 , F2 with F1 ∪ F2 = F and F ∈F1 F ∩ F ∈F2 F ⊆ X . Thus, set-cover instances with this property are solvable in polynomial time. 5. Approximation algorithms Since the MCRP is NP-hard even on trees, we cannot hope that a polynomial-time algorithm solves the problem to optimality—even if we consider graphs of bounded treewidth. Using the algorithms Section 3.5 we now present (2 + ϵ)approximation algorithms for the MCRP and the MRRP for graphs of bounded treewidth with arbitrary (∞, ∞)-colorings. The following algorithm is inspired by the algorithm of Bar-Yehuda et al. [3]. We extend the algorithm from trees to graphs of bounded treewidth and present a slightly different description for proving the correctness of the algorithm. Given a graph G with a coloring C and a nice tree decomposition (T , B) of width k − 1 for G, our results can be obtained by iteratively modifying the coloring C and the weights of the vertices such that finally |SEP(C , w)| < s for all nodes w of T and a fixed s ∈ N with s > k. Let w be a node of T such that there is a set R′ ⊆ SEP(C , w) containing exactly s colors and let V ′ be a set consisting of a vertex u ∈ UP(C , w) colored with c and a vertex v ∈ LOW(C , w) colored with c for all c ∈ R′ such that, for each pair of vertices u, v ∈ V ′ of the same color, the vertices u and v are in different connected components in G − B(w). Moreover, let α be the minimal weight of a vertex in V ′ . The number of vertices in SEP(C , w) is decremented by reducing the weight of all vertices in V ′ by α and subsequently uncoloring the vertices of zero-weight. On the one hand, this weight reduction decreases the cost of an optimal convex (re-)coloring C ′ of G by at least (s − k)α since the vertices in B(w) allow to connect at most k of the s colors in R′ , i.e., at least s − k vertices in V ′ must be uncolored. On the other hand, if we have a solution for the MCRP (or the MRRP) with the reduced weight function, we can simply take this solution as a solution for the MCRP (or the MRRP) with the original weights and our cost increases by at most 2sα . Thus, in each iteration our cost decreases by at most a factor of 2s/(s − k) more than the decrease of the cost of an optimal solution. If at the end no further weight reduction is possible, we can use the exact algorithms from the previous section, i.e., we can solve the instance obtained by this weight reduction as good as an optimal algorithm. Altogether, we have only a recoloring cost that is a factor of 2s/(s − k) = 2 + 2k/(s − k) larger than the cost of an optimal solution. Choosing s = 2k/ϵ + k, we obtain the following. Corollary 5.1. On graphs with n vertices for which a tree decomposition (T , B) of width k is known, a (2 + ϵ)-approximation algorithm exists for the MCRP and the MRRP with a running time O(n2 + n(2O(k/ϵ) (k/ϵ)O(k) f (k))) for some fixed function f . Acknowledgments We thank the anonymous referees for their valuable comments and their constructive suggestions that helped to improve many parts of the paper. References [1] N. Alon, D. Moshkovitz, S. Safra, Algorithmic construction of sets for k-restrictions, ACM Trans. Algorithms 2 (2006) 153–177. [2] M. Andrews, L. Zhang, Hardness of the undirected edge-disjoint paths problem, in: Proc. 37th Annual ACM Symposium on Theory of Computing, STOC 2005, pp. 276–283. [3] R. Bar-Yehuda, I. Feldman, D. Rawitz, Improved approximation algorithm for convex recoloring of trees, in: Workshop on Approximation and Online Algorithms, WAOA’05, in: LNCS, vol. 3879, Springer, Berlin, 2006, pp. 55–68. [4] H.L. Bodlaender, A linear-time algorithm for finding tree-decompositions of small treewidth, SIAM J. Comput. 25 (1996) 1305–1317. [5] H.L. Bodlaender, A partial k-arboretum of graphs with bounded treewidth, Theoret. Comput. Sci. 209 (1998) 1–45. [6] H.L. Bodlaender, T. Kloks, Efficient and constructive algorithms for the pathwidth and treewidth of graphs, J. Algorithms 21 (1996) 358–402. [7] X. Chen, X. Hu, T. Shuai, Inapproximability and approximability of maximal tree routing and coloring, J. Comb. Optim. 11 (2006) 219–229. [8] B. Chor, M. Fellows, M.A. Ragan, I. Razgon, F. Rosamond, S. Snir, Connected coloring completion for general graphs: algorithms and complexity, in: Proc. 13th Annual International Computing and Combinatorics Conference, COCOON’07, in: LNCS, vol. 4598, Springer, Berlin, 2007, pp. 75–85. [9] U. Feige, A threshold of ln n for approximating set cover, J. ACM 45 (1998) 634–652. [10] F. Kammer, T. Tholey, The complexity of minimum convex coloring, in: Proc. 19th Annual International Symposium on Algorithms and Computation, ISAAC 2008, in: Lecture Notes in Computer Science Series, vol. 5369, Springer, Berlin, 2008, pp. 16–27. [11] I.A. Kanj, D. Kratsch, Convex recoloring revisited: complexity and exact algorithms, in: Proc. 15th Annual International Computing and Combinatorics Conference, COCOON’09, in: LNCS, vol. 5609, Springer, Berlin, 2009, pp. 388–397. [12] R.M. Karp, On the computational complexity of combinatorial problems, Networks 5 (1975) 45–68. [13] J.F. Lynch, The equivalence of theorem proving and the interconnection problem, (ACM) SIGDA Newsl. 5 (1975) 31–36. [14] S. Moran, S. Snir, Efficient approximation of convex recoloring, J. Comput. System Sci. 73 (2007) 1078–1089.
F. Kammer, T. Tholey / Discrete Applied Mathematics 160 (2012) 810–833
833
[15] S. Moran, S. Snir, Convex recolorings of strings and trees: definitions, hardness results and algorithms, J. Comput. System Sci. 74 (2008) 850–869. [16] S. Moran, S. Snir, W.-K. Sung, Partial convex recolorings of trees and galled networks: tight upper and lower bounds, ACM Trans. Algorithms 7 (2011), Article No. 42. [17] O. Ponta, F. Hüffner, R. Niedermeier, Speeding up dynamic programming for some NP-hard graph recoloring problems, in: TAMC 2008, pp. 490–501. [18] N. Robertson, P.D. Seymour, Graph minors. I. Excluding a forest, J. Combin. Theory Ser. B 35 (1983) 39–61. [19] N. Robertson, P.D. Seymour, Graph minors. XIII. The disjoint paths problem, J. Combin. Theory Ser. B 63 (1995) 39–61.