Graph coloring is arguably one of the best-studied problems in algorithmic graph theory. It is well-known that -Coloring is polynomial-time solvable for and NP-hard for every . Furthermore, assuming the Exponential-Time Hypothesis (ETH) [25, 26], the hard cases do not even admit algorithms working in subexponential time.
Coloring -free graphs.
A very natural direction of research is to investigate what restrictions put on the family of input make the problem more tractable than for general graphs. In recent years, a very active topic has been to study the complexity of -Coloring and related problems in graphs defined by one or more forbidden induced subgraphs. For a family of graphs, we say that a graph is -free if does not contain any graph from as an induced subgraph. If consists of a single graph , then we say -free instead of -free. Note that the class of -free graphs is hereditary i.e., closed under vertex deletion. On the other hand, every hereditary class of graphs can be equivalently defined as -free graphs for some unique minimal (possibly infinite) family of graphs.
It is well-known that for every , the -Coloring problem is NP-hard in -free graphs, unless is a linear forest, i.e., every connected component of is a path. Indeed, for every constant , -Coloring is NP-hard in graphs of girth (i.e., the length of a shortest cycle) at least . Setting , we immediately obtain hardness for every that is not a forest. On the other hand, -Coloring is NP-hard in line graphs which are claw-free [23, 29]. The only forests that are claw-free are linear forests.
The complexity of -Coloring in -free graphs, where is the path in vertices, has recently attracted a lot of attention. For , the problem is polynomial-time solvable for every constant . If , then the problem is NP-hard already in -free graphs . The case is also fully understood: it is polynomial-time solvable for  and NP-hard for . The case of is much more elusive. We know a polynomial-time algorithm for -free graphs . However, for , we know neither polynomial-time algorithm nor any hardness result. Some positive results are also known for the case that is a disconnected linear forest [28, 6, 18].
Let us point out almost all mentioned algorithmic results also hold for the more general list variant of the problem, where each vertex is given a list of admissible colors. The notable exception is List 4-Coloring, which is NP-hard already in -free graphs . Furthermore, all hardness results also imply the nonexistence of subexponential-time algorithms (assuming the ETH).
Some more general positive results can be obtained if we relax our notion of tractability. As observed by Groenland et al. , List 3-Coloring can be solved in subexponential time in -free graphs, for every fixed . This was recently improved by Pilipczuk, Pilipczuk, and Rzążewski  who showed a quasipolynomial-time algorithm for this problem. Note that this is strong evidence that the problem is not NP-hard.
Graph colorings can be seen as a special case of graph homomorphisms. A homomorphism from a graph to a graph (with possible loops) is an edge-preserving mapping from to . Note that homomorphisms to are precisely proper -colorings. By the celebrated result of Hell and Nešetřil , determining whether an input graph admits a homomorphism to a fixed graph is polynomial-time solvable if is bipartite or has a vertex with a loop, and NP-hard otherwise. A list variant of the graph homomorphism problem, denoted by LHom(), has also been considered. It turns out that the problem can be solved in polynomial time if is a so-called bi-arc graph, and otherwise, the problem is NP-hard [12, 13, 14].
The complexity of variants of the graph homomorphism problem in hereditary graph classes was also studied. For example, Chudnovsky et al.  showed that LHom() for is polynomial-time solvable in -free graphs. On the negative side, they showed that for every the problem cannot be solved in -free graphs, unless every component of , where consists of graphs whose every connected component is a path or a tree with three leaves (called a subdivided claw). This negative result was later extended by Piecyk and Rzążewski  who showed that if is not a bi-arc graph (i.e., LHom() is NP-hard in general graphs), then LHom() is NP-hard and cannot be solved in subexponential time (assuming the ETH) in -free graphs, unless .
The case of forbidden path or subdivided claw was later investigated by Okrasa and Rzążewski . They defined a class of predacious graphs and showed that if is not predacious, then for every , the LHom() problem can be solved in quasipolynomial time in -free graphs (for every ). Otherwise, for every , there exists for which LHom() cannot be solved in subexponential time in -free graphs unless the ETH fails. They also provided some partial results for the case of forbidden subdivided claws.
Locally surjective graph homomorphisms.
Graph homomorphisms are a very robust notion, which can be easily extended by putting some additional restrictions on the solution. In this paper, we focus on one such variant called locally surjective homomorphisms. A homomorphism from to is locally surjective if it is surjective in the neighborhood of each vertex of . In other words, if , then for every neighbor of in (including , if it has a loop) there is a neighbor of in , such that . The study of locally surjective homomorphisms originates in social sciences, where they can be used to model some social roles (the problem is called role assignment ). The problem of determining whether an input graph admits a locally surjective homomorphism to a fixed graph is denoted by LSHom(). Fiala and Paulusma  provided the full complexity dichotomy for LSHom(). For simplicity, let us consider only connected graphs , and let be the one-vertex graph with a loop. They showed that LSHom() is polynomial-time-solvable if , and otherwise it is NP-hard. Again, the hardness reduction excluded also subexponential time algorithms under the ETH.
Let us point out that LSHom() is closely related to the well-known hypergraph 2-coloring problem  (or, equivalently, Positive NAE SAT). In this problem, we ask whether the input hypergraph admits a 2-coloring of its vertices which makes no edge monochromatic. Consider a hypergraph with vertices and hyperedges , and let be its incidence graph, i.e., the bipartite graph with vertex set , where is adjacent to if and only if . Note that proper 2-colorings of are precisely locally surjective homomorphisms of to with consecutive vertices , where is mapped to , and is mapped to . As shown by Camby and Schaudt , 2-coloring of hypergraphs with -free incidence graph is polynomial-time solvable.
In this paper, we consider the complexity of the list variant of LSHom(), called LLSHom(). First, we observe that if (recall, these are the easy cases of LSHom()), then also LLSHom() can be solved in polynomial time in general graphs.
Then we focus on the complexity of the problem in -free graphs. In particular, we are interested in determining the pair , for which the problem can be solved in subexponential time. Similarly to the case of LHom(), we split into two cases, depending whether .
In the first case, we identify two more positive cases: we show that if , then the problem admits a subexponential-time algorithm for every . The algorithm itself uses a win-win strategy: we combine branching on a high-degree vertex with a separator theorem that can be used if the maximum degree is bounded. A similar approach was used for various other problems [20, 31], however, the specifics of our problem require a slightly more complicated approach.
We also show that the above cases are the only positive ones for general , which provides the following dichotomy theorem.
Let be a fixed connected graph.
If , then for every , the LLSHom() problem can be solved in time in -vertex -free graphs.
Otherwise there is , such that the LLSHom() problem cannot be solved in subexponential time in -free graphs, unless the ETH fails.
Then, we turn our attention to other forbidden graphs . We show that whenever the problem is NP-hard for general graphs, i.e., for every , and for every there exists , such that LSHom() is NP-hard in graphs of degree at most and girth at least . This implies the following lower bound.
For every connected , there exists , such that the following holds. For every graph that is not a forest of maximum degree at most , the LLSHom() problem cannot be solved in time in -vertex -free graphs of maximum degree , unless the ETH fails.
We conclude the paper by discussing the possibilities of improving our theorems in order to fully classify the complexity ofLSHom() in -free graphs.
For a graph and , by we denote the set of neighbors of in . For a set , by we denote . If is clear from the context, we omit the subscripts. By , where , we denote the subgraph of induced by the set .
For graphs and , by we denote their direct product (sometimes called categorical product or Kronecker product), i.e, the graph
For , by we denote the -vertex path, and by we denote the three-leaf tree with leaves at distance , , and , respectively, from the unique vertex of degree 3, which we denote as central. Every such is called a subdivided claw. Recall that by , we denote the family of graphs whose every connected component is either a path or a subdivided claw.
Let be a homomorphism from to . We say that a vertex is happy (in ) if . In other words, for every neighbor of , some neighbor of is colored . We say that a homomorphism is locally surjective if every vertex is happy in . If is a locally surjective homomorphism from to , we denote it by .
For a fixed graph (with possible loops) we consider the problem, whose instance is where is a graph and is a list function. We ask if there exists a homomrphism , such that for every it holds that . If is such a homomorphism, we denote it by .
Observe that if or is disconnected, then each component of must be mapped to some component of . Thus, the problem can be easily reduced to the case that both and are connected. We will assume this from now on.
Recall that the non-list variant of our problem, i.e., , is polynomial time-solvable if (where denotes the one-vertex graph with a loop), and NP-hard otherwise . Let us point out that exactly the same dichotomy holds for .
If , then is polynomial-time solvable, and otherwise it is NP-hard.
As is a restriction of , it is sufficient to show the polynomial cases. Indeed, NP-hardness of implies the NP-hardness of .
The positive instances of are edgeless graphs, where the list of every vertex is nonempty. Similarly, the positive instance of are graphs with no isolated vertices, where the list of every vertex is nonempty. In both cases, yes-instances can clearly be recognized in polynomial time.
Finally, let us consider the case that , denote its vertices by and . Let be an instance of . First, note that if is not bipartite, then is a no-instance, and we are done. If is disconnected, then we can process each connected component of separately.
So assume that is connected and bipartite, and its bipartition classes are and . We observe that every homomorphism from to either maps to 1 and to 2, or maps to 2 and to 1. It is clear that verification if any of these two functions is a locally surjective list homomorphism can be performed in polynomial time. ∎
2.1 Associated Bipartite Graphs and Associated Instances
Now let us show that in order to classify the hard cases of LLSHom() it is sufficient to consider the case that is bipartite. A similar approach was used to the LHom() [32, 14], but to the best of our knowledge, we are the first to observe that it also works for LLSHom().
Let be a connected bipartite graph with bipartition classes , and consider an instance of , where is connected. Note that if is not bipartite, then is clearly a no-instance. Thus, assume that is bipartite with the bipartition classes . We observe that in every homomorphism , either all vertices of are mapped to , and all vertices of are mapped to , or all vertices of are mapped to , and all vertices of are mapped to . Thus in order to solve , we can consider these two cases separately. More specifically, we need to solve two instances and of , where
This motivates the following definition, see also .
Let be a connected bipartite graph with bipartition classes . We say that an instance of is consistent, if
is connected bipartite with the bipartition classes ,
For a graph , by we denote its associated bipartite graph. In other words, the vertex set of is and the edge set is . We also define and , i.e., are the bipartation classes of .
Note that if is connected and nonbipartite, then is connected. If is bipartite, then consists of two disjoint copies of .
Let be a fixed connected nonbipartite graph. Let be a consistent instance of . For each , define . Then is a yes-instance of if and only if is a yes-instance of .
First consider . Define as follows: if and only if . Clearly, is a homomorphism from to , and it respects lists .
Let us show that is locally surjective. Consider such that and some . Since , we know that (the actual value depends on the bipartition class where belongs). By symmetry, assume that . Since is locally surjective and , there is , such that . Then, .
Now, consider . Let the bipartition classes of be , such that and (this holds since is consistent). We define as follows. Consider and let . If , then and if , then . Again, it is straightforward to verify that is a homomorphism from to , and it respects lists , since is consistent.
Now, let us argue that is locally surjective. By symmetry, consider , such that . Then, . Let . Since is locally surjective, there is , such that . Thus, . ∎
Let be a class of graphs and let be a fixed connected nonbipartite graph. Suppose there is an algorithm that solves every bipartite instance of , such that , in time . Then there is an algorithm that solves every instance of , where , in time .
Consider an arbitrary instance of , where . If is disconnected, we apply the reasoning below to each connected component independently. Furthermore, we can assume that is bipartite, as otherwise, it is a trivial no-instance.
By the reasoning at the beginning of the section, we can reduce solving to solving two consistent instances. Thus, let us assume that is consistent. By Lemma 2.3, in order to solve , it is sufficient to solve the instance of , where the lists are defined as in the lemma. This can be done in time using the algorithm . As all additional computation (checking if is bipartite, determining lists ) can be performed in polynomial time, the claim follows. ∎
Note that Corollary 2.4 immediately implies the following.
Assume the ETH. Let be a fixed connected nonbipartite graph and let be a class of graphs. If cannot be solved in time for -vertex instances in , then cannot be solved in time for -vertex instances in .
3 Algorithm for -free Graphs for
An important tool used in our algorithm is the following structural result about -free graphs.
Theorem 3.1 (Okrasa, Rzążewski ).
Let be an integer. Given an -vertex -free graph with maximum degree , in time we can find a tree decomposition of with width at most .
Equipped by this, we are ready to prove the following algorithmic result.
Let be fixed integers. The in -vertex -free graphs can be solved in time .
Denote the consecutive vertices of by . Let be an instance of , where has vertices and is -free. Let and note that is -free. Furthermore, if is not bipartite, then is clearly a no-instance. Thus, we can assume that is bipartite (and, in particular, triangle-free).
Furthermore, recall that we can safely assume that the instance is consistent. Let and denote the bipartition classes of , such that and . Note that if or , then we are clearly dealing with a no-instance. Thus from now on, let us assume otherwise. In particular, it means that every vertex from is always happy. Consequently, our task boils down to choosing colors for vertices of to make each vertex from happy.
Actually, we will design a recursive algorithm that solves a slightly more general problem, where we are additionally given a function . We are looking for a list homomorphism , such that for every it holds that . Initially, we have for every . Thus, the returned homomorphism is indeed locally surjective. During the course of the algorithm, we will modify the sets to keep track of the colors seen by vertices in in the part of the graph that was removed.
Each recursive call starts with a preprocessing phase. First, we exhaustively apply the following steps. If there is some with , then we immediately terminate the recursive call and report a no-instance. If there is some with , then we can safely remove from the graph. If there is some with , then we remove the element of from the sets of all neighbors of , and remove from the graph.
If none of the above steps can be applied and has an isolated vertex (note that ), then we terminate and report a no-instance. The preprocessing phase can clearly be performed in polynomial time.
Finally, if the graph obtained is disconnected, we apply the following reasoning to every connected component independently. Let us still denote the instance by , and assume that is connected.
We consider two cases. First, suppose that there is with . We branch on choosing the color for , i.e., we perform two recursive calls of the algorithm, in one branch setting , and in the other . Note that at least neighbors of have the same set . Consequently, in at least one branch, the sets will be reduced for at least vertices during the preprocessing phase. In the other branch, we are guaranteed to have a little progress, too: the vertex will be removed from the graph. Let us define the measure of the instance as . Clearly . Thus the complexity of this step is given by the following recursive inequality:
So now let us assume that for each it holds that . Let be the set of vertices satisfying . Observe that . Consequently, .
Consider the graph . As it is an induced subgraph of , it is -free. Furthermore, the maximum degree of is at most . Consequently by Theorem 3.1, in time we can find a tree decomposition of with width . Let us modify this tree decomposition by adding the set to every bag – this way we obtain a tree decomposition of with width .
Using fairly standard dynamic programming on a tree decomposition, we can solve our auxiliary problem on graphs given with a tree decomposition of width in time . Indeed, the state of the dynamic programming is the coloring of the vertices from in the current bag and the colors seen by the vertices from in subgraph induced the subtree rooted at the current bag (these colors are reflected in sets ). Thus, the total number of states to consider is at most (two possibilities for a vertex from and at most three for a vertex from ).
Consequently, in the second case we obtain the running time .
Summing up, the overall complexity of the algorithm is . This completes the proof. ∎
Note that every -free graph is also, e.g., -free, so Theorem 3.2 can also be applied to -free graphs. Now, let us show a slight generalization of Theorem 3.2 to the case that we exclude a forest of paths and subdivided claws.
For every , the problem in -vertex -free graphs can be solved in time .
Sketch of proof.
Let for some , where each is a subdivided claw.
We begin similarly to the algorithm from Theorem 3.2. Again, we are solving an auxiliary problem with instance . First, we check if the instance graph is bipartite, and otherwise, we reject it. Let the bipartition classes of be and , and let and . Then, we perform the preprocessing phase and the branching phase; note that in these phases, we do not assume anything about the forbidden induced graph. The recursion tree has leaves, each corresponds to an instance which is -free and every vertex from has maximum degree at most . Consider one such instance, for simplicity let us call it .
We continue as in the proof of Theorem 3.2 by selecting the set of vertices of degree at least . Recall that and the graph is of maximum degree at most .
Now for each we perform the following steps. Let be an instance corresponding to a leaf of the recursion tree, with the set removed. We check if contains as an induced subgraph, this can be done in polynomial time by the exhaustive enumeration. If not, then is -free and we can call the algorithm given by Theorem 3.1 and continue exactly as in the proof of Theorem 3.2.
Thus, let us suppose that there is , such that . We observe that . We exhaustively guess the coloring of , this results in branches. In each branch, we update the sets for the neighbors of colored vertices; in particular we reject if some vertex from does not see some color in . Note that each instance is -free.
After the last iteration, the instances corresponding to the leaves of the recursion tree are -free, and thus we continue as in the proof of Theorem 3.2, i.e., use Theorem 3.1, restore the set , and solve the problem by dynamic programming.
The total number of leaves of the recursion tree is at most
each of which corresponds to an instance that is -free for some , and thus can be solved in time as in Theorem 3.2. ∎
Now, let us show that the algorithm from Theorem 3.2 can be used to solve in -free graphs. The proof of the following lemma is based on a similar argument used by Okrasa and Rzążewski  in the non-list case.
Let be a consistent instance of . Then the problem can be reduced in polynomial time to solving two consistent instances of .
Let the consecutive vertices of be . Let the bipartition classes of be , and let and .
Define as follows:
We claim that is a yes-instance of if and only if is a yes-instance of and is a yes-instance of . Note that both graphs and are induced three-vertex paths.
First, suppose that there is some . Let us define as follows:
Let us argue that that and . We prove only the first claim. The proof of the second one is analogous. First, is clearly a homomorphism. Furthermore, it satisfies the lists, as for we have , and for we have . Finally, let us argue that is locally surjective. For each , there are some such that and , as otherwise is not locally surjective. Thus, , which makes happy in . Similarly, for each , there are some such that and , as otherwise is not locally surjective. Thus, and , which makes happy in .
Now, suppose there are and . We define as follows:
Let us argue that .
First, note that is a homomorphism, as for every edge , where and , we have and .
Now, observe that respects the lists . Indeed, for we have and for we have .
Finally, let us argue that is locally surjective. Consider some ; the argument for vertices in is symmetric. Note that . Since is locally surjective, has two neighbors , such that and . Consequently, and , which makes happy in . This completes the proof. ∎
For every , the in -vertex -free graphs can be solved in time .
4 Hardness for -free Graphs for
In this section, we will prove the hardness part of Theorem 1.1, i.e., if then there is such that LLSHom() cannot be solved in subexponential time in -free graphs. It easily follows that such contains at least one of as an induced subgraph, where and are graphs consisting of an edge with a loop at one or both of its endpoint, respectively. First, we will prove the theorem for several base cases for . Then, we will generalize the result for containing an induced subgraph . The last cases when contains or as an induced subgraph will follows from the base cases and Corollary 2.5 as for such the graph contains as an induced subgraph.
4.1 Hardness for
The LLSHom() problem cannot be solved in time in -vertex -free graphs, unless the ETH fails. Moreover, the constructed reduction use only lists of size at most 2, and each vertex of the construction which has a list of size exactly two has a neighbor with a list of size exactly one.
Let , where is the central degree three vertex and are the leaves. We reduce from the 3-SAT problem. The ETH implies that an instance with variables and clauses cannot be solved in time . We first describe the reduction. For every variable , a variable gadget is represented by with the central vertex with and the leaves with lists , , and , respectively.
Claim 4.2 (Variable consistency).
There exists exactly two homomorphisms in which vertices of are happy:
, , , , and
, , , .
Proof of Claim 4.2. In order to make vertex happy, vertices and have to be mapped to different vertices of . It is easy to check that all other vertices are happy.
For every clause , the clause gadget is represented by . Let denote the central vertex, and , , and denote vertices of the -th branch ordered by the distance from , for . We set the lists as , , , and . We construct the final graph as follows. If variable appears as the -th literal in clause , then (of ) is adjacent to or (of ) if the literal is positive or negative, respectively. Moreover, each central vertex of each clause is connected with each and with each vertices of all variable gadgets. For an overview of the described construction, see Figure 1. This completes the construction of the graph . The described construction gives only a constant blow-up, and therefore the ETH lower bound is preserved. Observe that vertex is happy if and only if for at least one has .
First, suppose that we have a satisfying assignment of the formula. We will construct the sought homomorphism . For each variable , we set of based on Claim 4.2: we use assignment from (i) if is true and (ii) otherwise. As each clause is satisfied, say by the -th literal, there is a corresponding variable gadget such that sees a vertex mapped to 1 (either a true variable occurring as a positive literal or a false variable occurring as a negative literal in ). In order to make happy, we set and so , that immediately makes also happy. It is easy to check that all other vertices in a clause gadget may be mapped in a way to be happy and that we created a yes-instance.
Second, suppose there is a homomorphism . We define the truthfulness of variables based on Claim 4.2: is true if (i) and false if (ii). Now, it remains to check whether this is a satisfying assignment. For each clause , in is happy. Therefore for some , . In order for to be happy, vertex (or ) in the adjacent variable gadget has to be mapped to . In both cases, variable satisfies .
It remains to argue that the constructed graph is -free. Suppose there is an induced denoted as . Clearly, it is not solely within variable or clause gadgets. Hence, it must contain vertex or of some variable gadget as those are the only vertices that connect variable and clause gadgets. We denote this particular vertex . If no central vertex of a clause gadget belongs to , we are limited to an induced path on at most seven vertices. Therefore, contains a central vertex of some gadget. As all central vertices of clause gadgets induce together with all vertices and of variable gadgets a complete bipartite graph, either at most one other central vertex or at most one other vertex or can belong to . The former leads to an induced path on at most seven vertices, the latter to an induced path on at most nice vertices. ∎
4.2 Hardness for
The LLSHom() problem cannot be solved in time in -vertex -free graphs, unless the ETH fails. Moreover, the problem is hard even for instances where all the lists are of size at most 2, and each vertex that has a list of size exactly two has a neighbor with a list of size exactly one.
Let , where are the consecutive vertices on the path. We reduce from the 3-SAT problem. Let be an instance of 3-SAT. Without loss of generality, we can assume that each variable appears at least once negatively and at least once positively in some clause in . For every variable we introduce a variable gadget to be a double-sided broom with a five-vertex path , called handle, set of leaves on one end, and set of leaves on the second end of the handle. The number of vertices in and equals to the number of positive and negative occurrences of in , respectively. We set the lists of to be , respectively, and the lists of all vertices in to be (see a part of Figure 2 for an illustration).
Claim 4.4 (Variable consistency).
There exists exactly two homomorphisms in which the vertices of the handle of are happy:
, , , , , , and
, , , , , .
Proof of Claim 4.4. In order to make vertex happy, vertices and have to be mapped to different vertices of . As consequence, vertices are mapped to different vertices as well. It is easy to check that all other vertices except