We investigate a problem at the confluence of two popular topics – graph homomorphisms and signed graphs. Their interplay was first considered in an unpublished manuscript of Guenin , and has since become an established field of study .
We now introduce the two topics separately. In the study of computational aspects of graph homomorphisms, the central problem is one of existence – does an input graph admit a homomorphism to a fixed target graph ? (The graphs considered here are undirected graphs with possible loops but no parallel edges.) This is known as the graph homomorphism problem. It was shown in  that this problem is polynomial-time solvable when has a loop or is bipartite, and is NP-complete otherwise. This is known as the dichotomy of graph homomorphisms (see ). The core of a graph is a subgraph of with the smallest number of vertices to which admits a homomorphism; note that such a subgraph is unique up to isomorphism. A graph with a loop has a vertex with a loop as its core, and a (non-empty) bipartite graph has an edge as its core. Thus an equivalent way of stating the graph dichotomy result is that the problem is polynomial-time solvable when the core of has at most one edge, and is NP-complete otherwise.
Now suppose the input graph is equipped with lists, and we ask if there is a homomorphism of to such that each . This is known as the graph list homomorphism problem. This problem also has a dichotomy of possible complexities  – it is polynomial-time solvable when is a so-called bi-arc graph and is NP-complete otherwise. Bi-arc graphs have turned out to be an interesting class of graphs; for instance, when is a reflexive graph (each vertex has a loop), is a bi-arc graph if and only if it is an interval graph .
These kinds of complexity questions found their most general formulation in the context of constraint satisfaction problems. The Feder-Vardi dichotomy conjecture  claimed that every constraint satisfaction problem with a fixed template is polynomial-time solvable or NP-complete. After a quarter century of concerted effort by researchers in theoretical computer science, universal algebra, logic, and graph theory, the conjecture was proved in 2017, independently by Bulatov  and Zhuk . This exciting development focused research attention on additional homomorphism type dichotomies, including ones for signed graphs [4, 6, 11].
The study of signed graphs goes back to [13, 14], and has been most notably investigated in [20, 21, 22, 23, 24], from the point of view of colourings, matroids, or embeddings. Following Guenin, homomorphisms of signed graphs have been pioneered in  and . The computational aspects of existence of homomorphisms in signed graphs – given a fixed signed graph , does an input signed graph admit a homomorphism to – were studied in [4, 11], and eventually a complete dichotomy classification was obtained in . It is surprisingly similar to the second way we stated the graph dichotomy result above, see Theorem 4, and the discussion following it.
Although typically homomorphism problems tend to be easier to classify with lists than without lists (lists allow for recursion to subgraphs), the complexity of the list homomorphism problem for signed graphs appears difficult to classify [2, 6]. If the analogy to (unsigned) graphs holds again, then the tractable cases of the problem should identify an interesting class of signed graphs, generalizing bi-arc graphs. In this paper, we begin the exploration of this concept. It turns out that even for signed trees the classification is complex.
2 Terminology and notation
A signed graph is a graph , with possible loops and multiple edges (at most two loops per vertex and at most two edges between a pair of vertices), together with a mapping , assigning a sign ( or ) to each edge of , so that different loops at a vertex have different signs, and similarly for multiple edges between the same two vertices. We denote such a signed graph by , and call its underlying graph and its signature. When the signature name is not needed, we denote the signed graph by to emphasize that it has a signature even though we do not give it a name. We will sometimes view signs of edges as colours, and call positive edges blue, and negative edges red. It will be convenient to call a red-blue pair of edges (or loops) with the same endpoint(s) a bicoloured edge (or loop); however, it is important to keep in mind that formally they are two distinct edges (or loops). By contrast, we call edges (and loops) that are not part of such a pair unicoloured; moreover, when we refer to an edge as blue or red we shall always mean the edge is unicoloured blue or red. Treating a pair of red-blue edges as one bicoloured edge is advantageous in many descriptions, but introduces an ambiguity when discussing walks, since a walk in a signed graph could be seen as a sequences of incident vertices and edges, and so selecting just one edge from a red-blue pair, or it could be seen as a sequence of consecutively adjacent vertices, and hence contain some bicoloured edges. This creates particular problem for cycles, since in the former view, a bicoloured edge would be seen as a cycle of length two, with one red edge and one blue edge. In the literature, the former approach is more common, but here we take the latter approach. Of course, the two views coincide if only walks of unicoloured edges are considered. The sign of a closed walk consisting of unicoloured edges is the product of the signs of its edges. Thus a closed walk of unicoloured edges is negative
if it has an odd number of negative (red) edges, andpositive if it has an even number of negative (red) edges. In the case of unicoloured cycles, we also call a positive cycle balanced and a negative cycle unbalanced. Note that a vertex with a red loop is a cycle with one negative edge, and hence is unbalanced. A uni-balanced signed graph is a signed graph without unbalanced cycles, i.e., a signed graph in which all unicoloured cycles (if any) have an even number of red edges. A anti-uni-balanced signed graph is a signed graph in which each unicoloured cycle has an even number of blue edges. Thus we have a symmetry to viewing the signs as colours, in particular is uni-balanced if and only if , obtained from by exchanging the colour of each edge, is anti-uni-balanced. We introduce the qualifier "uni-" because the notion of a balanced signed graph is well established in the literature: it means a signed graph without any unbalanced cycles in the classical view, including the two-cycles formed by red-blue pairs of edges. Thus a balanced signed graph is a uni-balanced signed graph without bicoloured edges and loops.
We now define the switching operation. This operation can be applied to any vertex of a signed graph and it negates the signs of all its incident non-loop edges. (The signs of loops are unchanged by switching.) We say that two signatures of a graph are switching equivalent if we can obtain from by a sequence of switchings. In that case we also say that the two signed graphs and are switching equivalent. (We note a sequence of switchings may also be realized by negating all the edges of a single edge cut.) In a very formal way, a signed graph is an equivalence class under the switching equivalence, and we sometimes use the notation to mean the entire class.
It was proved by Zaslavsky  that two signatures of are switching equivalent if and only if they define exactly the same set of negative (or positive) cycles. It is easy to conclude that a uni-balanced signed graph is switching equivalent to a signed graph with all edges and loops blue or bicoloured, and an anti-uni-balanced signed graph is switching equivalent to a signed graph with all edges and loops red or bicoloured.
We now consider homomorphisms of signed graphs. Since signed graphs can be viewed as equivalence classes, a homomorphism of signed graphs to should be a homomorphism of one representative of to one representative of . It is easy to see that this definition can be simplified by prescribing any fixed representative of . In other words, we now consider mapping all possible representatives of to one fixed representative of . At this point, a homomorphism of one concrete to is just a homomorphism of the underlying graphs to preserving the edge colours. Since there are multiple edges, we can either consider to be a mapping of vertices to vertices and edges to edges, preserving vertex-edge incidences and edge-colours, as in , or simply state that blue edges map to blue or bicoloured edges, red edges map to red or bicoloured edges, and bicoloured edges to bicoloured edges. We follow the second convention. We say that a signed graph contains a positive edge joining and if the edge is positive (blue) or bicoloured, similarly we say a signed graph contains a negative edge joining and if the edge is negative (red) or bicoloured.
We say that a mapping is a homomorphism of the signed graph to the signed graph , written as , if there exists a signed graph , switching equivalent to , such that whenever is a positive edge in , then contains a positive edge joining and , and whenever is a negative edge in , then contains a negative edge joining and .
There is an equivalent alternate definition (see ). A homomorphism of the signed graph to the signed graph is a homomorphism of the underlying graphs to , such that for any closed walk in with only unicoloured edges for which the image walk has also only unicoloured edges, the sign of in is the same as the sign of in . (In other words, negative closed walks map to negative closed walks and positive closed walks map to positive closed walks.) This definition does not require switching the input graph before mapping it. The equivalence of the two definitions follows from the theorem of Zaslavsky  cited above. That result is constructive, and the actual switching required to produce the switching equivalent signed graph can be found in polynomial time .
We deduce the following fact.
Suppose and are signed graphs, and is a mapping of the vertices of to the vertices of . Then is a homomorphism of the signed graph to the signed graph if and only if is a homomorphism of the underlying graph to the underlying graph , which moreover maps bicoloured edges of to bicoloured edges of , and for any closed walk in with only unicoloured edges for which the image walk has also only unicoloured edges, the signs of and are the same.
Note that each negative closed walk contains a negative cycle, and in particular an irreflexive tree has no negative closed walks. Thus if is an irreflexive tree, then the condition simplifies to having no negative cycle of mapped to unicoloured edges in (because the image would be a positive closed walk). For reflexive trees, the condition requires that no negative cycle of maps to a positive closed walk in , and no positive cycle of maps to a negative closed walk.
For our purposes, the simpler Definition 2 is sufficient. Note that whether an edge is unicoloured or bicoloured is independent of switching, and that a homomorphism can map a unicoloured edge or loop in to a bicoloured edge or loop in but not conversely.
Let be a fixed signed graph. The homomorphism problem takes as input a signed graph and asks whether there exists a homomorphism of to . The formal definition of the list homomorphism problems for signed graphs is very similar.
Let be a fixed signed graph. The list homomorphism problem List-S-Hom takes an input a signed graph with lists for every , and asks whether there exists a homomorphism of to such that for every .
We note that when and are switching equivalent signed graphs, then any homomorphism of an input signed graph to is also a homomorphism to , and therefore the problems and , as well as the problems List-S-Hom and List-S-Hom, are equivalent.
We call a signed graph connected if the underlying graph is connected. We call reflexive is each vertex of has a loop, and irreflexive if no vertex has a loop. We call a signed tree if , with any existing loops removed, is a tree.
3 More background and connections to constraint satisfaction
We now briefly introduce the constraint satisfaction problems, in the format used in . A relational system consists of a set of vertices and a family of relations on . Assume is a relational system with relations and a relational system with relations , where the arity of the corresponding relations and is the same for all . A homomorphism of to is a mapping that preserves all relations, i.e., satisfies , for all . The constraint satisfaction problem with fixed template asks whether or not an input relational system , with the same arities of corresponding relations as , admits a homomorphism to .
Note that when has a single relation , which is binary and symmetric, then we obtain the graph homomorphism problem referred to at the beginning of Section 1. When has a single relation , which is an arbitrary binary relation, we obtain the digraph homomorphism problem  which is in a certain sense  as difficult to classify as the general constraint satisfaction problem. When has two relations , then we obtain a problem that is superficially similar to the homomorphism problem for signed graphs, except that switching is not allowed. This problem is called the edge-coloured graph homomorphism problem , and it turns out to be similar to the digraph homomorphism problem in that it is difficult to classify . On the other hand, the homomorphism problem for signed graphs [4, 6, 11], seems easier to classify, and exhibits a dichotomy similar to the graph dichotomy classification, see Theorem 4.
List homomorphism problems are also special cases of constraint satisfaction problems, as lists can be replaced by unary relations. Consider first the case of graphs. Suppose is a fixed graph, and form the relational system with vertices and the following relations: one binary relation (this is a symmetric relation corresponding to the undirected edges of the graph ), and unary relations on , each consisting of a different non-empty subset of . The constraint satisfaction problem with template has inputs with a symmetric binary relation (a graph) and unary relations , and the question is whether or not a homomorphism exists. If a vertex is in the relation corresponding to , then any mapping preserving the relations must map to a vertex in ; thus imposing the relation on amounts to setting . Therefore the list homomorphism problem for the graph is formulated as the constraint satisfaction problem for the template .
Such a translation is also possible for homomorphism of signed graphs. Brewster and Graves introduced a useful construction. The switching graph has two vertices for each vertex of , and each edge of gives rise to edges of colour and edges of the opposite colour. (This definition applies also for loops, i.e., when .) Then each homomorphism of the signed graph to the signed graph corresponds to a homomorphism of the edge-coloured graph to the edge-coloured graph and conversely. For list homomorphisms of signed graphs, we can use the same transformation, modifying the lists of the input signed graph. If has lists , then the new lists are defined as follows: for any for , we place both and in . It is easy to see that the signed graph has a list homomorphism to the signed graph with respect to the lists if and only if the edge-coloured graph has a list homomorphism to the edge-coloured graph with respect to the lists . The new lists are symmetric sets in , meaning that for any , we have if and only if we have . Thus we obtain the list homomorphism problem for the edge-coloured graph , restricted to input instances with lists that are symmetric in . As above, we can transform this list homomorphism problem for the edge-coloured graph , to a constraint satisfaction problem with the template obtained by adding unary relations , for sets that are symmetric in .
We conclude that our problems List-S-Hom fit into the general constraint satisfaction framework, and therefore it follows from [7, 25] that dichotomy holds for problems List-S-Hom. We therefore ask which problems List-S-Hom are polynomial-time solvable and which are NP-complete.
The solution of the Feder-Vardi dichotomy conjecture involved an algebraic classification of the complexity pioneered by Jeavons . A key role in this is played by the notion of a polymorphism of a relational structure . If is a digraph, then a polymorphism of is a homomorphism of some power to , i.e., a function that assigns to each ordered -tuple of vertices of a vertex such that two coordinatewise adjacent tuples obtain adjacent images. For general templates, all relations must be similarly preserved. A polymorphism of order is a majority if for all . A Siggers polymorphism is a polymorphism of order , if for all . One formulation of the dichotomy theorem proved by Bulatov  and Zhuk  states that the constraint satisfaction problem for the template is polynomial-time solvable if admits a Siggers polymorphism, and is NP-complete otherwise. Majority polymorphisms are less powerful, but it is known  that if admits a majority then the constraint satisfaction problem for the template is polynomial-time solvable. Moreover, we have shown in  that a graph is a bi-arc graph if and only if the associated relational system admits a majority polymorphism. Thus the list homomorphism problem for a graph with possible loops is polynomial-time solvable if admits a majority polymorphism, and is NP-complete otherwise. A similar result may hold for signed graphs. Since List-S-Hom is polynomial-time if admits a majority polymorphism, we ask if it is true that List-S-Hom is NP-complete if does not admit a majority polymorphism.
There is a convenient way to think of polymorphisms of the relational system . A mapping is a polymorphism of if and only if it is a polymorphism of the edge-coloured graph and if, for any symmetric set , we have then also . We call such polymorphisms of semi-conservative.
For any signed graph , the problem List-S-Hom is polynomial-time solvable if admits a semi-conservative Siggers polymorphism, and is NP-complete otherwise.
As mentioned above, we ask whether in the theorem one can replace the semi-conservative Siggers polymorphism by a semi-conservative majority polymorphism. We focus in this paper on seeking a graph theoretic classification, at least for some classes of signed graphs.
4 Basic facts
We first mention the dichotomy classification of the problems S-Hom from . A subgraph of the signed graph is the s-core of if there is homomorphism , and every homomorphism is a bijection on . The letter stands for signed. It is again easy to see that the -core is unique up to isomorphism and switching equivalence.
 The problem S-Hom is polynomial-time solvable if the s-core of has at most two edges, and is NP-complete otherwise.
When the signature has all edges positive, the problem S-Hom is equivalent to the unsigned graph homomorphism problem, and the s-core of is just the core of . To compare Theorem 4 with the graph dichotomy theorem of  as discussed at the beginning Section 1, we observe that the core of a graph cannot have exactly two edges, as a core must be either a single vertex (possibly with a loop), or a single edge, or a graph with at least three edges. Thus Theorem 4 is stronger than the graph dichotomy theorem from , which states that the graph homomorphism problem to is polynomial-time solvable if the core of has at most one edge and is NP-complete otherwise. (However, we note that the proof of Theorem 4 in  uses the graph dichotomy theorem .)
Observe that an instance of the problem can be also viewed as an instance of with all lists , therefore if is NP-complete, then so is . Moreover, if is an induced subgraph of , then any instance of can be viewed as an instance of (with the same lists), therefore if the problem is NP-complete, then so is the problem . This yields the NP-completeness of for all signed graphs that contain an induced subgraph whose s-core has more than two edges. Furthermore, when the signed graph is uni-balanced, then we may assume that all edges are blue or bicoloured, and the list homomorphism problem for can be reduced to . In particular, we emphasize that is NP-complete if is a uni-balanced signed graph (or, by a symmetric argument, an anti-uni-balanced signed graph), and the underlying graph is not a bi-arc graph .
Next we focus on the class of signed graphs that have no bicoloured loops and no bicoloured edges. In this case, the following simple dichotomy describes the classification. (This result was previously announced in .) It follows from our earlier remarks that these signed graphs are balanced if and only if they are uni-balanced, and similarly they are anti-balanced if and only if they are anti-uni-balanced.
Suppose is a connected signed graph without bicoloured loops or edges. If the underlying graph is a bi-arc graph, and is balanced or anti-balanced, then the problem is polynomial-time solvable. Otherwise, the problem is NP-complete.
The polynomial cases follow from Feder et al. , since balanced or anti-balanced signed graphs can be assumed to have all edges blue, or all red. Otherwise, the graph must contain a cycle which cannot be switched to a blue cycle and a cycle which cannot be switched to a red cycle, in which case the s-core of contains at least three edges. (This is true even if the cycles are just loops.) ∎
We have observed that List-S-Hom is NP-complete if the s-core of has more than two edges. Thus we will focus on signed graphs whose s-cores have at most two edges. This is not as simple as it sounds, as there are many complex signed graphs with this property, including, for example, all irreflexive bipartite signed graphs that contain a bicoloured edge, and all signed graphs that contain a bicoloured loop. That these cases are not easy underlines the fact that the assumptions in Theorem 4 cannot be weakened without significant new breakthroughs. Consider, for example, allowing bicoloured edges but not bicoloured loops. In this situation, we may focus on the case when there is a bicoloured edge (else Theorem 4 applies), and so if there is any loop at all, the s-core would have more than two edges. Thus we consider irreflexive signed graphs, and the s-core is still too big if the underlying graph has an odd cycle. So in this case it remains to classify the irreflexive bipartite signed graphs that contain a bicoloured edge. Even this case is complex, as we discuss in the final section.
In this paper we focus on when the underlying graph of is a reflexive or irreflexive tree. We also study an additional class of irreflexive bipartite signed graphs in which the unicoloured edges span a Hamiltonian path. We classify the complexity of these graphs; the classification turns out to be surprisingly complex.
We now introduce our basic tool for proving NP-completeness.
Let be two walks in of equal length, say , with vertices and , with vertices . We say that is a chain, provided are unicoloured edges and are bicoloured edges, and for each , , we have
both and are edges of while is not an edge of , or
both and are bicoloured edges of while is not a bicoloured edge of .
If a signed graph contains a chain, then is NP-complete.
Suppose that has a chain as specified above. We shall reduce from Not-All-Equal SAT. (Each clause has three unnegated variables, and we seek a truth assignment in which at least one variable is true and at least one is false, in each clause.) For each clause , we take three vertices , each with list , and three vertices , each with list . For the triple , we add three new vertices , , and , each with list , and for the triple , we add three new vertices , each with list . We connect these vertices as follows:
adjacent to by a red edge and to by a blue edge,
adjacent to by a red edge and to by a blue edge,
adjacent to by a red edge and to by a blue edge.
Analogously, the hexagon will also be alternating in blue and red colours, with (say) adjacent to by a red edge.
Moreover, we join each pair of vertices and by a separate path of length , say , where has list and the edge is blue unless both and are bicoloured, in which case is also bicoloured. Paths and are defined analogously. See Figure 1 for an illustration.
We observe for future reference that the path , when considered by itself, admits a list homomorphism both to and to , but no list homomorphism to any other subgraph of . (To see the first part, invoke Zaslavsky’s theorem characterizing switching equivalent signatures, and use the fact that both and contain a bicoloured edge. To see the second part, use the conditions in the definition of chain.)
If occurs in more clauses, we link the occurrences by a new vertex with the list and blue edges to all occurrences of . (This will ensure that all occurrences of take on the same truth value.)
We denote the resulting graph . We now claim that this instance of Not-All-Equal SAT is satisfiable if and only if admits a list homomorphism to .
Let denote the subgraph of induced by
and . We claim that
(i) any list homomorphism of to must switch at either one or two of the vertices , and that
(ii) there are list homomorphisms of to that switch at any one or any two of the vertices .
Once this claim is proved, we can associate with every truth assignment a list homomorphism of to where a vertex corresponding to a variable is switched if and only if that variable is true, and conversely, setting a variable true if its corresponding vertex was switched in the list homomorphism.
We now prove (i). Since the lists are so restrictive, any list homomorphism is fully described by what happens to the paths , , , and whether or not the vertices corresponding to (and ) are switched. Note that begins with a unicoloured edge and ends with a unicoloured edge. It follows that in any list homomorphism of to after the necessary switching we must have either the edges and of the same colour, or the edges and of the same colour. (In the former case, we map to , in the latter case, we map it to .) If none of the vertices were switched, then the edges and must be of the same colour, and by a similar argument so must the edges and , as well as and . This would mean that the hexagon has an even number of red and even number of blue edges, which is impossible. (It started with an odd number of each.) Similarly, if all three vertices were switched, we would obtain the same contradiction.
For (ii), it remains to show that one or two of the vertices can be switched under a list homomorphism of to . Suppose first that only one was switched; by symmetry assume it was (so and were not switched). Now edges and have the same colour, and and have the same colour. By the above observation, we can map and to , and map to . Note that the switchings necessary for these list homomorphisms affect disjoint sets of vertices (the paths ), so the observation applies. If two vertices, say and were switched, the argument is almost the same and we omit it. ∎
5 Irreflexive trees
In this section, will always be an irreflexive tree. As trees do not have any cycles, is trivially uni-balanced, and hence we may assume that all edges are either blue or bicoloured.
If the underlying graph contains the graph in Figure 2, then is NP-complete.
If contains one of the signed graphs in family from Figure 3 as an induced subgraph, then is NP-complete
For each of the signed graphs in family we can apply Theorem 4. The figure lists a chain for each of these forbidden subgraphs. Thus any signed graph that contains one of them as an induced subgraph has NP-complete . ∎
An irreflexive tree is a -caterpillar if it contains a path , such that each vertex of is either on , or is a child of a vertex on , or is a grandchild of a vertex on , i.e., is adjacent to a child of a vertex on . We also say that is a -caterpillar with respect to the spine . (Note that the same tree can be a -caterpillar with respect to different spines .) In such a situation, let be the connected components of . Each is a star adjacent to a unique vertex on . The tree together with the edge joining it to is called a rooted subtree of (with respect to the spine ), and is considered to be rooted at . Note that there can be several rooted subtrees with the same root vertex on the spine, but each rooted subtree at contains a unique child of (and possibly no grandchildren, or possibly several grandchildren).
If is a -caterpillar with respect to the spine , and additionally the bicoloured edges of form a connected subgraph, and there exists an integer , with , such that:
all edges on the path are bicoloured, and all edges on the path are blue,
the edges of all subtrees rooted at are bicoloured, except possibly edges incident to leaves, and
the edges of all subtrees rooted at are all blue,
then we call a good -caterpillar with respect to .
The vertex is called the dividing vertex of . Note that the subtrees rooted at are not limited by any condition except the connectivity of the subgraph formed by the bicoloured edges. A typical example of a good -caterpillar is depicted in Figure 4.
Let be an irreflexive signed tree. Then is a good -caterpillar if and only if it does not contain any of the graphs from family in Figure 3 as an induced subgraph, and the underlying graph does not contain the graph in Figure 2.
It is easy to check that none of the depicted signed graphs admits a suitable spine, and hence they are not good -caterpillars. So assume does not contain any of the graphs in Figure 3 as an induced subgraph, and the underlying graph does not contain the graph in Figure 2 as a subgraph. If is not a -caterpillar with respect to any spine, then the underlying graph contains the tree in Figure 2. The bicoloured edges of induce a connected subgraph, since there is no subgraph from graph class a) in Figure 3. There exists a path with a dividing vertex as specified, because there is no subgraph from graph class b) in Figure 3. The absence of classes b) and c) from Figure 3 also ensures that, there is a suitable spine with bicoloured edges on and blue edges on , and with all subtrees of height two rooted at attached to with a bicoloured edge. The absence of graphs d) and e) in Figure 3 ensures all subtrees rooted at have all edges blue. ∎
Let be an irreflexive tree. If is a good -caterpillar, then is polynomial-time solvable. Otherwise, contains a copy of , or contains one of the signed graphs in family as an induced subgraph, and the problem is NP-complete.
The second claim follows from Lemmas 5, 5 and 5. We prove the first claim in a sequence of lemmas. Suppose that is a good -caterpillar with respect to the spine . Since is bipartite, we may distinguish its vertices as black and white. We may assume that the input signed graph is connected and bipartite, and the lists of the black vertices of contain only black vertices of , and similarly for white vertices. (Since is connected, there are only two possible assignments of black and white colours to its vertices, and we consider each separately.)
We distinguish four types of rooted subtrees of with respect to the spine .
Type : a bicoloured edge ;
Type : a bicoloured edge , bicoloured edges for a set of vertices , and blue edges for another set of vertices ;
Type : a blue edge and blue edges for a set of vertices ; and
Type : a blue edge .
In the types and we assume that they are not of type or , i.e., that at least some or exist; but we allow in either the set of or the set of to be empty.
Recall that we assume that all edges of are bicoloured or blue. Since the underlying graph is bipartite, we have also distinguished its vertices as black and white; we assume that is white.
A bipartite min ordering of the bipartite graph is a pair , where is a linear ordering of the black vertices and is a linear ordering of the white vertices, such that for white vertices and black vertices , if are both edges in , then is also an edge in . It is known  that if a bipartite graph has a bipartite min ordering, then the list homomorphism problem for can be solved in polynomial time as follows. First apply the arc consistency test, which repeatedly visits edges and removes from any vertex of not adjacent to some vertex of , and similarly removes from any vertex of not adjacent to some vertex of . After arc consistency, if there is an empty list, no list homomorphism exists, and if all lists are non-empty, choosing the minimum element of each list, according to or , defines a list homomorphism as required. We call a bipartite min-ordering of the signed irreflexive tree special if for black vertices and white vertices , if is bicoloured and is blue, then , and if is bicoloured and is blue, then . In other words, the bicoloured neighbours of any vertex appear before its unicoloured neighbours, both in and in .
Every good -caterpillar admits a special bipartite min ordering.
Let us first observe that any -caterpillar admits a bipartite min ordering in which and , and each subtree rooted at a vertex has the children of ordered between and and the grandchildren of ordered between and . We only need to ensure that the order of the grandchildren conforms to the order of the children, i.e., if a child of is ordered before a child of then the children of are all ordered before the children of . Also, all children of are ordered after all grandchildren of . See Figure 5 for an illustration.
It remains to ensure that the bipartite min ordering we choose is in fact a special bipartite min ordering, i.e., that each vertex has its neighbours joined to it by bicoloured edges ordered before its neighbours joined to it by unicoloured edges. Therefore the subtrees rooted at each are treated as follows. We will order first vertices of subtrees of type one at a time, then vertices of subtrees of type one at a time, then vertices of subtrees of type one at a time, and finally vertices of subtrees of type one at a time. Each subtree of type consists of only one bicoloured edge, and we order these consecutively between and . Next in order will come the children of in subtrees of type , still before , and in each of these subtrees we order first the grandchildren of incident to a bicoloured edge before those incident to a unicoloured edge. We order the subtrees of type similarly. Finally, for subtrees of type , we order their vertices (each a child of ) right after . ∎
If a signed irreflexive tree admits a special bipartite min ordering, then is polynomial-time solvable.
We describe a polynomial-time algorithm. Suppose is the input signed graph; we may assume is connected, bipartite, and such that the black vertices have lists with only the black vertices of , and similarly for the white vertices. The first step is to perform the arc consistency test for the existence of a homomorphism of the underlying graphs to , using the special bipartite min ordering . We also perform bicoloured arc consistency test, which repeatedly visits bicoloured edges of and removes from any vertex of not adjacent to some vertex of by a bicoloured edge, and similarly removes from any vertex of not adjacent to some vertex of by bicoloured edge. If it yields an empty list, there is no list homomorphism of the underlying graphs, and hence no list homomorphism of signed graphs. Otherwise, the minima of all lists define a list homomorphism of the underlying graphs, by . By the bicoloured arc consistency test, the minimum choices imply that the image of a bicoloured edge under is also a bicoloured edge. According to Lemma 2 and the remark following it, is also a list homomorphism of signed graphs unless a negative cycle of unicoloured edges of maps to a closed walk of blue edges in . Now we make use of the properties of special bipartite min ordering to repair the situation, if possible. Note that the fact that we choose minimum possible values for means that we cannot map lower in the orders . We consider three possible cases.
At least one of the edges of is in a subtree of type rooted at some with :
In this case, all edges of must be in , since the edge of incident to is bicoloured. Assume without loss of generality that is white, is the unique child of in , and are the blue edges of , where is black and are white. Since is included in the edges and precedes in all vertices , the final lists of the white vertices in do not include (since we assigned the minimum value in each list). Therefore under any homomorphism the image of the connected graph either is included in the set of edges , or is disjoint from this set of edges. Since we have already explored the first possibility, we can delete the vertices from the lists of all white vertices of and repeat the arc consistency test. This will check whether there is possibly another list homomorphism of graphs , which is also a homomorphism of signed graphs .
At least one of the edges of is in a subtree of type rooted at some :
In this case, all edges of must be in subtrees of type rooted at the same . Assume again, without loss of generality, that is white and the subtrees consist of the blue edges , with each black. Since is a special bipartite min ordering, all vertices adjacent to by a bicoloured edge are smaller in than . Therefore no such vertex can be in a list of a black vertex in . This again means that the image of is either included in the set of edges , or is disjoint from this set of edges. We can delete all vertices from the lists of all black vertices of and repeat as above.
The edges of are included in the set of the edges on the path and in the subtrees of types or rooted at :
In this case, the vertices of the cycle have lists containing only vertices incident with blue edges, and there is no homomorphism of signed graphs .
After we modified the image of one negative cycle of , we proceed to modify another, until we either obtain a homomorphism of signed graph, or find that no such homomorphism exists. The algorithm is polynomial, because arc consistency can be performed in linear time , and each modification removes at least one vertex of from the list of at least one vertex of . Recall that the graph is fixed, and hence its number of vertices is a constant . If has vertices, then this step will be performed at most times. ∎
6 Reflexive trees
We now turn to reflexive trees, and hence in this section, will always be a reflexive tree. We may have red, blue, or bicoloured loops, but we may again assume that all non-loop unicoloured edges are of the same colour (blue or red).
If the underlying graph contains the graph in Figure 6, then the problem is NP-complete.
Deciding if there exists a list homomorphism (of unsigned graphs) to the graph is NP-complete . A direct reduction of to as in the proof of Lemma 5 is complicated by the fact that the loops in can be red, blue, or bicoloured. However, the proof from  can itself be adapted to our setting as we now describe.
Suppose that is a subgraph of with underlying graph , and suppose that has been switched so that all non-loop edges are blue or bicoloured. Label the leaves of by , and their respective neighbours as , and label the center vertex .
Given distinct and in and distinct subsets and of , an -chooser is a path with endpoints and , together with a list assignment , such that the following hold. For each list homomorphism from to , either and or and . Moreover, for each and , there are list homomorphisms from to such that and .
Suppose is a -chooser, is -chooser, and is a -chooser. Let be the tree obtained by identifying the vertices in the three choosers and labelling the leaves respectively as . It is easy to verify that admits a list-homomorphism to if, and only if, the triple does not map to either or . Consequently, we can reduce an instance of Not-All-Equal SAT to . For each clause in the instance, create a copy of and identify the vertices with the three literals in the clause.
It remains to construct the choosers. Let be distinct. First, we begin by building an -chooser using a path of length (the distance between any pair of leaves in ). Let be the neighbour of on the this path. Define , , , and for all other vertices of . Let be the signed graph with underlying graph and all edges blue.
We claim together with is an -chooser. Any list homomorphism from to that maps to , must map to as and are not adjacent (and the case for is analogous). The next vertex of the path either maps to , and thus all subsequent vertices including map to , or the path is mapped to the path from to , specifically maps to . In the latter case, as the edges of are blue and the non-loop edges of are blue or bicoloured, there is no need for switching. In the former case, if has only a red loop, we switch at the neighbour of in so that the two edges of mapping to the loop on are now red. Observe that the switching occurs at an interior vertex of and thus copies of sharing an end-point with other choosers can be switched independently as required.
Next we build a -chooser . Again the underlying graph is a path of length from to . Let be the vertices of on the path from to . Define lists , , and for all other . (We note should be added to in .) Let again have all edges blue. It is easy to verify is the desired chooser. If maps to , then maps to without switching any vertex. If maps to (and thus all of maps to ), then no switching is required unless only has a red loop. In the latter case we switch at the unique neighbours of and in . Again we do not switch at end points of so the required switching is localized to .
The required choosers are defined as follows. First, is the -chooser followed by the -chooser. Next is the concatenation of the -chooser, the -chooser, the -chooser, and the -chooser. Finally is the concatenation of the -chooser and the -chooser. ∎