1 Introduction
A proper coloring of a given graph is an assignment of colors (integers) to its vertices, such that any two vertices linked by an edge of take different colors. For any given color, the set of vertices taking this color is called a color class. In [2], a coloring problem with non global constraints on the sizes of the color classes was studied. More precisely, the following problem was considered:
LocallyBoundedColoring
Instance: A graph , a partition of the vertex set , and a list of integral bounds such that for each .
Question: Decide whether there exists a proper coloring of (i.e., a proper coloring of using colors) that is such that, for each and for each , the number of vertices having color in is .
In this previous paper, it was shown that this problem can be solved in time when is a tree, where . A link with a scheduling problem consisting in processing a set of unit tasks on a set of processors with various unavailability constraints was also presented.
Moreover, it was shown in [10] that the following listcoloring problem (i.e., where each vertex must take a color from a list of possible colors) with global constraints on the size of the color classes is tractable in several classes of graphs:
BoundedListColoring
Instance: A graph , a list of integral bounds , and, for each vertex of , a list of possible colors .
Question: Decide whether there exists a proper coloring of such that, for each , the number of vertices having color is at most equal to the color bound , and the color of belongs to for each vertex .
More precisely, the authors of [10] described efficient algorithms to solve this problem in graphs of bounded treewidth and in cographs (that can be defined as graphs with no induced path on four vertices [6]). The notion of treewidth will be recalled formally when needed: it can be viewed as a measure of the treelikeness of a graph, and equals 1 in forests (and 0 in graphs with no edges). Graphs of treewidth at most for some are also called partial trees [6].
In this paper, we generalize both results, and show how to solve efficiently the listcoloring problem with non global and weighted constraints on the sizes of the color classes in graphs of bounded treewidth (and also in cographs). More precisely, the problem we shall study can be formally defined as follows:
WeightedLocallyBoundedListColoring
Instance: A graph , a weight function , a partition of the vertex set , a list of integral bounds with for each , and, for each vertex of , a list of possible colors .
Question: Decide whether there exists a proper coloring of such that, for each and for each , the total weight of vertices having color in is , and the color of belongs to for each vertex .
In the scheduling application mentioned above, the weight of each vertex would correspond to the amount of resource needed to process the associated task. Moreover, apart from listcoloring problems, other constrained coloring problems related to ours have been studied in the literature, see for instance [1, 3, 4, 5, 7, 8, 11, 14]. We will not review all the associated known results, as we will not need them all, and will only recall the useful ones when needed.
The equitable coloring problem consists in finding a coloring where the sizes of any two color classes differ by at most one, while the bounded coloring problem consists in finding a coloring where the size of any color class does not exceed a given bound (that is common to all color classes). Moreover, without the requirement of being a listcoloring, the problem studied in [10] is defined as the capacitated coloring problem in [5]. Hence, the bounded coloring problem is a special case of the capacitated coloring problem, where all the color bounds (i.e., all the bounds on the sizes of the color classes) are equal.
It was observed in [5] that the equitable coloring problem is in fact a special case of the capacitated coloring problem (and one in which the color bounds are actually reached), by setting for any , and for any other , where is the number of vertices. It was also observed in [3] that any instance of the bounded coloring problem is equivalent to an instance of the equitable coloring problem with the same number of colors, by adding sufficiently many isolated vertices (which destroys neither the property of having bounded treewidth nor the one of being a cograph or a split graph, i.e., a graph whose vertex set can be partitioned into a clique and an independent set [6]).
In fact, all of the above problems (including the coloring problem, which is a listcoloring problem where for each vertex ) are special cases of BoundedListColoring, and this is true for WeightedLocallyBoundedListColoring as well, in most of the graphs that we shall consider: take any instance of BoundedListColoring, keep the same color bounds, set and the weight of any vertex to 1, and add isolated vertices of weight 1 (that can take any color), so that the total number of vertices reaches .
Numerous applications of the listcoloring problem and of the capacitated coloring problem were described respectively in [14] and in [4, 5]. Many papers also consider a precolored variant of the equitable or capacitated coloring problem, where some of the vertices are already colored [3]. Observe that this can also be achieved, when considering an instance of the listcoloring problem, by defining the list of possible colors for each vertex that is already colored as a singleton, corresponding to the given color. Similarly, one can transform a listcoloring instance into a precolored one, by adding pendant vertices adjacent to each vertex (these pendant vertices being colored by the colors not in ). Such an operation does not destroy the property of having bounded treewidth, but can destroy the one of being a cograph (or a split graph, depending on whether lies in the clique or in the independent set). Finally, when considering instances of WeightedLocallyBoundedListColoring where is not fixed and for each vertex , then precoloring some vertices can be achieved by putting each of these vertices in one set of the partition ( contains only this vertex), and defining the ’s appropriately.
The present paper is organized as follows. We begin by providing, in Section 2, tight hardness results for WeightedLocallyBoundedListColoring. Then, we describe in Section 3 a dynamic programming algorithm for this problem, that runs in polynomial time whenever we are not in the cases covered by Section 2 (i.e., when , and the treewidth of the graph are fixed, and the vertex weights are polynomially bounded). In Section 4, we prove that the problem is tractable in cographs under similar assumptions, and that, under weaker assumptions, it can be solved in polynomial time in several subclasses of cographs. Section 5 is devoted to split graphs, and we show that, in such graphs, the problem can be solved in (pseudo)polynomial time even when is not fixed (provided that is), and provide additional tractable special cases. Finally, in the last section of the paper, we extend to edge colorings all our results concerning (vertex) colorings in the graphs studied in Sections 3 to 5.
2 Npcompleteness proofs
In this section, we prove that WeightedLocallyBoundedListColoring, which is clearly in NP, is NPcomplete, even in very restricted special cases.
Before detailing these special cases, we note that, when , WeightedLocallyBoundedListColoring is NPcomplete in general graphs (i.e., when the treewidth is unbounded), even when and for each vertex , as deciding whether a graph can be colored using three colors is. Also note that this latter result does not hold when : in this case, the coloring problem is trivial, as the input graph is bipartite (otherwise, the answer is no).
Actually, WeightedLocallyBoundedListColoring itself can be solved in polynomial time when and , provided that the vertex weights are polynomially bounded (in the next subsection, we deal with the case where they are not). Indeed, if , then any connected component of the graph is bipartite (otherwise, the answer is no), and hence admits two possible colorings. For each one, one can check whether such a coloring is a valid listcoloring in the associated connected component. This implies that the whole problem can be solved by a dynamic programming algorithm similar to the one given in [10, Theorem 2]: we consider the connected components one after the other, keeping track for each one of them of all the possible weights of vertices of color in the set , for each and , and then combining these weights whenever a new component is considered. The total amount of information that we need to keep track of is thus , which is polynomial under our assumptions.
2.1 When vertex weights are arbitrary
We first give a short proof that WeightedLocallyBoundedListColoring is NPcomplete in general, even when (there are two colors) and (the vertex partition contains only one set). To do this, we consider the following wellknown weakly NPcomplete problem [9]:
Partition
Instance: positive integers such that .
Question: Decide whether there exists such that .
Given an instance of Partition, we define the following instance of WeightedLocallyBoundedListColoring: the graph consists of isolated vertices . We define , and . We also define, for each , (i.e., any vertex can take any color) and . Then, has a solution if and only if admits a solution, i.e., a 2coloring where the total weight of the vertices of each color is : a vertex will take color 1 if and only if . This implies:
Theorem 1.
WeightedLocallyBoundedListColoring is NPcomplete in the weak sense in graphs consisting of isolated vertices, even if , , and each vertex can take any color.
Note that this instance can be made connected by setting and adding, for each , two edges and , where the ’s are new vertices of color 3 (e.g., for each ). The graph we obtain is then a tree (in fact, a chain), and so has treewidth 1.
Also note that, if and is connected, then solving WeightedLocallyBoundedListColoring is a trivial task, since a connected bipartite graph has only two proper (vertex) colorings using two colors.
In [3], Bodlaender and Fomin managed to show that the equitable coloring problem can be solved in polynomial time in graphs of bounded treewidth (i.e., even if the number of colors is not fixed). In the next subsections, we rule out this possibility by proving that, even if all vertex weights are polynomially bounded, WeightedLocallyBoundedListColoring remains NPcomplete in graphs of bounded treewidth, if either or is not fixed.
2.2 When the number of colors is not fixed
First, we look at the case where the number of colors is not fixed. We consider the following wellknown strongly NPcomplete problem [9]:
Partition
Instance: A set of positive integers , and an integer such that and, for each , .
Question: Decide whether can be partitioned into disjoint sets of three elements such that, for each , .
Since this problem is strongly NPcomplete, we can assume w.l.o.g. that the ’s are polynomially bounded in . We construct an instance of WeightedLocallyBoundedListColoring in a graph consisting of isolated vertices , by defining , , for each , and, for each , and . It is easy to see that the equivalence between the solutions of the two instances is given by: for each , a vertex will take color in if and only if . Hence:
Theorem 2.
WeightedLocallyBoundedListColoring is NPcomplete in the strong sense in graphs consisting of isolated vertices, even if , all the vertex weights are polynomially bounded, and each vertex can take any color.
As in the case of Theorem 1, we can make this instance connected (for instance, obtaining a chain, or a star) by defining and adding new vertices (and associated edges) that can only take color . Note, however, that in this reduction we need non uniform vertex weights. Actually, this is unavoidable, from the following fact: the problem becomes tractable in graphs with no edges (and hence also in stars, by a simple reduction) when for each . For the sake of completeness, we give a proof of this fact.
Proposition 1.
If all vertex weights are 1, WeightedLocallyBoundedListColoring is polynomialtime solvable in graphs consisting of isolated vertices.
Proof.
Given an instance in such a graph , we can construct a bipartite graph as follows: there is a vertex in for each vertex in , and, for each and , there are vertices in . There is an edge between and in if and only if and : since for each , this implies that the number of vertices is the same in each side of the bipartition of .
Then, there exists a feasible coloring for the initial WeightedLocallyBoundedListColoring instance in if and only if admits a perfect matching. ( being bipartite, such a perfect matching can be computed as a maximum flow.) Indeed, we define the following equivalence: vertex has color if and only if the edge belongs to this perfect matching, for some .
On the one hand, each vertex will be incident to one edge of the matching, and hence will take one color (by construction, this is a color in ); on the other hand, each vertex will be incident to one edge of the matching, and hence in each there will be exactly vertices with color . ∎
We can nevertheless prove the strong NPcompleteness of WeightedLocallyBoundedListColoring in graphs of bounded treewidth when for each , and is arbitrary, by using a more complex reduction from Partition. Actually, such a reduction was already given in [3, Theorem 8] for the precolored variant of the equitable coloring problem. In this reduction, each instance is a set of trees of height 3 (together with additional isolated vertices). The leaves are in fact precolored vertices, which are used to restrain the set of possible colors for other vertices. Hence, if we consider listcolorings, we can ignore (i.e., remove) these leaves, and simply define suitable lists of possible colors for the other vertices. This yields instances consisting of trees of height at most 2, and leaves as open the case where each connected component is a tree of height at most 1 (which, unlike trees of height 2, are also cographs).
We now describe an alternative reduction, that needs more colors but only makes use of stars (i.e., trees of height 1), and that will prove useful in Sections 3 to 5. Assume we are given an instance of Partition with . We construct an instance of WeightedLocallyBoundedListColoring as follows: we define , , for each vertex , and the graph, that contains vertices, consists of vertexdisjoint stars and isolated vertices . We denote each star by , for each and each , and its central vertex by . For each and each , can take any of the colors in , and has leaves, which can only take colors and . Moreover, for each , vertex can take any of the colors in . We also define for each , for each , and for each and each .
Then, the following holds:
Lemma 1.
has a solution if and only if has a solution.
Proof.
We shall prove that the following equivalence holds: if and only if takes color , for each and each .
Assume that we are given a solution to the Partition instance . For each , if for some , then takes color , and the leaves in take color , while, for each , takes color , and all the leaves in take color . Moreover, for each , takes color . This implies, in , that there are vertices of color for each , and there are (assuming ) vertices of color for each .
Conversely, assume that we are given a solution to the WeightedLocallyBoundedListColoring instance , and let if takes color for each and each . Observe that, for each , exactly one of the ’s takes color (from the fact that for each , and from the possible colors that can be taken by and the ’s). This means that the leaves of such a must take color . For each , the leaves of all the other ’s must take color , since . Hence, for each , there are exactly three ’s in such that has color : if there are at most two such , then for each implies that at most vertices have color , a contradiction; if there are at least four such vertices, then for each implies that at least vertices have color , a contradiction. The sum of these three ’s is then , which concludes the proof. ∎
Hence, we have proved:
Theorem 3.
WeightedLocallyBoundedListColoring is NPcomplete in the strong sense in star forests, even if and for each .
Corollary 1.
WeightedLocallyBoundedListColoring is strongly NPcomplete in cographs of treewidth 1, even if and .
Again, we can make the instance connected by adding a new color, as well as one or more vertices that can only take this new color. After doing this, we can obtain a tree of height 2 (or a caterpillar), while recall that, from a direct consequence of Proposition 1, WeightedLocallyBoundedListColoring is tractable in stars (i.e., in trees of height 1) when for each .
Moreover, one of the features of the above reduction is that all the ’s and ’s must take different colors, which will be useful in Section 5. However, one can use a simpler reduction, in which for each vertex . Too see this, remove all the ’s, and set and for each vertex in each . The color bounds are then for each and for each . As in the proof of Theorem 3, and for similar reasons, we have if and only if takes color for each and each .
Note that the above reductions leave as open the case of chains (which are not cographs, except when they are also stars) where the vertex weights are 1, is fixed and is not. The reduction given in [7, Theorem 3] closes this gap, and shows that the problem is strongly NPcomplete in this case, even when and for each . However, this reduction is rather complicated, in particular since all the chains do not play the same role. We now give a different kind of reduction to prove this result, in which we have and for each , as well as an additional restriction on the lists of possible colors:
Theorem 4.
WeightedLocallyBoundedListColoring is NPcomplete in the strong sense in linear forests, even if , and for each , and all the vertices of each chain share one common possible color.
Proof.
Given a Partition instance, instead of defining stars as in Theorem 3, we define disjoint chains , for each and each . We also define , , and for each . For each and each , has vertices, and () the first and the last vertices in can only take colors and , (
) the vertices with an odd index different from 1 in
can only take colors and , () the vertices with an even index different from in can only take colors and . Hence, for each vertex in , we have . To end the reduction, we define and for each , for each and each , and for each .Note that, for each and each , any feasible coloring has exactly one vertex (either the first one or the last one) in of color , while there can be at most vertices of color in this chain. Since each is equal to , this implies that in any feasible coloring there are exactly vertices of color in , for each and each : the vertices of color in are either all the vertices with an odd index, or all the vertices with an even index. Hence, in each chain, the remaining vertices either all have color , or all have color . Moreover, since each is equal to , this implies that in any feasible coloring there are exactly integers in such that there are vertices of color in , for each .
We can thus define the following equivalence between the two instances: for each and each , if and only if there are vertices of color in (for each , there will be exactly three such ’s, for reasons similar to the ones mentioned in the proof of Theorem 3), which concludes the proof. ∎
We conclude by pointing out that we can turn the previous instance into a chain by adding a new color and new vertices that can only take this new color.
2.3 When is not fixed
Now, we prove the NPcompleteness of the case where is fixed but is not, by considering the following wellknown strongly NPcomplete problem [9]:
MonotoneOneInThreeSAT
Instance: A set of boolean variables , and a set of clauses, each one containing exactly three (non negated) boolean variables from .
Question: Decide whether there exists a truth assignment for the variables in such that in every clause there is exactly one variable equal to true.
Theorem 5.
WeightedLocallyBoundedListColoring is NPcomplete in the strong sense in star forests, even if , and each vertex has weight 1 and can take any color.
Proof.
Given an instance of MonotoneOneInThreeSAT, we construct an instance of WeightedLocallyBoundedListColoring as follows: the graph consists of vertexdisjoint stars, one star per variable . We denote by the central vertex of the th star, and by its leaves, where is the number of occurrences of in the set of clauses. Then, we define , , and, for each vertex , and . The partition of the vertices of and their target weights are given by: and for each , and , and for each , where we consider that the th clause consists of the th occurrence of the variable , of the th occurrence of the variable , and of the th occurrence of the variable .
It is easy to check that we have the following equivalence between the initial MonotoneOneInThreeSAT instance and this WeightedLocallyBoundedListColoring instance: for each , variable is equal to true if and only if has color , which concludes the proof. ∎
Corollary 2.
WeightedLocallyBoundedListColoring is strongly NPcomplete in cographs of treewidth 1, even if , and each vertex has weight 1 and can take any color.
As in the case of Theorem 3, we can make the previous instance connected (obtaining a tree of height 2, or a caterpillar) by defining and adding new vertices (and associated edges, to link the stars together) that can only take color 3 (for instance, we can define and , and include all these new vertices of weight 1 in the new , keeping the other ’s unchanged).
Again, this reduction, that will prove useful both in Sections 3 and 4 (thanks to Corollary 2), leaves as open the case of chains where for each , is fixed and is not. The next theorem closes this gap.
Theorem 6.
WeightedLocallyBoundedListColoring is NPcomplete in the strong sense in linear forests, even if , and each vertex has weight 1 and can take any color.
Proof.
Given a MonotoneOneInThreeSAT instance, we define a WeightedLocallyBoundedListColoring instance as follows: the graph consists of vertexdisjoint chains (one per variable ) and of isolated vertices. The vertices of the th chain are (in this order), where is defined as in the proof of Theorem 5. For each chain, we also add isolated vertices . Then, we define , , and, for each vertex , and . It remains to define the partition of the vertices of and their target weights. We have , and for each , where we consider that the th clause consists of the th occurrence of the variable , of the th occurrence of the variable , and of the th occurrence of the variable . For each and each , we define and , where .
As in the case of Theorem 4, we can make the previous instance connected (obtaining a chain) by defining and adding new vertices (and associated edges) that can only take color 3. Also note that, in the reductions used to prove Theorems 5 and 6, we only need colorings (not listcolorings), although we did need to make use of listcolorings in the proofs of Theorems 3 and 4.
3 An algorithm for graphs of bounded treewidth
This section deals with WeightedLocallyBoundedListColoring in partial trees. Given a graph , a tree decomposition of is a pair where , is a bag of vertices of , is a tree, and:

,

For every edge , there is an such that ,

For all , if lies in the path between and , then .
The width of a given tree decomposition of a graph is equal to . The treewidth of a graph , denoted by , is the minimum width of a tree decomposition of , taken over all tree decompositions of . Note that trees (and hence chains and stars) have treewidth 1. Without loss of generality, we can also assume that the tree decomposition is nice [15], i.e.:

is rooted at some node ,

is binary and has nodes,

If a node has two children and then (join node)

If a node has one child , then either

and (forget node)

and (introduce node)

Given two vertices of , we will use the notation to denote the fact that is either or a descendant of with respect to . Given a node , let , i.e., is the subset of induced by the vertices in . Moreover, let and let be the subgraph of induced by .
In order to design a standard dynamic programming algorithm that solves WeightedLocallyBoundedListColoring, we use the following function :

= true if there exists a listcoloring of where each vertex has color and where the total weight of vertices of having color in is , and false otherwise.
To describe our algorithm, we now simply need to write down the induction equations defining the values of , for each type of nodes of . Then, these values will be computed in a bottomup fashion, starting from the leaves of .
Note that, by the definition of tree decompositions, any two vertices linked by an edge in must both belong to at least one common bag of the tree decomposition (Condition (2)). This implies that a (list)coloring that is proper in each bag is also proper in the whole graph , provided that each vertex has the same color in each bag it belongs to. Moreover, Condition (3) ensures that the subgraph of induced by the bags any given vertex belongs to is connected, and hence in all these bags this vertex will have the same color if we do not change its color whenever we move (in ) from one bag to an adjacent one.
If is a forget node.
Let denote its child such that :
If is an introduce node.
Let denote its child such that , and assume that :
where .
If is a join node.
Let and denote its two children, and let be the total weight of vertices such that , for each and .
where .
If is a leaf node.
In this case, we just have to check that the coloring function provides a valid locally bounded listcoloring of .
where .
Root value.
The answer true or false for the initial instance is obtained at the root by computing the following value:
Lemma 2.
The values of computed by the above algorithm are correct.
Proof.
In order to show that a vertex listcoloring is proper in , first notice that, from our preliminary remark, it suffices to show that () it is a proper listcoloring in and () the color of any vertex remains the same when moving from one bag of to an adjacent one. We now show the correctness of the above equations by considering each possible node type for .
Assume is a forget node. Then, since , is true if and only if is true for some coloring , such that for each (each vertex must keep its color when moving from to ) and vertex takes some color in .
Assume is an introduce node. Then, is true if and only if is true ( has weight and color , so the total weight of vertices of color in is in ), each vertex keeps its color when moving from to , and the color of defines a valid listcoloring in the subgraph of induced by (i.e., and for each such that ).
Assume is a join node. Then, is true if and only if both and are true for some and such that for each and (with obviously and for each and ), since the weights of the vertices in are counted twice, i.e., both in and in (and any other vertex weight in is counted only once).
Assume is a leaf node. Then, is true if and only if the coloring function provides a valid locally bounded listcoloring of .
Finally, the root value is obtained by requiring that is a listcoloring in the subgraph of induced by , which concludes the proof. ∎
Running time.
Let (with ). The running time for a given node of , that depends on its type, is given by:
node type  running time 

forget  
introduce  
join  
leaf 
There are nodes in , possible colorings of any given bag, and possible tuples , so when running the algorithm we have values to compute. Since computing the optimal value only takes time, the overall running time is . Together with Lemma 2, this implies:
Theorem 7.
In graphs of bounded treewidth, WeightedLocallyBoundedListColoring can be solved:

in pseudopolynomial time when and are fixed,

in polynomial time when (i) and are fixed, and (ii) all vertex weights are polynomially bounded.
Observe that these results are best possible, in the sense that, from Theorems 1 to 6, dropping any of the assumptions (on , , and the vertex weights) leads to NPcompleteness. They also generalize the results in [2, 10, 14].
We close this section by mentioning that this approach can be adapted to solve an optimization version of WeightedLocallyBoundedListColoring.
More precisely, one can associate a profit function to the vertices of ; the profit of a vertex then depends on its color. By slightly modifying the above dynamic programming algorithm, one can compute a valid weighted and locally bounded listcoloring of maximum (or minimum) profit (if any). In this case, the value of is no longer equal to true or false, i.e.:

= the maximum total profit of a listcoloring of where each vertex has color and where the total weight of vertices of having color in is (if any).
In order to compute the value of this “new” function , we must make some changes in the equations. We provide them without proofs, as the arguments are quite similar to the ones used in the proof of Lemma 2 (note that, by convention, infeasible solutions will have a value of , as we maximize ):

(in forget nodes and root value) “” becomes “”.

(in introduce nodes) is equal to if is false, and to otherwise.

(in join nodes) “” becomes “”, “” becomes “”, and we add the value “” at the end of the line.

(in leaf nodes) is equal to if both and the condition “” are true, and to otherwise.
4 Locally bounded listcolorings in cographs
In this section, we study the tractability of WeightedLocallyBoundedListColoring in cographs. Cographs, as defined in Section 1, can be characterized in several ways. For instance, a graph is a cograph if and only if it can be associated with a cotree : the leaves of are the vertices of , and the internal nodes of are either union nodes or join nodes. A subtree of having a union node as a root corresponds to the disjoint union of the subgraphs of associated with the children of this node, and a subtree of having a join node as a root corresponds to the complete union of the subgraphs of associated with the children of this node (i.e., we add an edge between every pair of vertices with one vertex in each subgraph). Moreover, this cotree can easily be transformed in linear time into a binary cotree with nodes [6].
First note that WeightedLocallyBoundedListColoring is still NPcomplete in cographs, even when is arbitrary, , and each vertex has weight 1. Indeed, on the one hand, it was proved in [14] that the listcoloring problem is NPcomplete in complete bipartite graphs (which are cographs), when is not fixed. On the other hand, the bounded coloring problem was proved to be NPcomplete in cographs in [4], by a reduction from bin packing (which, by [13], also shows its W[1]hardness with respect to in cographs).
However, the instances used in [4, 14] have a large treewidth (as otherwise the listcoloring and bounded coloring problems are tractable [3, 14]): since star forests and isolated vertices are cographs, Corollary 1 shows that this remains true even when the treewidth is 1 (the case of treewidth 0 and polynomially bounded vertex weights being covered by Theorem 2). Corollary 2 shows that, under the same assumption of being a cograph of treewidth 1 (the case of treewidth 0 will be discussed later in this section), this is also true as soon as (provided that is arbitrary), even when each vertex has weight 1 and can take any color. Finally, as in the case of partial trees, Theorem 1 shows that allowing arbitrary vertex weights leads to weak NPcompleteness in cographs of treewidth 0, even if , , and any vertex can take any color.
Moreover, the instances from the previous reductions can be made connected by adding a new vertex, adjacent to all the other vertices, that must take a new color (this increases the treewidth by 1). In particular, when the graph in the reduction consisted of isolated vertices, it then becomes a star.
However, when both and are fixed, we can design an efficient dynamic programming algorithm, based on standard techniques, to solve WeightedLocallyBoundedListColoring in cographs, by using the associated (binary) cotrees. In order to describe this algorithm, we define the following function:

= true if there exists a listcoloring of the subgraph of induced by the leaves of the subgraph of rooted at node , where the total weight of vertices of this induced subgraph of having color in is , and false otherwise.
The value of each is then computed in a bottomup fashion, as follows.
If is a join node.
Let and denote its two children.