Associative spectra of graph algebras I

Associative spectra of graph algebras are examined with the help of homomorphisms of DFS trees. Undirected graphs are classified according to the associative spectra of their graph algebras; there are only three distinct possibilities: constant 1, powers of 2, and Catalan numbers. Associative and antiassociative digraphs are described, and associative spectra are determined for certain families of digraphs, such as paths, cycles, and graphs on two vertices.


Introduction
Associativity is a fundamental property of binary operations, and one tends to take it for granted, since the most frequently encountered operations are associative. However, there are also many noteworthy operations that are not associative, such as subtraction, cross product of vectors, implication, just to name a few. For a systematic study of phenomena related to (non)associativity, one may consider an arbitrary nonempty set A together with a binary operation x · y on A. Let us emphasize that we denote the operation as multiplication only for notational convenience; the operation can be any map A × A → A, (x, y) → x · y. This yields the algebraic structure A = (A; ·), called a groupoid. (Note that the term groupoid has a different meaning in category theory.) Given such a groupoid, there are several ways of measuring how far our operation is from being associative. For finite A, a natural "measure of nonassociativity" is the number of triples (a, b, c) ∈ A 3 such that (a ·b)·c = a ·(b ·c). This notion was studied by A. C. Climescu [5] as early as 1947, and later by T. Kepka and M. Trch in a long series of papers starting with [11]. Another option is to count the minimum number of changes one has to make in the operation table in order to make it associative [12].
B. Csákány suggested a third method, namely to look at how many of the identities that are consequences of associativity are (not) satisfied. If the operation is associative, then there is no need to use parentheses in a product x 1 · x 2 · . . . · x n , as the result will be the same anyway, but if the operation is not associative, then one must insert n − 2 pairs of parentheses in order to make the product unambiguous. The Catalan numbers C n−1 = 1 n 2n−2 n−1 give the number of ways of inserting parentheses (or round brackets) meaningfully, and each such bracketing induces an n-variable function A n → A. For associative binary operations, all these n-ary functions will be the same, but for arbitrary operations we may get as many as C n−1 functions. The associative spectrum of A is the sequence {s n (A)} ∞ n=1 that counts the number of different n-ary functions on A arising from bracketings of the product x 1 · x 2 · . . . · x n . If A is a semigroup (i.e., if x · y is associative), then s n (A) = 1 for all n ∈ N, and intuitively we can say that the faster the spectrum grows, the less associative the operation is.
The associative spectrum was introduced in [7], and some basic properties and many examples of associative spectra were presented. In particular, it was shown that the cross product and the implication have a Catalan spectrum; hence, they are as nonassociative as a binary operation can be. We shall call such operations (groupoids) antiassociative. The associative spectrum of the subtraction operation is given by s n = 2 n−2 ; thus, subtraction is somewhere between being associative and antiassociative. Examples of groupoids with constant and linear spectra were also given in [7]; furthermore, in [14] groupoids with polynomial spectra of arbitrary degrees were constructed. It was also proved in [14] that there exist a continuum of different associative spectra (allowing infinite base sets, of course). Similar questions were investigated in [2][3][4], where some of the earlier results were rediscovered (with a different terminology).
In this paper, we study associative spectra of certain binary operations associated to graphs, which may be finite or infinite. Let us define a "multiplication" on the vertices of a graph as follows: let u · v = u if there is an edge from u to v and let u · v = ∞ otherwise (here ∞ is an external absorbing element). We define the arising graph algebras more precisely in Sect. 2, where we also present the required background on bracketings and spectra.
For undirected graphs, we obtain a full description of all possible associative spectra in Sect. 3. It turns out that there are only three possibilities: we have either s n = 1, s n = 2 n−2 or s n = C n−1 . Note the sharp contrast between this result and the abundance of different (growth rates of) spectra presented in [7,14]. In Theorem 3.3, we also give explicit characterizations of undirected graphs corresponding to each of the three spectra.
We determine antiassociative digraphs in Sect. 4; this together with the description of associative digraphs [15] gives us at least a picture about the two extrema of the spectrum(!) of associative spectra of digraphs. Finally, in Sect. 5 we compute the associative spectra of some concrete graphs such as cycles and paths, and we also determine the spectra of graphs on two vertices. A more detailed analysis of the associative spectra of general digraphs will be a topic of a forthcoming paper.

General notation
We denote by N and N + the set of nonnegative integers and the set of positive integers, respectively.

Directed graphs
By a directed graph (or digraph or simply graph), we mean a pair G = (V , E), where V = V (G) is a nonempty set of vertices and E = E(G) ⊆ V 2 is a set of edges (or the edge relation).
If e = (u, v) ∈ E, then we say that e is an edge from u to v, and we sometimes denote this by u → v. In this case, we also say that u is an inneighbour of v and v is an outneighbour of u. The outneigbourhood of a vertex u ∈ V (G), denoted by N G o (u), is the set of all outneighbours of u in G. The concept of inneighbourhood is defined analogously. An edge of the form (u, u) is called a loop (on u) and sometimes denoted by u .
A walk of length from u to v in G is a sequence v 0 , . . . , v of (not necessarily distinct) vertices such that v 0 = u, v = v, and there is an edge from each vertex to the next one (except for the last vertex, of course): v 0 → v 1 → · · · → v . If v 0 = v , then we say that the walk is closed. A path (cycle) is a (closed) walk in which the vertices are pairwise distinct (with the exception of the first and last vertex in case of a cycle). A digraph without cycles is called acyclic.
We say that a vertex u is reachable from v if there exists a walk (equivalently, a path) from v to u. A pair of vertices u and v is said to be strongly connected if each one of u and v is reachable from the other. The relation of being strongly connected is an equivalence relation, and the induced subgraphs on its equivalence classes are called the strongly connected components of G. A digraph is strongly connected if it has just one strongly connected component. A one-vertex graph with no edge is strongly connected (let us call this the trivial strongly connected graph); apart from this trivial example, every vertex of a strongly connected digraph is contained in a cycle of nonzero length (this includes the graph of one vertex with a loop on it).
A digraph with a symmetric edge relation is called an undirected graph. The strongly connected components of an undirected graph are called connected components. The underlying undirected graph of a digraph G = (V , E) is the undirected graph (V , E ), where the edge relation E equals the symmetric closure of E.
A tree is an undirected graph in which any two vertices are connected by exactly one path. A rooted directed tree is a directed acyclic graph whose underlying undirected graph is a tree and that has a distinguished vertex, called the root, from which all vertices are reachable. Let v be a vertex of a rooted directed tree T . Unless v is the root of T , it has a unique inneighbour, which is referred to as the parent of v. The outneighbours of v are called children of v. A childless vertex is called a leaf. The vertices reachable from v are called descendants of v, and v is called an ancestor of any of its descendants. The rooted induced subtree of T rooted at v, denoted by T v , is the subgraph of T induced by v and all its descendants.
The depth of a vertex v in a rooted directed tree T is the length of the (unique) path from the root to v, denoted by d T (v). (Thus the root has depth 0.) The height of the tree T , denoted by h(T ), is the maximum of the depths of its vertices:

Graph algebras
Graph algebras were introduced by Shallon [17]. We associate any digraph G = (V , E) with an algebra A(G) = (V ∪ {∞}; •, ∞) of type (2, 0), where ∞ is a new element distinct from the vertices, and the binary operation is defined by the following rule: for any x, y ∈ V ∪ {∞}, The algebra A(G) is called the graph algebra of G. Graph algebras provide a simple encoding of graphs as algebras, and using this encoding, the algebraic properties of the graph algebra A(G) can be seen as properties of the graph G itself. We are particularly interested in the satisfaction of identities by graph algebras. Recall that a term is, informally speaking, a well-formed string comprising variables and function symbols from the language of algebras under consideration. An identity is an ordered pair (t, t ) of terms, usually written as t ≈ t . An algebra A satisfies an identity t ≈ t if for all assignments of values to the variables occurring in t and t , the two terms get the same value when the function symbols are interpreted as the fundamental operations of A. An identity t ≈ t is trivial if t = t . Trivial identities are clearly satisfied by all algebras (of the given type). For further details, see, e.g., [9].
Let t be a term in the language of graph algebras. Denote by var(t) the set of variables occurring in t and by L(t) the leftmost variable occurring in t. We say that t is trivial if it contains an occurrence of the constant symbol ∞; otherwise, t is nontrivial. Nontrivial terms are thus just groupoid terms. To any nontrivial term t, we can associate a digraph The following result is very helpful for determining whether a graph algebra satisfies an identity.
Let t and t be nontrivial terms in the language of graph algebras, and assume that var(t) = var(t ) and L(t) = L(t ). Then the following conditions are equivalent:

Associative spectra
Let B n denote the set of bracketings of size n, i.e., groupoid terms obtained from the string x 1 · x 2 ·. . .· x n by inserting parentheses appropriately. The number of bracketings of size n is given by the Intuitively, the faster the associative spectrum grows, the less associative the operation is considered. A groupoid A is a semigroup if and only if s n (A) = 1 for all n ∈ N. On the other extreme, we have the antiassociative groupoids whose associative spectrum is given by the Catalan numbers: s n (A) = |B n | = C n−1 . These groupoids do not satisfy any nontrivial identity of the form t 1 ≈ t 2 with t 1 , t 2 ∈ B n .
Since there exists only one bracketing of size 1, namely x 1 , and of size 2, namely (x 1 x 2 ), it is clear that s 1 (A) = s 2 (A) = 1 for every groupoid A. Therefore, we may always assume that n ≥ 3 when we consider bracketings of size n or the n-th component of an associative spectrum.

DFS trees
It turns out that the graphs associated with bracketings are particularly nice; they are rooted directed trees of a very special form.

Definition 2.2
A DFS tree of size n is a rooted directed tree T on the vertex set X n := {x 1 , x 2 , . . . , x n } that has root x 1 and for every vertex x i ∈ X n , the induced The name "DFS tree" stems from the fact that the vertices are labelled in an order in which they may be discovered by the depth-first search (DFS) (see [6,Section 22.3]) starting from the root. Figure 1 shows the DFS tree G(t) of size 8 that corresponds to the bracketing t = ((x 1 ((x 2 x 3 )x 4 ))x 5 )(x 6 (x 7 x 8 )). The dotted line shows the walk traversed by the depth-first search (using the convention that the search continues always with the leftmost unvisited child). Note that the order of first occurrence of the vertices along this walk is x 1 , x 2 , . . . , x 8 . Proof (i) ⇒ (ii): Assume that T satisfies condition (i). Condition (ii) will follow if we prove that for each vertex x i ∈ X n , the vertices of the rooted induced subtree T x i (by our assumption V (T x i ) = X [i,i ] for some i ≥ i) may be traversed by the depthfirst search in the order x i , x i+1 , . . . , x i . We proceed by induction on the height of subtrees. The claim obviously holds for rooted induced subtrees of height 0. Assume that the claim holds for rooted induced subtrees of height at most k, and let x i ∈ X n be a vertex such that h( By the induction hypothesis, the vertices of T x is may be traversed by the depth-first search in the order x i s , x i s +1 , . . . , x i s ; consequently, the vertices of T x i may be traversed in the order Assume that T satisfies condition (ii). For any x i ∈ X n , x i is the first vertex in T x i visited by the depth-first search, all vertices of T x i are traversed before the depth-first search continues with vertices not belonging to T x i , and once the depthfirst search leaves the subtree T x i , it will never return to it. Consequently, condition (i) clearly holds.
It is a well-known fact that a digraph G is isomorphic to G(t) for some term t if and only if G is finite and rooted, i.e., there exists a vertex from which every vertex of G is reachable (see Kiss [13], Lemma 2). For the digraphs associated with bracketings, we obtain a sharper result: bracketings of size n are in a one-to-one correspondence with DFS trees of size n.

Lemma 2.4 Let n ∈ N.
(a) For any bracketing t ∈ B n , the graph G(t) is a DFS tree of size n. (b) Conversely, for every DFS tree T of size n, there is a unique bracketing t ∈ B n such that G(t) = T .
Proof (a) Let t ∈ B n . Then G(t) is a graph on X n by definition. We will prove by induction on the structure of terms that for every subterm t of t, the graph G(t ) is a directed tree on var(t ) with root L(t ) such that for every x i ∈ var(t ), the subtree of G(t ) rooted at x i has vertex set of the form X [i,i ] for some i ∈ [n] with i ≥ i. The claim obviously holds for any subterm of the form t = x i ∈ X n . Let now t = (t 1 • t 2 ) and assume that the claim holds for the subterms t 1 and t 2 .
; by the induction hypothesis, the subtree has the desired form.
(b) For the purpose of this proof, we relax the notions of bracketing and DFS tree so as to allow variable or vertex sets of the form X [a,b] . Let a, b ∈ N with a ≤ b, and let n : . , x i be the children of the root vertex x a , and assume that i bracketing and it is easy to see that G(t) = T because L(r ) = x a and L(s) = x i . This proves existence. As for uniqueness, assume t is another [a, b]-bracketing such that Observe that t contains no subterm of the form (r • s ) • s (otherwise L(s ) =: x p would be a child of x a with p > i , contradicting the choice of i ). Consequently var(s ) = X [i ,b] , so G(s ) = T x i = G(s). By the induction hypothesis r = r and s = s , so t = (r • s) = (r • s ) = t .

Proposition 2.5 DFS trees are uniquely determined by their depth sequences: if T and T are DFS trees of size n such that d T (x
Proof Suppose, to the contrary, that DFS trees T and T satisfy d T ( (1) This notion was introduced in [7], where bracketings were represented by binary trees instead of DFS trees. (See also Exercise 19(u) in [18].) The depth of a vertex in a DFS tree is the same as the so-called "right depth" of the corresponding vertex in the binary tree representing the same bracketing. Therefore, 2.8 of [7] implies that depth sequences of DFS trees are in a one-to-one correspondence with zag sequences. We include an easy proof of this fact for the sake of self-containedness.

nonnegative integers is the depth sequence of a DFS tree of size n if and only if it is a zag sequence.
Proof Necessity is clear We prove sufficiency by induction on n. The case n = 1 is trivial, so let n ≥ 2, and assume that every zag sequence of length less than n is the depth sequence of a DFS tree (which is unique, by Proposition 2.5). Let (d 1 , . . . , d n ) be a zag sequence, and let d k = 1 be the last occurrence of 1 in the sequence (possibly k = 2). Then d 1 , . . . , d k−1 and d k − 1, . . . , d n − 1 are zag sequences of length less than n; hence, by our induction hypothesis, they are depth sequences of DFS trees T 1 (of size k − 1) and T 2 (of size n − k + 1), respectively. Let us form the disjoint union of T 1 and T 2 after applying the renaming x i → x i+k−1 to the vertices of T 2 . Now if we add an edge from x 1 (the root of T 1 ) to x k (the new root of T 2 ), then we obtain a DFS tree of size n with depth sequence (d 1 , . . . , d n ). Another family of lattice paths is also closely related to bracketings and DFS trees. A Dyck path of semilength n is a lattice path from (0, 0) to (2n, 0) consisting of n up-steps U = (1, 1) and n down-steps D = (1, −1) in such a way that the path never goes below the x-axis. To construct the Dyck path corresponding to a DFS tree T , let us draw T in such a way that all edges point upwards, and the children of every vertex are drawn in increasing order (of their subscripts) from left to right. (All DFS trees in this paper are drawn using this convention.) Let us follow the depth-first search on T , including the backtracking steps, returning to the root in the end (see the dotted line in Fig. 1). For each step, we add an up-step U or a down-step D to our lattice path starting at the origin according to whether we are moving upwards or downwards in the tree. (See Fig. 3 for the Dyck path corresponding to the DFS tree of Fig. 1. The first occurrence of each vertex during the depth-first search is labelled on the diagram.) This way we obtain a bijection from the set of DFS trees of size n to the set of Dyck paths of semilength n − 1. A wormderful explanation of this bijection is presented in [19, p. 10], where this process is actually used to define the depth-first order.

Collapsing maps and a few lemmas
Such homomorphisms ϕ and ψ are referred to as collapsing maps of T on W and C, respectively, and we say that the DFS tree T is collapsed on the walk W (on the closed walk C) by ϕ (by ψ).
We will often specify homomorphisms of DFS trees by giving a piecewise definition in which each piece is a collapsing map of a subgraph. In particular, if T is a DFS tree of size n, x d ∈ X n , s : is an edge, and W is either a walk u 0 → u 1 → · · · → u h or a closed walk u 0 → u 1 → · · · → u → u 0 , then the mapping ϕ : X n → V (G) that collapses T \ T x d on W and T x d on W is a homomorphism of T into G, and we will refer to ϕ as the collapsing map of (T , x d ) on (W , W ), and we say that Figure 4 shows a collapsing map ϕ of (T , 4 and W : u 0 → u 1 are walks in a graph G and T is a DFS tree of size 15. Each vertex of T is mapped to the vertex on the same level in G represented by the same type of node (filled or empty).

Example 2.9
With the help of collapsing maps and Proposition 2.1, we can derive conditions for the edges of a digraph satisfying a bracketing identity. Let us illustrate this with a few examples that will serve as helpful tools later.

Lemma 2.11
Let t, t ∈ B n , t = t , T := G(t), T := G(t ), and let G be a digraph such that A(G) satisfies the identity t ≈ t . Then the following statements hold.
Proof Since t = t , there exists a vertex x d that has distinct parents in T and T , say x p and x q , respectively. We have p < d and q < d, and, changing the roles of T and T if necessary, we may assume that For each statement, we are going to provide suitable walks with v s−1 → u 0 being an edge, and we consider the collapsing map ϕ of (T , x d ) on (W , W ), which is a homomorphism of T into G. By Proposition 2.1, ϕ is also a homomorphism of T into G.
(a) We obtain the edge v → u by letting W be the walk starting with r occurrences of u, followed by a walk of length h − r starting at v, and letting W be the cycle u → u. We obtain the edge v → v by letting W be as above and letting W be a sufficiently long walk starting at v.
(b) We obtain the edge u → w by letting W : v → · · · → v → u → · · · → u with r occurrences of v and h − r + 1 occurrences of u and W : w → w. By swapping u with w in the above, we obtain also the edge w → u.
(c) We obtain the edge w → v by letting W : v 0 → v 1 → · · · → v h be the walk in which v 0 , . . . , v r −1 alternate between vertices u and v such that v r −1 = v, followed by the vertices of a walk of length h − r starting at w, and letting W be the cycle (d) We obtain the edge u → v by letting W : v 0 → v 1 → · · · → v h be the walk with v i := u when i ≡ r (mod 2) and i = r , v r := u , and v i := v when i ≡ r (mod 2), and letting W be the cycle v → u → v . Note that we have s − 1 ≡ r (mod 2) as above, so v s−1 = u and v s−1 → u 0 is indeed an edge in G. Switching the roles of u and v, while also switching the roles of u and v , yields v → u .

Remark 2.12
There exist arbitrarily long walks with initial vertex v if, for example, v lies on a cycle, or there is a path from v to a vertex v that lies on a cycle.

Associative spectra of graph algebras of undirected graphs
It is relatively easy to determine the associative spectra of graph algebras of undirected graphs. It turns out that there are only three distinct possibilities: the sequences of all 1's, powers of 2, and Catalan numbers. Undirected graphs are classified into these three types in Theorem 3.3.
As we will see, a key criterion for the classification of pairs of distinct DFS trees of size n is whether the depths of each vertex in the two trees are congruent modulo 2.

Lemma 3.1 Let ∼ be the equivalence relation on B n that relates t and t if and only if
for all x i ∈ X n . Then |B n /∼| = 2 n−2 for n ≥ 2.
Proof Let us define the depth sequence modulo 2 of a bracketing t ∈ B n as the tuple d t,2 : = (d 1 , d 2 , . . . , d n ),

Lemma 3.2 Let K be an undirected connected graph with no loops. Assume that for all vertices a, b, c, d of K it holds that if a → b → c → d is a walk in K , then a → d is an edge. Then K is complete bipartite.
Proof Suppose, to the contrary, that K is not bipartite. Then K has a cycle of odd length m ≥ 3, say v 1 → v 2 → · · · → v m → v 1 . By applying our assumption Repeating this argument, we eventually arrive at a cycle of length 1. This contradicts the fact that K has no loops.
We have established that K must be bipartite. It remains to show that K is complete bipartite. Let B 1 , B 2 be a bipartition of K , and let x ∈ B 1 , y ∈ B 2 . We want to show that x → y is an edge in K . Since K is connected, there exists a path x = v 0 → v 1 → · · · → v n = y in K , with n odd. If n ≥ 3, then our assumption implies that v 0 → v 1 → · · · → v n−3 → v n is a path of length n − 2 from x to y. Repeating this argument, we eventually get a path of length 1 from x to y, i.e., an edge x → y.
for all x i ∈ X n . In this case, s n (A(G)) = 2 n−2 for all n ≥ 2.
(iii) Otherwise A(G) satisfies no nontrivial bracketing identity. In this case, s n (A(G)) = C n−1 for all n ∈ N + . Proof Let K be a connected component of G containing a loop. We will show that the edge relation E(K ) is reflexive, symmetric, and transitive. From this, we can conclude that K is a complete graph with loops. The claim is obvious if K has only one vertex, so we may assume that K has at least two vertices. The edge relation is symmetric because G is undirected. For reflexivity, let u be a vertex in K with a loop, and let v be a vertex adjacent to u. It follows from Lemma 2.11(a) that (v, v) ∈ E(K ) (note that v belongs to the cycle v → u → v). From this, we can conclude that every vertex in K has a loop, that is, the edge relation E(K ) is reflexive.
For transitivity, assume that (u, v) and (v, w) are edges in K . By reflexivity, we have loops at vertices u, v and w, and by symmetry, we have also the edges (v, u) and (w, v). Now Lemma 2.11(b) implies that (u, w) ∈ E(K ).

Claim 3.3.2 Every nontrivial connected component of G without loops is a complete bipartite graph. Such a component exists only if d T (x
Proof Let K be a nontrivial connected component of G without loops. Then K contains an edge (u, v). Then the map ϕ : X n → V , is clearly a homomorphism of T into G. By Proposition 2.1, ϕ is a homomorphism of In order to conclude that K is complete bipartite, it suffices, by Lemma 3.2, to show that if a → b → c → d is a walk in K , then (a, d) is an edge. Since the edge relation is symmetric, this holds by Lemma 2.11(d).
Assume now that the connected components of G are trivial, complete graphs (with loops), or complete bipartite graphs, and if one of the components is a complete bipartite graph, then d T (x i ) ≡ d T (x i ) (mod 2) for all x i ∈ X n . In order to prove that G satisfies t ≈ t , we apply Proposition 2.1. Let ϕ : X n → V be a homomorphism of T into G. Since T is connected and contains an edge, the image of ϕ lies in a single Consider then the case where K is a complete bipartite graph with bipartition B 1 , B 2 . It is easy to see that for all x i , x j ∈ X n , ϕ(x i ) and ϕ(x j ) lie in the same part (B 1 or B 2 for all x i ∈ X n , which implies that ϕ is also a homomorphism of T into G.
A similar argument shows that every homomorphism of T into G is also a homomorphism of T into G. By Proposition 2.1, G satisfies t ≈ t .
We have shown that G satisfies a nontrivial bracketing identity t ≈ t if and only if the connected components of G are trivial, complete graphs (with loops), or complete bipartite graphs, and if the last case occurs, then d T (x i ) ≡ d T (x i ) (mod 2) for all x i ∈ X n . This gives us the three possible associative spectra. If A(G) satisfies all bracketing identities, then A(G) is associative and s n (A(G)) = 1 for all n ∈ N + . If A(G) satisfies no nontrivial bracketing identity, then s n (A(G)) = C n−1 for all n ∈ N + . In the last possible case, σ n (A(G)) relates t and t if and only if d T (x i ) ≡ d T (x i ) (mod 2) for all x i ∈ X n ; by Lemma 3.1 we have s n (A(G)) = 2 n−2 .

Associative and antiassociative digraphs
A digraph G is associative if A(G) satisfies the associative identity x 1 (x 2 x 3 ) ≈ (x 1 x 2 )x 3 , i.e., if the associative spectrum of A(G) is constant 1. Associative digraphs were characterized by Poomsa-ard [15]; the equivalence of conditions (i) and (ii) in the following can be verified by applying Proposition 2.1 to the DFS trees associated with the two bracketings appearing in the associative law (see Fig. 5).

Proposition 4.1 (Poomsa-ard [15, Proposition 2.2]) For any digraph G = (V , E), the following statements are equivalent. (i) G is associative. (ii) For any edge (u, v) ∈ E and any vertex w ∈ V , (u, w) ∈ E if and only if (v, w) ∈ E. (iii) The edge relation E is transitive and for every v ∈ V , the subgraph induced on the outneighbourhood N G o (v) is a complete graph.
On the other extreme, we have the antiassociative digraphs whose graph algebras satisfy no nontrivial bracketing identities, i.e., the associative spectrum of A(G) consists of the Catalan numbers. The goal of this section is to characterize antiassociative digraphs. To this end, we introduce some numerical parameters of bracketing identities in terms of the corresponding DFS trees, and we prove several necessary conditions for a graph algebra to satisfy a given bracketing identity.  x i ∈ X n . In other words, the depth sequences of T and T are congruent modulo M t,t . (iii) Let L t,t be the largest integer m such that for all x i ∈ X n , In other words, the DFS trees T and T are identical up to level L t,t .
Note that 0 ≤ H t,t < n (with H t,t = 0 if and only if n = 1), 0 ≤ L t,t < H t,t and 1 ≤ M t,t ≤ H t,t . Figure 6 shows two DFS trees corresponding to certain terms t, t ∈ B 20 . It is straightforward to verify that H t,t = 6, M t,t = 3, and L t,t = 2.

Example 4.3
is an edge in G. In particular, v L+1 belongs to a nontrivial strongly connected component.
Proof By the definition of L, there exists a vertex x d ∈ X n such that either d T ( By changing the roles of T and T , if necessary, we may assume that d T ( . Let x p be the parent of x d in T , and let x q be the parent of x d in T . Then d T (x p ) = L, and it follows from Definition 2.2 that V (T x p ) = V (T x p ) because the trees T and T are identical up to level L. Since , and consider first the case that h ≤ h , so h = H . In this case, the statement of the Lemma holds with r : Consider now the case that h > h , so h = H . Let u 0 → u 1 → · · · → u h be a longest path in T , and write d i := d T (u i ) for i ∈ {0, . . . , h}. Now, since h > h , the sequence d 0 , d 1 , . . . , d h cannot be strictly increasing, so there exists an index j with d j ≥ d j+1 . Note that d j+1 ≥ L + 1, because the trees T and T are identical up to level L.

and then, it continues around the closed walk C until it reaches length
so M divides D (notation: M | D), and it follows that r ≡ d T (x q ) ≡ L (mod M). Now we have a closed walk v L+1 → · · · → v r → v L+1 in G. This means, in particular, that v L+1 belongs to a nontrivial strongly connected component.
The next lemma generalizes Lemma 2.11(a). Proof For m = 1 this is Lemma 2.11(a). Assume that m ≥ 2. Let r be the number provided by Lemma 4.4, and let v 0 → v 1 → · · · → v H be a walk that starts by going around the closed walk U so that v r −1 = u 0 (i.e., v i := u i−r +1 mod m for 0 ≤ i ≤ r − 1) and continues with a walk of length H − r with initial vertex w. By Lemma 4.4, v r → v L+1 is an edge. We have v r = w and v L+1 = u L+1−r +1 mod m . Since r ≡ L (mod M) and m | M, we have r ≡ L (mod m); hence L + 1 −r + 1 ≡ 2 mod m. Therefore w → u 2 is an edge if m > 2 and w → u 0 is an edge if m = 2.

Lemma 4.5 Let t, t ∈ B n , t = t , and let G be a digraph such that
Since the only homomorphisms of T to C m are collapsing maps x i → (d T (x i ) + k) mod m for some k ∈ Z m , and since ϕ( In other words, an m-whirl G is a strong homomorphic preimage of the directed m-cycle C m . By definition, 1-whirls are precisely the complete graphs with loops and 2-whirls are precisely the complete bipartite graphs. (Note the role of 1-whirls and 2-whirls in Theorem 3.3.)

Lemma 4.8 Let t, t ∈ B n , t = t , and let G be a digraph such that A(G) satisfies the identity t ≈ t . Then every strongly connected component of G is either trivial or an m-whirl for some divisor m of M t,t .
Proof Let K be a nontrivial strongly connected component of G. Every vertex of K lies on a cycle contained in K ; let C be a shortest cycle in K , and assume that C has length m. Lemma 4.6 implies that m is a divisor of M t,t . We want to show that K is an m-whirl.
Assume first that m = 1. Then K contains a vertex u with a loop. Let v be an arbitrary vertex of K . By strong connectivity, there exists a path from u to v. Since every vertex is contained in a cycle (again by strong connectivity), we can deduce with the help of Lemma 2.11(a) that every vertex along the path from u to v has a loop. We conclude that the edge relation of K is reflexive. The reflexivity of the edge relation and Lemma 2.11(a) imply immediately that the edge relation is symmetric. Now Lemma 2.11(b) implies in turn that the edge relation is transitive. We conclude that K is a complete graph with loops, i.e., a 1-whirl.
Assume now that m = 2. Then M t,t is even, K contains no loop, and there is a cycle of length 2 in K , i.e., vertices u, v with (u, v), (v, u) ∈ E(G). With the help of strong connectivity and Lemma 2.11(c), we can deduce that K is undirected. It now follows from Lemmas 3.2 and 2.11(d) that K is a complete bipartite graph, i.e., a 2-whirl.
From now on, assume that m > 2. For notational simplicity, suppose that C = C m , that is, V (C) = Z m and for all i, j ∈ Z m , i → j is an edge if and only if j ≡ i + 1 (mod m). For each i ∈ Z m , consider i.e., B i is the set of all outneighbours of i − 1 (addition modulo m) belonging to the strongly connected component K . Note that i ∈ B i by definition. We show that for all i ∈ Z m and for all v Lemma 4.5 gives the edge v → i + 1 (note that by strong connectivity every vertex of K , in particular v, belongs to a cycle). Now let i ∈ Z m , v ∈ B i and w ∈ B i+1 . Considering the closed walk i − 1 → i → w → i + 2 → · · · → m − 1 → 0 → · · · → i − 1 of length m and the edge i − 1 → v, Lemma 4.5 gives the edge v → w. We have shown thus far that for all i ∈ Z m , and let w be a vertex of K with v → w. We have shown above that v → i + 1 is an edge. Considering the closed walk v → i + 1 → · · · → m − 1 → 0 → 1 → · · · → i − 1 → v of length m and the edge v → w, Lemma 4.5 gives the edge w → i + 2. Considering the closed walk It remains to show that the sets B 0 , B 1 , . . . , B m−1 constitute a partition of V (K ). Let us show first that these sets are pairwise disjoint. Suppose, to the contrary, that B i ∩ B j = ∅ for some i = j, and let v ∈ B i ∩ B j . Then we have i − 1 → v → i + 1 and j − 1 → v → j + 1. We will find a contradiction by showing that K contains a cycle shorter than C. If j = i + 1, then K contains the loop v → v, a cycle of length 1. Otherwise v → i + 1 → · · · → j − 1 → v is a cycle shorter than C.
Suppose now, to the contrary, that m−1 i=0 B i = V (K ), and let v ∈ V (K )\ m−1 i=0 B i . Since K is strongly connected, there exists a path 0 = v 0 → v 1 → · · · → v p = v in K . Then there exists an index q ∈ {0, . . . , p − 1} such that v q ∈ m−1 i=0 B i and v q+1 / ∈ m−1 i=0 B i , say v q ∈ B j . But we have shown above that N K o (v q ) = B j+1 . This gives the desired contradiction, and we conclude that K is an m-whirl.

Lemma 4.9 Let t, t ∈ B n , t = t , and let G be a digraph such that A(G) satisfies the identity t ≈ t . Then there is no path from a nontrivial strongly connected component of G to another.
Proof Suppose, to the contrary, that there are distinct nontrivial strongly connected components K and K and a path P from a vertex v ∈ V (K ) to a vertex v ∈ V (K ). Assume that P is the shortest possible among all such paths. Then v is the only vertex of P lying in K . Let w be the successor of v along this path.
By Lemma 4.8, K and K are an m-whirl and an m -whirl, respectively, for some divisors m and m of M t,t . Hence v belongs to an m-cycle C in K and v belongs to an m -cycle C in K . Now Lemma 4.5 provides an edge from w to a vertex on C. This means that w belongs to the strongly connected component K , a contradiction.
belongs to a nontrivial strongly connected component, a contradiction.
The necessary conditions established in the previous lemmas together are sufficient for the satisfaction of some nontrivial bracketing identity. We prove this in the following theorem, which provides a complete characterization of (not) antiassociative digraphs. Note that this does not constitute a necessary and sufficient condition for the satisfaction of a given nontrivial bracketing identity. Finding such a condition will be a topic of a forthcoming paper.

Theorem 4.12 Let G be a digraph. Then A(G) is not antiassociative if and only if the following conditions hold. (i) Every nontrivial strongly connected component of G is a whirl. (ii) There is no path from a nontrivial strongly connected component of G to another. (iii) There is a finite upper bound on the length of the pleasant paths in G. (iv) There is a finite upper bound on the numbers m such that G contains an m-whirl.
Clearly, for finite graphs conditions (iii) and (iv) are fulfilled trivially.
Proof Assume that A(G) satisfies a nontrivial bracketing identity t ≈ t . By Lemma 4.4, the pleasant paths in G have length less than H t,t . By Lemma 4.8, every nontrivial strongly connected component of G is an m-whirl for some divisor m of M t,t ; such numbers m are clearly bounded above by M t,t . By Lemma 4.9, there is no path from a nontrivial strongly connected component of G to another. Assume now that conditions (i)-(iv) hold. We will construct a nontrivial bracketing identity t ≈ t that is satisfied by A(G). We will define the terms t and t in terms of the corresponding DFS trees T := G(t) and T := G(t ). Let P be an upper bound on the lengths of pleasant paths in G, as provided by condition (iii), and let M := lcm{m ∈ N + | G contains an m-whirl}, which is a finite natural number by condition (iv), with the convention that lcm ∅ = 1. Let n := 3P + M + 6, and let T consist of the paths x 1 → · · · → x 2P+M+4 and x 2P+M+5 → · · · → x 3P+M+6 and of the edge x P+2 → x 2P+M+5 . The tree T is constructed in a similar way, but we replace the edge is an edge, which proves that ϕ is also a homomorphism of T into G. An analogous argument shows that if ϕ is a homomorphism of T into G, then ϕ is also a homomorphism of T into G. Now if we let t and t be the bracketings corresponding to T and T , respectively, then A(G) satisfies t ≈ t by Proposition 2.1.

Some examples
In this section, we determine the associative spectrum of a few special directed graphs that are not covered by the results of the previous sections (i.e., they are neither associative nor antiassociative), such as directed paths and cycles, all graphs on two vertices, etc. For the spectra of directed paths, we shall need the number of DFS trees of bounded height, so first we recall some known facts about these numbers.
Let us denote the number of DFS trees of size n of height at most h by D h (n). Clearly D h (n) = C n−1 whenever n ≤ h + 1, because every n-vertex rooted directed tree has height at most n − 1. The generating function ∞ n=0 D h (n) · x n is a rational function (see [8]), hence the sequence {D h (n)} ∞ n=0 satisfies a linear recurrence relation: We list these recurrence relations for h = 2, 3, 4, 5 in Table 1 together with explicit formulas for D h (n) and the corresponding OEIS entries. (For h = 5 the characteristic polynomial of the linear recurrence is x 3 − 5x 2 + 6x − 1, and its roots are not "nice", so we do not give an explicit formula for this case.) Note that we have every second Fibonacci number for h = 3. (We use the indexing F 1 = F 2 = 1.) For more information on the numbers D h (n), see [8] (note that in [8] the height is defined as the number of vertices of the longest path starting at the root, whereas in this paper the number of edges is counted), and see also the OEIS entry A080934.

Proposition 5.1 Let G be a directed path of length :
The associative spectrum of the corresponding graph algebra is Proof If T is a DFS tree with h(T ) > , then there is no homomorphism from T to G; hence, all bracketings corresponding to DFS trees of height at least + 1 belong to the same equivalence class of σ n (A(G)) by Proposition 2.1. (Note that such trees exist only if n ≥ + 2.) If h(T ) ≤ , then there exist homomorphisms from T to G, for instance the collapsing map ϕ of T on G defined by ϕ( , and this implies T = T by Proposition 2.5. This together with Proposition 2.1 shows that each bracketing whose DFS tree has height at most forms a singleton class in σ n (A(G)). There are D (n) such classes, and if n ≥ + 2, then we also have the class corresponding to trees of height at least + 1.
Next we examine directed paths with some loops. By Theorem 4.12 (or just by Lemma 4.9), if we have at least two loops on a path, then the graph is antiassociative, so it suffices to consider the case of only one loop. We determine the spectrum of directed paths with a loop on the last vertex; the other cases constitute a topic for further research. Proof The equivalence relation ∼ on B n induces naturally an equivalence relation on the set of zag sequences of length n, and we will use the same symbol ∼ for this relation. For any zag sequence d = (d 1 , . . . , d n ), let β(d) = (d 1 , . . . , d n ) be the sequence obtained from d by replacing each element greater than h by h + 1, i.e., d i = min(d i , h + 1) for i = 1, . . . , n. 2 It is straightforward to verify that β(d) is also a zag sequence, and every zag sequence bounded above by h + 1 is in the image of β (indeed, if d is bounded by h + 1, then β(d) = d). Morover, for all zag sequences d 1 , d 2 of size n, we have β(d 1 ) = β(d 2 ) if and only if d 1 ∼ d 2 . Thus β is a surjection from the set of all zag sequences of size n to the set of all zag sequences of size n bounded by h + 1, and the kernel of β is the equivalence relation ∼. This implies that the number of equivalence classes of ∼ equals the cardinality of the image of β, which is clearly D h+1 (n).

Proposition 5.3 Let G be a directed path of length with a loop on the last vertex:
The associative spectrum of the corresponding graph algebra is s n (A(G)) = D (n).
Proof Homomorphisms of a DFS tree T into G are uniquely determined by the image of x 1 : a map ϕ : This implies, by Proposition 2.1, that A(G) satisfies a bracketing identity t ≈ t if and only if L t,t ≥ − 1. Therefore, Lemma 5.2 gives For the spectrum of the directed cycle C m , we need to count depth sequences modulo m by Lemma 4.6 (or zag sequences modulo m, according to Proposition 2.6). The resulting numbers are called modular Catalan numbers in [10], and they are denoted by C m,n . For us it will be most convenient to define these numbers simply as C m,n := s n+1 (A(C m )), and we refer the reader to [10] for plenty of information on these numbers (tables of numerical values, references to OEIS entries, formulas and various combinatorial interpretations). We give two combinatorial interpretations in the next proposition. The second one is stated in [10], but the proof is left to the reader there, so we include the proof here.

Proposition 5.4
The associative spectrum s n (A(C m )) = C m,n−1 counts the number of zag sequences satisfying Furthermore, s n (A(C m )) = C m,n−1 equals the number of Dyck paths of semilength n − 1 that do not contain D · · · DU = D m U .
Proof According to Proposition 2.6 and Lemma 4.6, the associative spectrum of A(C m ) counts the number of zag sequences modulo m. We claim that each zag sequence of Remark 5.5 Proposition 5.4 implies that s n (A(C m )) is nondecreasing in m, hence s n (A(C m )) ≥ s n (A(C 2 )) = 2 n−2 for all m ≥ 2 (see Lemma 3.1). The results of [7] and [10] imply that the associative spectrum of A(C m ) coincides with that of the operation x + εy on complex numbers, where ε is a primitive m-th root of unity. In particular, for m = 2, we have that the spectrum of subtraction consists of powers of 2 (see 3.1 in [7]). Now let us study digraphs on two vertices systematically. Up to isomorphism, there are ten digraphs on two vertices; they are presented in Table 2. The corresponding graph algebras are three-element groupoids, and the last column of the table indicates the Siena Catalog numbers of their isomorphism class representatives as listed in [1], as well as the ones of their opposite groupoids. Of these ten digraphs, only three are not covered by Proposition 4.1 and Theorem 4.12 (i.e., they are neither associative nor antiassociative): the undirected path of length one, the directed path of length one, and the directed path of length one with a loop on the first vertex. The first two ones are special cases of Theorem 3.3 and Proposition 5.1, respectively. We treat the third one in Proposition 5.7, and for that we need to investigate an equivalence relation on DFS trees determined by their leaves. Let T and T be DFS trees on n vertices. We say that T and T are leaf-equivalent if they have the same set of leaves. Proof The set of leaves of a DFS tree on n vertices is a subset of X n that does not contain the root x 1 , but it always contains x n . On the other hand, it is easy to see that for every subset S = {x i 1 , x i 2 , . . . , x i r } ⊆ X n with 1 < i 1 < i 2 < · · · < i r = n, there exists a DFS tree whose leaves are precisely the elements of S. For example, we can take the tree comprising just the paths from x 1 to each x i j ∈ S that are disjoint except for the initial vertex: x 1 → x 2 → · · · → x i 1 and x 1 → x i j−1 +1 → · · · → x i j for 2 ≤ j ≤ r . The number of subsets of X n containing x n but not containing x 1 is 2 n−2 . Proof For any DFS tree T of size n, a map ϕ : X n → {v, w} is a homomorphism of T into G if and only if all vertices that are mapped to w are leaves in T . Therefore, A(G) satisfies a bracketing identity t ≈ t if and only if the corresponding trees T := G(t) and T := G(t ) are leaf-equivalent. Now Lemma 5.6 implies that s n = 2 n−2 .
Finally, we consider some graphs on three vertices. Proof For any DFS tree T of size n, a map ϕ : X n → {u, v, w} is a homomorphism of T into G if and only if either ϕ(X n ) = v or ϕ(X n ) = w, or ϕ(x 1 ) = u and all other vertices are mapped to {v, w} in such a way, that if a vertex of depth one is mapped to v (to w), then all of its descendants are also mapped to v (to w): Thus the set of all homomorphisms of T into G is determined by the partition {V (T p ) | p ∈ X n and d T ( p) = 1} of the set {x 2 , . . . , x n }. This partition is in turn determined uniquely by the set of depth-one vertices. Indeed, if the depth-one vertices of T are x i 1 , . . . , x i s with 2 = i 1 < · · · < i s ≤ n, then V (T x i k ) = X [i k ,i k+1 −1] for k = 1, . . . , s −1 and V (T x is ) = X [i s ,n] . By Proposition 2.1, this implies that A(G) satisfies a bracketing identity t ≈ t if and only if L t,t ≥ 1. Therefore, by Lemma 5.2 we have s n (A(G)) = D 2 (n) = 2 n−2 . Proof For any DFS tree T of size n, a map ϕ : X n → {u, v, w} is a homomorphism of T into G if and only if either ϕ(X n ) ⊆ {v, w}, or ϕ(x 1 ) = u, all depth-one vertices are mapped to v, and the other vertices are mapped to {v, w} in an arbitrary way. Thus the set of all homomorphisms of T into G is determined uniquely by the set of depth-one vertices. Therefore, just as in the previous proposition, we can conclude s n (A(G)) = D 2 (n) = 2 n−2 with the help of Lemma 5.2.

Remark 5.10
The graph algebra of the directed path of length one with loops on both vertices is isomorphic to the three-element groupoid with Siena Catalog number 84 and antiisomorphic to the one with number 82 (see [1]). These groupoids were shown in [7, statements 2.4, 5.7] to be antiassociative; this result also follows immediately from our Lemma 4.9.