On Maltsev Digraphs

We study digraphs preserved by a Maltsev operation, Maltsev digraphs. We show that these digraphs retract either onto a directed path or to the disjoint union of directed cycles, showing that the constraint satisfaction problem for Maltsev digraphs is in logspace, L. (This was observed in [19] using an indirect argument.) We then generalize results in [19] to show that a Maltsev digraph is preserved not only by a majority operation, but by a class of other operations (e.g., minority, Pixley) and obtain a O(V 4 G)-time algorithm to recognize Maltsev digraphs. We also prove analogous results for digraphs preserved by conservative Maltsev operations which we use to establish that the list homomorphism problem for Maltsev digraphs is in L. We then give a polynomial time characterisation of Maltsev digraphs admitting a conservative 2semilattice operation. Finally, we give a simple inductive construction of directed acyclic digraphs preserved by a Maltsev operation.


Introduction
The study of relational structures and, in particular, digraphs preserved by certain operations from universal algebra became extremely important during the last decade.The main driving force behind this is the algebraic constraint satisfaction problem (CSP) dichotomy conjecture, which states that a constraint satisfaction problem CSP(B) is tractable if the relational structure B is preserved by a weak-near-unanimity (weak-NU) operation, and is NP-complete otherwise [5,6,23].Generalizing the dichotomy theorem of Hell and Nešetřil [19], the conjecture has been established for digraphs with no sinks and no sources by showing that the tractable digraphs are very structured, in fact, they retract onto a disjoint union of directed cycles [3].Other results relating the complexity of CSPs on digraphs to the existence of operations that preserve the digraph can be found, for example, in [2,1].
Once the tractability of a CSP is established, one also wishes to know the fine-grained complexity of that CSP, that is, for which structures B is CSP(B) in some subclass of P, such as L or NL?To establish the membership of a CSP in a complexity class inside P it is important to study the structure of relational structures (and digraphs) preserved by operations which are more "restrictive" than weak-NU operations, that is, operations that imply the presence of a weak-NU operation.Two important results in this direction, which we will invoke, are that if a relational structure B is preserved by a majority operation, then the corresponding CSP(B) is in the complexity class NL [11]; and if CSP(B) is definable in Datalog and B is preserved by a Maltsev operation, then CSP(B) is in L [12,14].
We study the structure of finite digraphs preserved by a Maltsev operation; we call such graphs Maltsev digraphs.We show that Maltsev digraphs retract either onto the disjoint union of directed cycles or to a directed path.This gives a direct proof that the corresponding CSP can be expressed with a symmetric Datalog program of width (2,3), and therefore the CSP is in L. 1 Kazda [22] showed that every Maltsev digraph also admits a majority operation.Subsequent work by Bulin, Delic, Jackson and Niven [8] showed that there is little opportunity for substantial extension of this result: the possible polymorphism behaviour of digraphs is mostly the same as for general CSPs.Nevertheless, we are able to revisit Kazda's argument, and use it to show that Maltsev digraphs also admit a minority polymorphism, and show how for Maltsev digraphs, a range of polymorphism properties are typically determined by the properties of an associated disjoint union of cycles.We also extend the results to the conservative setting, showing for example that a conservative Maltsev digraph is preserved by a class of conservative polymorphisms.
Kazda's article [22] concludes with an invitation to provide a more direct characterisation of Maltsev digraphs.We provide this by giving a graph-theoretic characterisation, and providing a O(|V G | 4 ) algorithm for recognising Maltsev digraphs.A similar characterisation is given for the conservative case; both conditions generalise the rectangularity property of [4].
We apply our results to the list homomorphism problem, LHOM, for directed graphs.We show that LHOM for Maltsev digraphs is in L. The complexity of LHOM for undirected graphs is completely understood [16], and for directed graphs there is a P vs. NP dichotomy is [20], and a recently announced L vs. NL-hard dichotomy [15].
Next we show that a digraph preserved by a Maltsev operation is also preserved by a conservative 2-semilattice operation if and only if the digraph satisfies a certain combinatorial property.We note that if a structure is preserved by a 2-semilattice operation, then CSP(B) is in Datalog and therefore in P [21].We also characterise digraphs (without the assumption of a Maltsev polymorphism) preserved by a conservative 2-semilattice operation and show that these digraphs can be recognised in NL.
In Section 5 we relate directed acyclic graphs (DAGs) preserved by Maltsev, and conservative Maltsev polymorphisms with series parallel digraphs.We characterize these in the spirit of the existing characterizations of quasi-series parallel and complete bipartite composite digraphs.This characterization allow us to obtain a O(|V G | 3 )-time algorithm to recognize if an acyclic digraph is Maltsev.Finally, an inductive construction of directed acyclic graphs preserved by a Maltsev operation is given.The main motivation behind this construction is that we suspect that extending this construction to n-permutable digraphs (2-permutable digraphs are precisely the Maltsev digraphs [18]) could make progress towards identifying all list homomorphism problems for digraphs in L. We note that in [16], an inductive construction of conservative n-permutable digraphs is key to the identification of all graphs whose LHOM is in L.

Algebra
We describe the algebraic definitions for digraphs, however, note that these definitions are straightforward to generalize to relational structures.Let G = (V G , E G ) and H = (V H , E H ) be digraphs.A homomorphism from G to H is a map f from the set of vertices of G, V G , to the set of vertices of H, V H , such that for every edge (u, v) ∈ E G we have that (f (u), f (v)) is an edge in H, that is (f (u), f (v)) ∈ E H .A digraph G is called a core if every homomorphism from G to itself is an automorphism, that is, a permutation on V G .Let G be a subgraph of G.We say that G retracts onto G if there is a homomorphism h : G → G such that h is the identity map on G .For a finite digraph H, we can then define CSP(H) as the class of all finite digraphs that admit a homomorphism to H An n-ary operation on a set A is a function f : A n → A. Given a digraph G and an n-ary operation f on V G , we say that f preserves G,

Graph Theory
Since all graphs in the paper are directed, we use the terms graph and digraph interchangeably.Throughout, all digraphs are assumed to be finite.
For a natural number n we write [n] = {1, 2, . . ., n}.An oriented path is a sequence of, not necessarily distinct, vertices v 1 , . . ., v n such that for every i ∈ [n − 1], either (v i , v i+1 ) (a forward edge) or (v i+1 , v i ) (a backward edge) is an edge.We use the terms path and oriented path interchangeably.A cycle is an oriented path with starting point v 1 and endpoint v m such that either (v m , v 1 ) or (v 1 , v m ) is an edge.The net length of a path P , net(P ), is the number of forward edges minus the number of backward edges in P .A dipath (reverse dipath) is a sequence of, not necessarily distinct, vertices v 1 , . . ., v n such that for every i ∈ ) is also an edge.For a (reverse) dipath P , we let len(P ) denote the number of edges in P .We use the term simple dipath or (directed) cycle to indicate that all vertices of the dipath or (directed) cycle are distinct.
A component of digraph G is a maximal subgraph, H, of G such that for every pair of vertices u, v ∈ V H , there is an oriented path from u to v. A digraph with one component is said to be connected.A digraph is a directed acyclic graph (DAG) if it contains no directed cycles.A DAG G is layered if there exists q ∈ N such that the vertices of G can be partitioned into q levels L 0 , . . ., L q−1 , such that any edge of G goes from L i to L i+1 , for some i = 0, . . ., q − 2.
Let G be a digraph, and x a vertex of G.We define For each vertex x of G and each k 1, we define The kth power of a graph, G, is a graph, G k , with the same set of vertices as G and an edge between two vertices u, v if and only if u 3 Retracts of Maltsev digraphs Definition 3.1.[totally rectangular] A digraph G is k-rectangular if the following implication holds for all vertices x, y, u, v: A digraph is rectangular if it is 1-rectangular, and totally rectangular if it is k-rectangular for every k ∈ N.
It is not hard to verify that a Maltsev digraph must be totally rectangular, and in Section 4 (see Corollary 4.11) we show that indeed the two properties are equivalent.
Example 3.2.The digraph in Fig. 1 is rectangular but not 2-rectangular.While the digraph in Fig. 2 is totally rectangular.The proof of Theorem 3.3 is a direct consequence of Lemma 3.10 below.We begin with some definitions and simple observations.Lemma 3.4.Let G be a digraph.Then G is layered if and only if for every pair of vertices u, v in G, and any pair of oriented paths P and Q from u to v, it holds that net(P ) = net(Q).Definition 3.5.Let G be a digraph that contains a directed cycle.Let C be a shortest directed cycle in G and assume it has length m.We say that G is inconsistent if there exist two vertices u, v in G such that, there are two different oriented paths of net lengths 1 and 2 from u to v such that 1 ≡ 2 mod m.Otherwise we say that G is consistent.Proposition 3.6.Let G be a connected digraph that contains a directed cycle.Let C be a shortest directed cycle in G. Then G retracts onto C if and only if G is consistent.
Proof.Assume that C has length m.If G is consistent, then choose an arbitrary vertex of C and label it with 0. Call this vertex s.For each vertex v ∈ G\s, find an oriented path P from s to v. Assume P has net length .Label v with the number mod m.Since G is consistent, this labeling is well defined.It is easy to see that the mapping that sends every vertex with label i to the vertex of C that has label i is a retraction of G onto C.
Conversely, assume that G retracts to C through a homomorphism h.Label every vertex v with h(v).It is not difficult to see that for any two vertices u and v of G such that there are two different (not necessarily simple) oriented paths of net lengths 1 and The following lemma relates total rectangularity with lengths of paths in a digraph.Lemma 3.7.Let G be a totally rectangular digraph and u, v be vertices in G. Let P and Q be two dipaths in G from u to v, such that len(P ) > len(Q).Set k = len(P ), = len(Q), and d = k − .Then one of the following two cases occurs: 1.If 2 > k, then G contains vertices u , v and dipaths P , Q from u to v with the following property: len(P ) = , len(Q ) = 2 − k, and len(P Proof.See Fig. 3.In the first case, let u be the vertex of P such that the subpath P u v of P from u to v has length .Let v be the vertex of P such that the subpath P uv of P from u to v has length .Applying the -rectangularity of G to P u v , Q, and P uv , we obtain the desired dipath P with len(P ) = .The other required dipath Q is the subpath of P from u to v .Since k = 2 − len(Q ) we have that len(Q ) = 2 − k, and len(P In the second case, the two paths P and Q form a cycle of length Definition 3.8.Let P be an oriented path.Let P 1 , . . ., P n be all maximal (with respect to length) directed subpaths of P , such that P i and P i+1 , i ∈ [n − 1] share a common vertex.We call P 1 , . . ., P n a directed path decomposition of P .We can obtain a directed path decomposition for oriented cycles in a similar way.Note that if an oriented cycle has two maximal directed subpaths, then these two subpaths share two vertices.Lemma 3.9.Let G be a totally rectangular digraph and u, v ∈ V G .Let P 1 and P 2 be oriented paths in G from u to v. Assume that net(P 1 ) > net(P 2 ), and set d = net(P 1 ) − net(P 2 ).Then there are vertices s, t ∈ V G and dipaths Proof.Consider the oriented cycle C formed by P 1 and P 2 .Let R 0 , . . ., R n−1 be a directed path decomposition of C, and assume that n 2. Find a shortest segment R i in the decomposition and assume it has length k.See Fig. 4. Then both R i−1 and R i+1 have length at least k, where i − 1 and i + 1 are considered modulo n.Assume without loss of generality that R i−1 and R i have the same endpoint b, and R i and R i+1 have the same We repeat this procedure until we obtain a cycle which has a directed path decomposition consisting only of two directed paths, Q 1 and Q 2 .Assume without loss of generality that Q 1 is longer than Q 2 .To see that net(Q 1 ) − net(Q 2 ) = d, observe that d is the difference of the forward and backward edges in C. Applying the above "shortcutting" procedure to C to obtain C does not change the difference of the forward and backward edges in C. To see this, observe that we take out 2k forward edges and k backward edges from C, and then we add back k forward edges to obtain C .Lemma 3.10.Let G be a connected totally rectangular digraph.If G is a DAG then G retracts onto a simple dipath.Otherwise G retracts onto a simple directed cycle.
Proof.Assume first that G is a DAG.We claim that G must be layered.Assume, for a contradiction, that G is not layered.By Lemma 3.4, there exist u, v ∈ V G and oriented paths P and Q from u to v, such that net(P ) = net(Q).Using Lemma 3.9, we can assume that P and Q are dipaths of different length.Now we repeatedly apply Case 1 of Lemma 3.7 as long as it is possible, and then applying Case 2 yields a cycle, a contradiction.So G is layered.
Assume that G has levels L 0 , . . ., L q−1 .Fix vertices s ∈ L 0 and t ∈ L q−1 , and let O be any oriented path from s to t (such a path exists because G is connected).Applying the total rectangularity of G to appropriate subpaths of O, it is easy to see that there exists a dipath D of length q − 1 from s to t in G. Clearly, G retracts onto D.
Suppose that G contains a directed cycle.By Proposition 3.6, it is enough to show that G is consistent.Assume this is not the case.Let C be a shortest directed cycle in G, and assume it has length m.Because G is inconsistent, we can find vertices u, v ∈ V G and oriented paths P 1 and P 2 from u to v, such that net(P 1 ) ≡ net(P 2 ) mod m.Set 1 = net(P 1 ) and 2 = net(P 2 ).Assume w.l.o.g. that 1 > 2 , and that u is a vertex of C. Note that if u is not a vertex of C, then we fix a vertex c of C and find any oriented path S from c to u.Then attaching S to P 1 and P 2 at vertex u gives us the desired oriented paths.Furthermore, we can assume that 1 − 2 = d < m, because if not, we can add the electronic journal of combinatorics 22(1) (2015), #P1.47 C-loops from u to u to P 2 to increase its length by a multiple of m, until 1 − 2 < m.Using Lemma 3.9 we obtain directed paths Q 1 and Q 2 such that len(Q 1 ) − len(Q 2 ) = d, and then, by applying Lemma 3.7, we obtain a cycle of length d in G, a contradiction.By Lemma 3.10, each connected component of G retracts either onto a simple dipath or to a simple directed cycle.The trivial observation that a dipath homomorphically maps to a cycle completes the proof of Theorem 3.3.

Rectangular Characterisations and Other Polymorphisms
In this section we generalise a technique of Kazda [22] to characterise digraphs that admit Maltsev and conservative Maltsev polymorphisms as those which are totally rectangular and universally rectangular respectively and to provide polynomial time algorithms for recognising the relevant properties.Furthermore, we show that Maltsev digraphs also admit many other polymorphisms, and under certain conditions, they also admit conservative 2-semilattice polymorphisms.Definition 4.1.[conservatively k-rectangular, universally rectangular] We say that a graph is conservatively k-rectangular if it satisfies the following sentence: A graph that is conservatively k-rectangular for all k 1 will be called universally rectangular.
In the presence of rectangularity, the relation R + is an equivalence relation on the set {x ∈ V G : x + = ∅}, the set of vertices of G that are not sinks.Additionally, the relation R − is an equivalence relation on the set {x ∈ V G : x − = ∅}, the set of vertices of G that are not sources.So it makes sense to consider the respective factor graphs, this was observed in [22].We use the notation G/R + to denote the graph on the R + -classes of G. Given R + -classes A, B, we write A → B if there is some a ∈ A and b ∈ B with a → b.Similarly, G/R − denotes the same construction, but using the relation R − .Note that G/R + is not strictly an actual graph quotient of G, only a quotient of an induced subgraph of G. Nevertheless, we sometimes refer to it as "the quotient of G by R + ". 1. G is -rectangular for all = 1, . . ., k if and only if G/R + is -rectangular for all = 1, . . ., k − 1.
Proof.The rectangularity of G ensures that G/R + is well defined.Consider some . This is equivalent to both the following properties holding: To prove the second statement, note that an instance of the premise in Definition 4.1 (1) in G/R + comes from an instance of the premise of conservative (k+1)-rectangularity in G. Then the path in G witnessing the conclusion of conservative (k + 1)-rectangularity provides a corresponding path in G/R + using the R + -classes of the vertices in the path.
For a totally rectangular graph G, define G 0 = G and G i+1 = G i /R + , i 1. From Lemma 4.4 it follows that G i is defined for all positive integers i, and eventually G i will either be empty or a disjoint union of directed cycles (the only situations that R + can be trivial).We define The next lemma is obtained by applying the Maltsev property to the columns of the premise of (1).Proof.We prove the second statement, the first being similar but easier.Consider an instance of the premise of k-rectangularity in some graph G with a conservative Maltsev polymorphism p.As p is a polymorphism, applying p to the columns yields a path The following lemma is key to the proof of Theorem 4.10.
However G is conservatively 2-rectangular so that there is either an edge from at least one of a, c to f or there is an edge from g to at least one of {b, c}.Then 1-rectangularity shows that either there is an edge from a to f or from g to b.
To give details of the proof of Theorem 4.10, it is useful to recall the following result, taken directly from [22].Lemma 4.7.Let G be a rectangular digraph.Then the following hold: 3. Whenever xR + y, we have x +1 = y +1 and x +1 is an equivalence class of R − .4. Whenever xR − y, we have x −1 = y −1 and x −1 is an equivalence class of R + .
5. The mapping φ : X → X +1 is a bijection from the set of equivalence classes of R + to the set of equivalence classes of R − and φ is an isomorphism from G/R + to G/R − .
We now give a technical lemma, present in [22]: Lemma 4.8.Let t + be a polymorphism on the graph G/R + , and let t − be the n-ary polymorphism defined by If t is an n-ary function on the vertices of G satisfies the following conditions then it is a polymorphism of G: the electronic journal of combinatorics 22(1) (2015), #P1.47 Proof.Note that t − is a polymorphism by Lemma 4.7 (5).The proof of the present lemma is given by Kazda [22, pp. 394-395] in the particular case where t + is known to be a majority polymorphism, however the proof makes no use of the arity, nor of the majority equations.
Remark 4.9.The following theorem makes use of an assumption that a system of term equalities is nontrivial (that is, that x ≈ y is not a consequence).In general such assumptions are not algorithmically verifiable, but it will be explained in the course of the proof why the particular form used in the assumption can always be satisfied on any set.Theorem 4.10.Consider a property C of digraphs defined either by a system of balanced equations, or by the existence of idempotent polymorphisms t 1 , t 2 , . . ., t k (not necessarily distinct) satisfying a single equational sequence where Proof.Our proof is very similar to the main proof in [22].We focus primarily on the conservative case (not considered in [22] which also only explicitly applies to majority equations), as the non-conservative case is obtained by following this proof and missing some steps (we give some pointers of the required omissions during the proof).There are two possible kinds of equations mentioned as determining the property C in the theorem statement: systems of balanced equations, and those determined by ( * ).In the proof to follow we refer to systems of balanced equations as equations of the first kind, while those of the form in ( * ) (a single family of k of equalities, with ≈ x) as equations of the second kind.We mention that in either case, C holds conservatively is the polymorphisms witnessing the defining equations are conservative.We define a notion of pattern for n-tuples.Let (x 1 , . . ., x n ) be an n-tuple of symbols, in which possibly some repeats occur.We say that an n-tuple (a 1 , . . ., a n ) agrees with the n-tuple (x 1 , . . ., x n ) if x i = x j implies a i = a j .We will make frequent agreement comparisons to the tuples appearing as arguments of terms in equations.
It is easy to see that if G has conservative property C then so does G/R + by defining t i (x 1 /R + , . . ., x n /R + ) = t i (x 1 , . . ., x n )/R + .Thus, it suffices to show that if G/R + satisfies C conservatively then so does G.This will be shown by backward induction over successive quotients by R + .This will be verified using Lemma 4.4 rather than the assumption of the Maltsev property directly, moreover instead of explicit use of universal rectangularity, the argument uses only the fact that on each successive quotient by R + , both rectangularity and the conclusion of Lemma 4.6 hold.
Assume that G/R + has conservative polymorphisms t + 1 , . . ., t + k witnessing C. Let t − i (x 1 , . . ., x n ) denote the operation given by φt + i (φ −1 (x 1 ), . . ., φ −1 (x n )).We show that one can construct conservative functions t G 1 , . . ., t G k on G, each satisfying the conditions stated in Lemma 4.8 and such that the equation sequence defining C holds.By Lemma 4.8, these are the desired family of polymorphisms witnessing C on G.
In the second kind of equation system (those defined by ( * )), the values of the t i are forced at many tuples: if (a 1 , . . ., a n ) agrees with the pattern (x i,1 , . . ., x i,n i ) (with x i,p = x), then t G i (a 1 , . . ., a n ) must equal a p .Idempotence may be considered as one such case: it forces t i (a, . . ., a) = a.Note that if some tuple is asked to take two different values under the same term symbol by this process, then this facilitates a proof of x ≈ y from ( * ), which we have assumed does not hold.Trivially, the reverse implication is true, which justifies the claim in Remark 4.9, for term conditions of this second kind.Note also that conditions (1) and ( 2) of Lemma 4.8 hold trivially for such tuples, because if (a 1 , . . ., a n ) agrees with the pattern (x i,1 , . . ., x i,n i ), then (a 1 /R + , . . ., a n /R + ) agrees with the pattern (x i,1 , . . ., x i,n i ) also, and so on.We observe that in this second kind of equation ( * ), the equations defining C are already guaranteed to hold at this point (and what remains is just ensuring they can be extended as polymorphisms to other tuples).
We now fix some arbitrary linear order G on the vertices V G and proceed to choose values for t G (a 1 , . . ., a n ) which have not so far been forced.Note that this is where the definition of the t G i begins in the case of equations of the first kind.Assume that one of a 1 , . . ., a n ∈ V G is a source.Choose the value of t G (a 1 , . . ., a n ) to be the smallest element a (under G ) of {a 1 , . . ., a n } such that a /R + = t + (a 1 /R + , . . ., a n /R + ).This implies that Condition (1) of Lemma 4.8 is satisfied for t G at the tuple (a 1 , . . ., a n ), while (2) is satisfied vacuously.(In the non-conservative case, we would simply take the smallest element of the R + -equivalence class t + (a 1 /R + , . . ., a n /R + ).) Dual statements hold if one of a 1 , . . ., a n is a sink.
Note that, given a /R + , the choice of element in the class a /R + is determined only by the set {a 1 , . . ., a n } and the fixed order G .Thus any balanced equation will hold at such tuples.This also justifies the claim in Remark 4.9 for term conditions of the first kind, as the construction just given can be applied to any set (treated as a graph with no edges, so that all tuples are sources) carrying a linear order, and clearly any set can be given a linear order.Now consider the case where none of the a 1 , . . ., a n are sources or sinks.We will show that the R + -class t + (a 1 /R + , . . ., a n /R + ) intersects the R − -class t − (a 1 /R − , . . ., a n /R − ) and that at least one of a 1 , . . ., a n lies in this intersection (this is the conservative part); this will be chosen as the value of t G (a 1 , . . ., a n ).
Since t + and t − are conservative functions we have t + (a 1 /R + , . . ., a n /R + ) = a l /R + for some l n and t − (a 1 /R − , . . ., a n /R − ) = a l /R − for some l n.We show that a l /R + ∩ a l /R − = ∅.Because any vertex u ∈ V G that is neither a source nor sink has u ∈ u/R + ∩ u/R − it suffices to consider the case where l = l .Now, as a i /R + ∩ a i /R − = ∅, for each i = 1, . . ., n, we have and therefore from which it follows that As a l /R + ∩ a l /R − = ∅, we may employ Lemma 4.6 to show that there is i n with a i ∈ a l /R + ∩ a l /R − .Choose t G (a 1 , . . ., a n ) to be the G -earliest amongst the a i ∈ a l /R + ∩ a l /R − .It is now trivial that properties 1 and 2 hold, which as observed already, ensures that the t G i are polymorphisms of G.We must show that the equations ( * ) hold for this case (or that balanced equations hold).The case labelled ( * ) (where ≈ x is assumed), has been established earlier in the proof, so we are considering here only systems of balanced equations.Consider an individual instance of a balanced equation t i (x i,1 , . . ., x i,n i ) ≈ t j (x j,1 , . . ., x j,n j ) in the list, where {x i,1 , . . ., x i,n i } = {x j,1 , . . ., x j,n j }.Now, the equations defining C hold at the level of t + i , t + j and t − i , t − j , so that the process just performed for selecting the value of t i and t j at a tuple without sources or sinks will always at least be made within the intersection of the same block of R + and block of R − .However the particular choice of element within this set was made only in terms of the order and the set {a 1 , . . ., a n }, which is uniform for both t i and t j .Thus equality at such tuples is verified.Some instances of polymorphisms satisfying the conditions of Theorem 4.10 are majority, Maltsev and Pixley.In these cases G ∞ always has the desired polymorphism, giving the following corollary.The above corollary yields an algorithm for verifying if a graph has a Maltsev (or Pixley) polymorphism.Indeed, the rectangularity of a digraph is equivalent to the following property of its adjacency matrix: when two rows (or two columns) share a common 1 they are identical.On an n-vertex digraph this property may be verified in O(n 3 ) steps.A digraph has a Maltsev polymorphism if and only if each (of at most n) successive quotient by R + is rectangular, with the process stopping once there are no R + -classes of size more than 1 (which happens after at most n quotients).Overall this takes O(n 4 ) steps (quadratic in terms of the size of the adjacency matrix).
Universal rectangularity (equivalently, the existence of a conservative Maltsev polymorphism) can also be verified in polynomial time by verifying total rectangularity and conservative 2-rectangularity at each successive quotient by R + .In fact, the proof of Theorem 4.10 is sufficiently constructive to construct the desired polymorphisms (when they exist): simply work backwards from their definition of G ∞ .

Conservative 2-Semilattice Polymorphisms
A disjoint union of directed cycles admits a conservative commutative binary (ccb) polymorphism (which coincide with conservative 2-semilattice operations) if and only if it contains no even cycles.This provides a case where Theorem 4.10 characterises a proper subclass of conservative Maltsev digraphs.In this section we classify Maltsev digraphs admitting a ccb polymorphism.A corollary of the result will be a sort of converse to Theorem 4.10: a Maltsev digraph with a ccb polymorphism is necessarily conservative Maltsev (Proposition 4.14 below).
Consider any digraph G and let * be any conservative commutative binary operation on V G .The operation * has an easy interpretation as a colouring of the nondiagonal elements of the cartesian square (The exclusion of the diagonal elements is only for convenience.)We now examine the consequences of * being a ccb polymorphism.
For any digraph G we define a structure-the ccb graph of G-on the nondiagonal elements of the cartesian square The ccb graph is a graph with two kinds of edges: "orienting" edges, which are directed, and "straight" edges which are considered as having no direction.
• A (directed) orienting edge is placed from (a 1 , b 1 ) to (a 2 , b 2 ) if there are parallel edges connecting each of the following pairs in G: a 1 and a 2 ; b 1 and b 2 ; and b 1 and the electronic journal of combinatorics 22(1) (2015), #P1.47 a 2 but not a 1 and b 2 .The following diagram depicts two situations that an orienting edge pointing from (a 1 , b 1 ) to (a 2 , b 2 ) can arise: • An (undirected) straight edge is placed from (a 1 , b 1 ) to (a 2 , b 2 ) if there are parallel edges connecting the following pairs: a 1 and a 2 ; b 1 and b 2 ; but not a 1 and b 2 or a 2 and b 1 .
A directed path in the ccb graph is a path of orienting edges and straight edges, in which each orienting edge is traversed in a forward direction.We now adopt the notation to denote directed paths: note that (a, b) (c, d) if and only if (d, c) (b, a).An important observation is: if (a, b) is not connected to (c, d) in the ccb graph of G then the compatibility of the ccb operation with the edges of G does not fail at the pairs (a, b) and (c, d).Thus the digraph G admits a ccb polymorphism iff the ccb graph of G can be coloured by L and R such that L and R are preserved across straight edges, L is preserved forward across orienting edges and R is preserved backward across orienting edges.Expressed in terms of this becomes the following rules.
In order to show that the existence of a colouring of a ccb-graph can be decided in polynomial time, we next consider a kind of a Möbius band.As the following example illustrates, we may think of a directed path connecting (a, b) to (b, a) in the ccb-graph of G as a kind of Möbius band of parallel edges in G. Proof.The forward implication is simply the statement that the colouring of the ccbgraph must colour each pair (a, b) oppositely to its reverse (b, a), and the colouring rules (L)(1)-(R)(2) must be obeyed.Now we show the converse: assume that for every a, b ∈ G, the ccb-graph of G does not contain a directed path from (a, b) to (b, a) and from (b, a) to (a, b).We construct (in a polynomial number of steps) a successful colouring by L and R, whence a ccb polymorphism.
First phase.Begin by finding any pairs (a, b) from which there is a directed path to the reverse pair (b, a) (necessarily it must contain an orienting edge, as otherwise there is a path from (b, a) to (a, b)).In every case, colour (a, b) by R and (b, a) by L. By assumption, no pair is coloured two different colours simultaneously.It might appear that the colouring rules might force the colouring of some further elements of G 2 , but in fact this is not the case as all potential applications of rules (L)( 1 Second phase.Now there may still be some uncoloured pairs.We are going to complete the colouring according to the following process which is to be repeated until all pairs are coloured (we show the process is well defined below): take any uncoloured pair, (a, b) say, and colour it arbitrarily; colour any other pairs for which rules (L)(1)-(R)(2) apply starting from (a, b).
We need to ensure that the second step is well defined, that is, that no pair (c, d) is forced to have been coloured two different colours simultaneously.Up to reversing everything, we can assume without loss of generality that at some stage a hitherto uncoloured pair (a, b) is given the colour L, and that (a, b) (c, d).There are two potential problems: (c, d) has already been coloured by R (that is, clashing with a previously assigned colour); or that the choice of colouring (a, b) by L itself also forces (c, d) to be coloured R (that is, (a, b) (d, c)).In either case, we get a contradiction with the assumption that (a, b) was uncoloured.In the first case, rule (R)(1) already forces (a, b) to be coloured R (either at some earlier iteration of the second phase, or if (c, d) was coloured at the first phase, then so was (a, b) coloured at the first phase).In the second case, (a, b) showing that (a, b) was coloured in the first phase.
Thus, eventually, the desired colouring (and ccb-polymorphism) is eventually achieved.
Note that the property in Theorem 4.13 can be verified using Reachability in the ccb-graph of G, so is solvable in nondeterministic logarithmic space.Hence deciding if a digraph has a ccb polymorphism is in NL too.d, c) in the ccb graph of G, there must be an edge between one of the following: {a, c} to h; {b, d} to e; g to {c, b}; or h to {a, d}.But then rectangularity forces either all edges from {a, b, c, d} and {e, h} or all edges from {g, f } to {a, b, c, d}.
It then follows, like in the proof of Theorem 4.10.
Note that the digraph in Fig. 2 is easily seen to admit a conservative majority polymorphism, a Maltsev polymorphism, but no conservative Maltsev polymorphism.So conservative majority cannot replace ccb in Proposition 4.14.

Maltsev DAGs
In this section all graphs will be acyclic, that is, DAGs.Recall that all DAGs preserved by a Maltsev polymorphism are layered and retract onto a simple dipath, see Theorem 3.3.

A simple inductive construction of Maltsev DAGs
In this section we provide a simple inductive characterisation of totally rectangular DAG.We note that in [22,Corollary 16] Kazda gives an inductive construction of Maltsev digraphs, however, this construction is not fully satisfying in the sense that it is nondeterministic, that is, it does not specify how to obtain the desired preimages, and it is not clear if it can be made deterministic.The construction described below, that only works for DAGs, consists of repeated applications of two straightforward steps (and their reverse versions) which clearly specify how to obtain a new Maltsev DAG from an already constructed one by a certain copying process.We need the following definitions.Definition 5.1.[(Reverse) arborescence] An (reverse) arborescence is a directed tree with root r such that every edge points away from (towards) r.An (reverse) arborescence is balanced if every (reverse) dipath from the root to a leaf has the same length.
the electronic journal of combinatorics 22(1) (2015), #P1.47 Definition 5.2.[∇(r, h) and ∆(r, h)] Let G be a digraph, r ∈ V G , and h ∈ N. ∇(r, h) (∆(r, h)) is defined to be the subgraph of G whose vertices and edges are the vertices and edges of all (reverse) sub-dipaths of G which have initial vertex r and length h.Let v be a vertex of ∇(r, h) (∆(r, h)) such that v = r.Then v is called an endpoint of ∇(r, h) (∆(r, h)) if there is a (reverse) dipath of length h from r to v. Otherwise v is called an inner vertex of ∇(r, h) (∆(r, h)).Definition 5.3.[isolated ∇(r, h)] Let G be a digraph.Consider ∇(r, h) (∆(r, h)) for some r ∈ V G and h ∈ N. We say that ∇(r, h) (∆(r, h)) is isolated in G if for every inner vertex v of ∇(r, h), both the in-neighborhood and the out-neighborhood of v belong to ∇(r, h) (∆(r, h)).
We are ready to define the construction formally in Fig. 6.This construction can be used, for example, to define a minority operation for a totally rectangular DAG.
1. C contains dipaths of all possible lengths n ∈ N 0 ; 2. C is closed under applying the following operations: (a) Given a digraph G, let r ∈ V G and h ∈ N such that ∇(r, h) is an arborescence.
Let ∇ be a copy of ∇(r, h).Join ∇ to G by identifying the corresponding endpoints of ∇ and ∇(r, h).Let the resulting graph be G ; (b) Given a digraph G, let r ∈ V G be such that r has exactly one incoming edge (p, r), and h ∈ N such that ∇(r, h) is an isolated arborescence.Let ∇ be a copy of ∇(r, h) with root r .Join ∇ to C by identifying the corresponding endpoints of ∇ and ∇(r, h), and adding the edge (p, r ).Let the resulting graph be G ; (c) The reverse version of Step 2a (defined in the natural way); (d) The reverse version of Step 2b (defined in the natural way).
3. M is the set of digraphs that can be obtained by taking disjoint unions of digraphs in C. and ∆(r, 2), which are the subgraphs to be copied and attached appropriately.
Reversing the argument of Lemma 5.10 reveals that if G is a totally rectangular DAG, then each component of G can be built using the construction in Figure 6 in a very structured manner.We make this restricted construction explicit in Figure 8. Construct every component C of G as follows: 1. Initially, C is a directed path of arbitrary length; (a) Using Step 2c of the construction in Figure 6, build an arborescence A.
(b) Choose a vertex layer L m such that each connected component of the subgraph between L 0 and L m is a balanced arborescence (notice that these arborescences must have their endpoints in L m ).
i. Choose an arbitrary q 0, and repeat the following q times.Choose a vertex v ∈ L k , where 0 k < m.Apply Step 2a of the construction in Figure 6 with ∇(v, m − k) to obtain a new graph.ii.Choose an arbitrary q 0, and repeat the following q times.Choose a vertex v ∈ L k , where 0 < k < m.Apply Step 2b of the construction in Figure 6 with ∇(v, m − k).iii.Choose an arbitrary q 0, and repeat the following q times.Choose a vertex v ∈ L k , where 0 < k < m.Apply Step 2c of the construction in Figure 6 with ∆(v, ), where (c) Either go back to Step 1b, choose L m with a larger m than previously and repeat, or finish the construction.We observe the following properties of this restricted construction.In Steps 1(b)i and ) is always a reverse directed path, and every vertex of F has precisely one in-neighbour.
We can now describe the class of totally rectangular DAGs.
Theorem 5.5.The class of totally rectangular DAGs is the set of digraphs M defined in Fig. 6.
Proof.Let G = (V G , E G ) be a layered digraph with levels L 0 , L 1 , . . ., L n .We define a natural order on the levels of G as follows: the level of G that the vertex u belongs to.The result then follows from Lemma 5.6 and Lemma 5.10 below.
Before stating Lemma 5.10 we need some auxiliary results.
Proof.We show the result assuming that G is connected, and the result follows.We show that applying a construction step to a totally rectangular digraph G yields a totally rectangular digraph G .Since a directed path is totally rectangular, this will prove the lemma.
Consider the case when G was obtained from G by an application of Step 2a attaching ∇ to G. Take any 4 distinct vertices a, b, c, d such that there are directed paths P ab from a to b, P cb from c to b, and P cd from c to d, each of some length .We show that there must be a directed path of length from d to a. Observe first that the construction has the property that there is no directed path from a vertex of G to a vertex of ∇ , and vice versa, except for the endpoints of ∇ (which are identified with the corresponding vertices of G).Let I be the common vertices of G and ∇ .We consider four cases: 1. Vertices a and c are in G. Then P ab , P cd , and P cb are subpaths of G, so the total rectangularity of G provides a directed path of length from a to d.

2.
Vertex a ∈ G and c ∈ ∇ .See Figure 9 for an illustration.Note that this is possible only if each path P ab , P cd , and P cb has a vertex u, v and w, respectively, in I. Let P cv denote the subpath of P cb from c to v, and P vb the subpath of P cb from v to b. Similarly define the subpaths P cw and P wd of P cd .Observe that by construction, P cv is a copy of a dipath P c v from a vertex c to v in G. Similarly, P cw is a copy of a dipath P c w from a vertex c to w in G.We have dipaths P ab from a to b, P c v P vb from c to b, and P c w P wd from c to d, each of length and fully inside G. Therefore we have a dipath of length from a to d.For the last two cases, an analysis fairly similar to the analysis of the second case can be done.Suppose now that G was obtained from G by an application of Step 2b of the construction.Let r, r , h, p, ∇(r, h), and ∇ be as in the definition of Step 2b.Take any 4 distinct vertices a, b, c, d such that there are directed paths P ab from a to b, P cb from c to b, and P cd from c to d, each of the same length .We show that d → a.If level(a) = level(c) level(r), then obviously, the same analysis works as for Step 2a.In addition, level(b) = level(d) > level(p) because otherwise all paths are fully inside G and the total rectangularity of G proves the claim.
Furthermore, there must be two (distinct) edges e 1 and e 2 among the edges of P ab , P cb P cd , such that e 1 is an edge in A = {∇(r, h) ∪ (p, r)} and e 2 ∈ B = {∇ ∪ (p, r )}.To see this, remove A from G to obtain the graph G, and observe that F is isomorphic to G. Assume then that there is no edge of P ab , P cb P cd in A. The total rectangularity of F yields the desired path from a to d.Because ∇(r, h) and ∇ are isolated and p is the only incoming edge of r and r , the only way that at least two of P ab , P cb P cd can be in A and B is if at least two of P ab , P cb P cd enters A and B through p.
If P ab and P cd both meet p, then we obviously have a dipath from a to d.If P ab and P cb meet at p then let P ap be the subpath of P ab from a to b, and P cp the subpath of P cb from c to p. Assume k = len(P ap )(= len(P cp )), and let Q be the subpath of P cd starting at c and taking the first k edges.Suppose the endpoint of Q is e.Then by the total rectangularity of G, there is a path of length k from a to e.This path from a to e and the subpath of P cd from e to d provides the desired path from a to d.
If P cb and P cd meet at p, then using the fact that G and F are isomorphic, we can assume w.l.o.g. that P cb passes through r and P cd passes through r .Let P r w be the subpath of P cd from r to an endpoint w.Because P r w is entirely in B, P r w is a copy of some dipath Q from r to w entirely in A and therefore entirely in G. Let P wd the subpath of P cd from w to d.Let P eb the subpath of P ab from e to b, where e is the vertex of P ab such that level(e) = level(r).Let P rb be the subpath of P cb from r to b.Then using the dipaths P eb , P rb , QP wd , we obtain a dipath R from e to d using the total rectangularity of G. Then following P ab up to e and then using R we obtain the desired dipath from a to d.
Lemma 5.7.Assume that G is a totally rectangular DAG, r is a vertex of G, and h ∈ N such that A = ∇(r, h) is an arborescence in G. Suppose that G contains a dipath P = v 0 , . . ., v h of length h such that v h is an endpoint of A, but P and A do not share any other vertices.Then A = ∇(v 0 , h) is isomorphic to A through an isomorphism ϕ, such that ϕ is the identity map on the endpoints of A .Furthermore, A and A share only the endpoints.
Proof.The proof is by induction on the height h of A. When h = 1 the result trivially follows from the assumption that G is totally rectangular.Assume that h > 1. Remove the root r of A to obtain sub-arborescences A 1 , . . ., A s , each of height h − 1, and with roots r 1 , . . ., r s , respectively.Fix an arbitrary endpoint e i for each A i .Once the following the electronic journal of combinatorics 22(1) (2015), #P1.47 By the choice of u and v, there is no vertex pair u , v in ∇(w 1 , m) such that there is more than one dipath from u to v .Therefore ∇(w 1 , m) is an arborescence.To see that ∇(w 1 , m) is in fact an isolated arborescence, assume for contradiction that there is an edge (s, t) such that t is an inner vertex of ∇(w 1 , m) and s ∈ ∇(w 1 , m).Then t is also an inner vertex of ∇(r, h), and because ∇(r, h) is isolated, s must be in ∇(r, h).This implies that ∇(r, h) contains some vertex s such that there are at least two directed paths from s to t.By Proposition 5.8, this would contradict the choice of g because ∇(r, g) is an arborescence.Similarly, ∇(w 1 , m) is an isolated arborescence in G.By a similar argument, w 1 or w 2 has only the in-neighbour u.
Using the subpath w 1 , . . ., w m , v of Q and Lemma 5.7, we obtain that ∇(w 1 , m) is isomorphic to ∇(w 1 , m).Let G s be the graph obtained from G be removing ∇(w 1 , m) (but not the endpoints) and the edge (u, w 1 ) (but not u).It is clear now that we can use Step 2b of the construction to obtain G from G s .
To complete the proof, we argue that G s is totally rectangular.Assume that there are directed paths of length k from a to c, a to d and b to d in G s (and therefore in G), but not from a to d in G s .Let the path from a to d in G be P .Clearly, some part of P must be removed in G s .If there is a directed path from a to u or a = u, and there is a directed path from an endpoint of ∇(w 1 , m) to d or if d is such an endpoint, then going through ∇(w 1 , m) instead of ∇(w 1 , m) gives a path of length k from a to d. Suppose therefore that there is no path from a to u and a = u (the other case is similar).Since ∇(w 1 , m) is isolated, and the only in-neighbor of w 1 is u, if a is not a vertex of ∇(w 1 , m) (except for the endpoints), then P does not go through any removed part of the graph, and therefore P is unaffected by the removal.Thus, a is must be a vertex of ∇(w 1 , m) that is not an endpoint, and therefore a is not in G s , a contradiction.Lemma 5.10.Let G be a totally rectangular DAG.Then each component of G can be built using the construction in Fig. 6.
Proof.Without loss of generality, we assume that G has only one component.By Theorem 3.3, G retracts onto a directed path of some length n.We show that if G is not a dipath, then we can always define a totally rectangular DAG (which has one component) such that G is smaller than G and an application of a step of the construction gives G from G .Let L 0 be the bottommost vertex level of G (i.e., the vertex level that contains only sources).( ) Let L i be the first level above L 0 such that it contains a vertex w which has at least two in-neighbours.Consider the induced subgraph of G between L 0 and L i and call it H.
Case 1: H contains a sink that is not in L i .Let t be such a sink with the smallest possible level.By the choice of w, t has precisely one in-neighbour.Find a shortest reverse directed path P from t to a vertex c such that c has at least two out-neighbours.To see that such a vertex exists, observe that there is an oriented path Q from t to w because G is connected.Since t is a sink, the first edge of Q is a backward edge.As we follow the vertices of Q, eventually we must meet a forward edge because level(t) < level(w).
Set = len(P ).Since c has at least two out-neighbours, there is a dipath R starting at c and distinct from P .We can choose R with length because t is a sink closest to L 0 .Every vertex of R must have in-degree one by the choice of w.Furthermore, P and R shares only the vertex c because otherwise the choice of w would be violated.Let the endpoint of R be t .Remove P from G to obtain G .Then clearly, G is connected, totally rectangular, and we can obtain G back from G by applying Step 2c with ∆(t , ).Repeating this argument if necessary, we can assume that H contains no sinks except in L i .
Case 2: H contains no sinks except in L i .Suppose that there is a source s in H such that level(s) = L i−k and ∇(s, k) is not an arborescence.Observe that by the choice of L i , ∇(s, k) is isolated, and therefore using Lemma 5.9, we can obtain a smaller graph G such that we can get back G from G by applying Step 2b.Repeating this argument if necessary, we can assume that for any source s of H, ∇(s, •) is an arborescence.(Also note that we can still assume that H contains no sinks except in L i .) Therefore if there is a connected component C of H that is not an (balanced) arborescence, then C must have more than one sources.Let s and s be such sources, and assume WLOG that level(s) level(s ).Since C is connected, there is a directed path P of some length from s to an endpoint e of the arborescence A s rooted at s. Let r be the unique vertex of A s such that there is a directed path of length from r to e. Then if G is the graph obtained from G by removing ∇(s , ) (except for the endpoints), then we can get back G from G by applying Step 2a of the construction with ∇(r, ) of G .Repeating this argument if necessary, we can assume that any connected component of H is an (balanced) arborescence such that all endpoints are in L i .
If G contains a vertex that has indegree at least 2, then we jump back to ( ) and repeat the whole argument.Notice that when we choose L i , i will increase.If all vertices of G have indegree 1, then G is an arborescence, and it can be easily constructed starting with a directed path and repeatedly applying Step 2c.

Connections with series parallel digraphs
The class of series parallel digraphs, or series parallel orders, and several modifications of these, such as generalized series parallel (GSP) digraphs, have been widely studied since the 70s.They not only can be used to model series and parallel circuits but also can be applied to scheduling problems, and are interesting from a computational point of view, since several problems that are NP-hard in general, can be solved efficiently when restricted to this class of digraphs.We refer the reader to [24] for a survey on some computational and structural properties of these digraphs.We will focus on generalisations of series parallel digraphs, and relate DAGs admitting Maltsev and conservative Maltsev polymorphisms with these classes of graphs.We start with some definitions.
We say that a digraph G is N -free if for any four distinct vertices of G, x, y, u, v, we have A digraph G t is said to be a transitive reduction of the digraph G if (i) G t has a directed path from vertex u to vertex v if and only if G has a directed path from vertex u to vertex v, and Theorem 5.12.
[24] Given a DAG H = (V, E), the following are equivalent: 3. H is the transitive reduction of an N -free partial order; 4. H is rectangular.
Clearly all Maltsev DAGs are CBC but the reverse is not true, the DAG in Fig. 1 is an example of a CBC that is not Maltsev.In fact a characterization in terms of series parallel constructions for Maltsev DAGs eluded us, even though the characterization of Maltsev DAGs in terms of neighbourhoods is a natural generalization of the characterizations given above.Also, we can think of a characterization of Maltsev DAGs in terms of CBC, in the sense that a DAG is Maltsev if and only if every power of it is CBC, indeed we have: Theorem 5.13.Given a DAG H = (V, E), the following are equivalent: 1. H admits a Maltsev polymorphism; 2. for every n 1, the DAG H n is CBC, that is, H is totally rectangular; 3. H is layered and for any u, v ∈ V on the same level, we have, for all k 1 either u ±k = v ±k or u ±k ∩ v ±k = ∅; 4. H can be obtained from a dipath as described in Fig. 6.
Proof.The fact that (1) ⇔ (2) was seen in Lemma 4.5, and Theorem 5.5 says that (1) ⇔ (4).We now show that (2) ⇔ (3).Assume that (3) holds, and let x, y, u, v ∈ V be such that there exists k > 0 such that x k → u, y k → u and y k → v.It follows that x k ∩ y k = ∅, so we must have x k = y k .Hence x k → v, and so H is totally rectangular.Assume now that H is totally rectangular.From Theorem 3.3 we know that H is layered.Let k > 0 be arbitrary, and u, v ∈ V be such that u and so u k ⊆ v k .Similarly we can show that v k ⊆ u k , and so u k = v k .The case when k < 0 can be dealt with similarly, and we can conclude that (3) holds.
Figure 10: A DAG that is not Maltsev nor QSP, and a conservative Maltsev DAG that is not MSP.
If we restrict ourselves to DAGs that admit a conservative Maltsev polymorphism, then a simpler characterization of these can be obtained.It is not hard to see that all MSP DAGs admit a conservative Maltsev, but the reverse is not true, the DAG on the right-hand side of Fig. 10 admits a conservative Maltsev but is not MSP.In fact, to obtain a characterization of DAGs with conservative Maltsev polymorphism we just need to allow a small generalisation of the construction of MSPs.
Definition 5.14.The class of Quasi-Minimal Series Parallel DAGs (QMSP) is the class of DAGs obtained recursively as follows: • the DAG having a single vertex and no edges is QMSP; ) and H 2 = (V 2 , E 2 ) and QMSP, then so are the DAGs obtained from H 1 and H 2 , by applying the following operations: parallel composition, and , where L 1 is a subset of the set of sinks on the last level of H 1 , and F 2 is a subset of the set of sources on the first level of H 2 .
We finally give a characterization, similar to the ones presented earlier, of DAGs admitting a conservative Maltsev polymorphism.
Before proving the theorem, we need the following two lemmas.
Lemma 5.16.Let H be a connected DAG that admits a conservative Maltsev polymorphism.There exists i 0 such that all vertices of H on levels i, i + 1 that are neither sources on level i + 1, nor sinks on level i, form a complete bipartite graph.
Proof.Recall that H is layered, and assume that it has levels 0, . . ., n.The proof is by induction on n.If n = 0 then the result trivially holds.Assume now that the statement is true for all connected DAGs admitting a conservative Maltsev polymorphism, and with at most n − 1 levels.Since H is preserved by a conservative Maltsev polymorphism, the subgraph H induced by the vertices on levels 0, 1, . . ., n − 1 of H, also admits a conservative Maltsev polymorphism.If H is connected then the result follows by the inductive hypothesis.So, assume now that H is not connected.Let H 1 , H 2 be two connected components of H .These components must be connected by an element on level n in H, since H is a connected DAG.Let a be an element of level n of H that connects these components.If H only has one element on level n, then it follows that the vertices of H on levels n − 1 and n form a complete bipartite DAG, so we assume now that there is at least another element, say b, on level n of H and, for a contradiction, assume that a −1 ∩ b −1 = ∅.We can assume, without loss of generality, that b is connected to H 2 .So we have that there exist distinct elements v, v belonging to H 2 and on level n − 1 of H (that is, on the top level of H 2 ) such that (v, a), (v , b) are arcs of H. Since H 2 is connected, there exists an element p in H 2 , say on level k < n − 1 of H, such that p n−1−k −→ v and p n−1−k −→ v .Choose p such that these paths are distinct (that is, p is there only common vertex) and as short as possible.This means that v, v meet in p and do not meet earlier, and consequently the levels of H 2 that form the complete bipartite DAG (which we know exist by the inductive hypothesis) appear below level k of H.If H has no elements on level k that belong to the connected component H 1 then the DAG H 1 ∪ H 2 ∪{a, b} has a complete bipartite induced subgraph on the same levels as H 2 , indeed the same complete bipartite component.If this is the case we just need to deal with other remaining connected components and elements on level n of H in the same way, which proves the claim.
So, assume now that H has an element on level k, say q, that belongs to H 1 , so there is a vertex u on H 1 such that (u, a) is an arc of H and q Since H admits a conservative Maltsev polymorphism there exists a path of length n − k from q to b using only the elements on the paths from q to a, p to a and p to b.Since H 1 and H 2 are disconnected, we must have that this path is all in H 1 up to level n − 1 and so (u, b) must be an arc of H, which contradicts the fact that a −1 ∩ b −1 = ∅.
Thus it follows that a −1 = b −1 , that is, a −1 × {a, b} forms a complete bipartite DAG, on levels n − 1 and n.This can clearly be extended to more connected components of H and other elements on level n, which proves the claim.Lemma 5.17.If a DAG H admits a conservative Maltsev polymorphism then it is QMSP.
Proof.Let H be a DAG, and assume that it has a conservative Maltsev polymorphism.We then know that it retracts to a directed path of some length, say n + 1, and so we know that the vertices of H can be placed into levels 0, 1, . . ., n, in such a way that edges are placed between consecutive levels.
We show that H can be obtained from the one vertex and no edges graph, by a sequence of parallel and quasi-series constructions.Clearly all connected components are with a program of width (1,2).If no such walk exists, then we still have to check that every walk from a vertex to itself has net length 0. This can be easily done with a program of width (2,3), similar in spirit to the program above.
The list homomorphism problem for a digraph H, LHOM(H), is the following decision problem.Given an input digraph G and for each vertex v ∈ V G a list L v ⊆ V H , determine if there is a homomorphism h from G to H such that for each v ∈ V G , h(v) ∈ L v .This problem is exactly CSP(H u ) where H u is the structure obtained by expanding the digraph H with unary relations U , where U runs through all non-empty subsets of V H . Using Corollary 4.11, the following corollary is easy to deduce.Corollary 6.2.The complement of LHOM(H) for a conservative Maltsev digraph H can be defined in symmetric Datalog, and therefore LHOM(H) is in L.
Proof.Let H be the digraph in the corollary.Assume the conservative Maltsev polymorphism is mal.Then by Corollary 4.11, H also has a conservative majority polymorphism maj.Since mal and maj are conservative, they preserve any unary relations.Construct B from H as above.Then mal and maj is also a polymorphism of B. If a relational structure has a Maltsev and a majority polymorphism, then it is in symmetric Datalog by results of [12,11] (see also [14]).

Lemma 4 . 5 .
Let G be a digraph.1.If G has a Maltsev polymorphism, then G is totally rectangular.2. If G has a conservative Maltsev polymorphism, then G is universally rectangular.the electronic journal of combinatorics 22(1) (2015), #P1.47

Lemma 4 . 6 .
Let a, b be vertices in a totally rectangular digraph G satisfying conservative 2-rectangularity and assume that neither a nor b is a source or sink.If a

Corollary 4 . 11 .Remark 4 . 12 .
Let G be a digraph.1.G admits a (conservative) Maltsev polymorphism iff it admits a (conservative) Pixley operation iff it is totally (universally) rectangular.2.If G is totally (universally) rectangular then G admits a (conservative) minority polymorphism and a (conservative) majority polymorphism.The first part of Corollary 4.11 strengthens the result given in Lemma 4 of[13], for the case of digraphs.The relational clone B of a structure B is the set of all relations that can be expressed with primitive positive first-order formulas (that is, only existential quantification, conjunction, and equality is allowed) from B. When we restrict[13, Lemma 4]  to digraphs, it can be stated as follows: A digraph G is preserved by a Maltsev operation iff every binary relation in G is rectangular.It is easy to see and well known that every binary relation in G can be expressed as B G (S, a, b) = {(h(a), h(b))|h is a homomorphism from S to G} for a structure S with two distinguished vertices a and b.Then Corollary 4.11 implies that for a digraph G to be preserved by a Maltsev operation it is enough to require that only those binary relations in G that can be expressed as B G (S, a, b), where S is a directed path with initial vertex a and terminal vertex b, are rectangular.
in the ccb-graph of G) Theorem 4.13.A digraph G admits a ccb polymorphism * if and only if for every distinct a, b ∈ G, the ccb-graph of G does not contain a directed path both from (a, b) to (b, a) and from (b, a) to (a, b).When a ccb polymorphism exists, it can be constructed in a polynomial number of steps.the electronic journal of combinatorics 22(1) (2015), #P1.47 )-(R)(2) are between elements already consistently coloured by this first phase.For example, say that (c, d) (a, b), with (a, b) coloured R because of (a, b) (b, a).Then, while (R1) would force (c, d) to be coloured by R, we already have (b, a) (c, d), giving (c, d) (a, b) (b, a) (d, c).Hence (c, d) was already coloured by R. (The other cases are equivalent, up to reversing.)

Proposition 4 . 14 .Claim 4 . 15 .
The following are equivalent for a Maltsev graph G:1.G has a conservative commutative idempotent binary polymorphism; the electronic journal of combinatorics 22(1) (2015), #P1.472.G has a conservative commutative idempotent binary polymorphism and a conservative Maltsev polymorphism;3.G has a conservative Maltsev polymorphism and G ∞ is empty or has no even length cycles.Proof.(2)⇒(3)⇒(1) follow from Theorem 4.10, because a disjoint union of directed cycles has a ccb iff it has no even length cycles.For (1)⇒(2) we use Theorem 4.13 to prove a version of Lemma 4.6 with conservative 2-rectangularity replaced by ccb.Indeed we have: Let a, b be vertices in a totally rectangular digraph G admitting a ccb polymorphism and assume that neither a nor b is a source or sink.If there is c ∈ a/R + ∩b/R − then either b ∈ a/R + or a ∈ b/R − .Proof.The assumptions on a and b lead to the existence of not-necessarily distinct points a, b, c, g, e, f , g with at least the edges given in Figure 2. Total rectangularity ensures the existence of d.If c = d we are done.Otherwise, as there can be no path of straight edges connecting (c, d) to (

Figure 6 :Example 5 . 4 .
Figure 6: Inductive construction of the set M of totally rectangular DAGs.Example 5.4.Consider the totally rectangular DAG G in Fig. 7. To construct it using the method in Fig. 6, we start with the dipath G and first apply Step 2a to G to obtain G .Next we apply Step 2d to G obtain G .The thick edges indicate the subgraphs ∇(r, 2)and ∆(r, 2), which are the subgraphs to be copied and attached appropriately.

Figure 7 :
Figure 7: Construction of a totally rectangular DAG.

3 . 4 .Figure 9 :
Figure 9: Left: Vertex a ∈ G and c ∈ ∇ in analysis of Step 2a.Right: The case when P cb and P cd meet at p in the analysis of Step 2b.