On Computation of Baker and Norine's Rank on Complete Graphs

The paper by M. Baker and S. Norine in 2007 introduced a new parameter on configurations of graphs and gave a new result in the theory of graphs which has an algebraic geometry flavor. This result was called Riemann-Roch formula for graphs since it defines a combinatorial version of divisors and their ranks in terms of configurations on graphs. The so called chip firing game on graphs and the sandpile model in physics play a central role in this theory. In this paper we present an algorithm for the determination of the rank of configurations for the complete graph K n. This algorithm has linear arithmetic complexity. The analysis of number of iterations in a less optimized version of this algorithm leads to an apparently new parameter which we call the prerank. This parameter and the parameter dinv provide an alternative description to some well known q, t-Catalan numbers. Restricted to a natural subset of configurations, the two natural statistics degree and rank lead to a distribution which is described by a generating function which, up to a change of variables and a rescaling, is a symmetric fraction involving two copies of Carlitz q-analogue of the Catalan numbers. In annex, we give an alternative presentation of the theorem of Baker and Norine in purely combinatorial terms.


Introduction
On a graph, a configuration is a map from its vertices to the integers of Z. Motivated by the generalization for graphs of a Riemann-Roch theorem, Baker and Norine [6] defined for any configuration a parameter they called rank.This parameter is an integer greater or equal to −1.The abelian sandpile model [4,17,15] provides a framework for the original definition of the rank which seems to involve non-trivial computations.At submission date of this work, the complexity of the computation of the rank for general graphs was unknown.Just after, Kiss and Tóthmérész announced on arXiv [25] their proof for general graphs that computation is NP-hard.
The complete graph K n is the non-oriented graph with n vertices and exactly one edge between any pair of distinct vertices.We present here an algorithm which computes the rank of a configuration in the particular case of complete graphs.We prove that our most efficient version has a linear arithmetic complexity where the size of the problem is the number of vertices of the graph.The design of this algorithm has enumerative byproducts in the context of the rank parameter and also some intensively studied q, t-Catalan numbers [23].The results in this second context strengthen the connection with the abelian sandpile model as in recent work involving one of the authors [19,2].
Let G = (V G , E G ) be an non-oriented connected simple graph without loops and with vertex set V G and edge set E G .Baker's and, Norine's theorem [6] states that for any where the cardinality of a set E is denoted by |E|; the definition of the parameter rank is still postponed to the preliminaries in Section 2; the configurations are seen as vectors allowing additions and subtractions; the degree of the configuration u is degree(u) := i∈V G u i ; the configuration K G := (k i ) i∈V G is defined by k i := d i − 2 where d i is the degree of the vertex i which is its number of incident edges.In this context, a configuration is called a divisor but we prefered to use the abelian sandpile model terminology.This paper focus on the particular case where G is a complete graph K n : we use the integers 1, 2, . . .n to label the vertices V Kn of the complete graph K n ; the configuration K Kn = (k i ) i=1...n satisfies k i = n − 3 for all i.
The two next sections are dedicated to the design of our main algorithm which computes the rank of a configuration on K n .Section 2 focus on correctness of a first version of the algorithm.We use the numerous symmetries of the complete graphs to obtain a greedy algorithm computing the rank.The complexity of this version is not clear but the aim of Section 3 is to optimize this algorithm.We select a particular run of this non-deterministic first algorithm to reach the announced complexity while preserving the correctness.The optimization requires to work at the level of orbits of a subgroup of symmetries.The toppling equivalence, an additional equivalent relation on configurations based on the sandpile model framework, shows that one can efficiently reduce the computation to the case of a sorted parking configuration.The configuration u is a sorted parking configuration if 0 u i < i for i < n and u 1 u 2 . . .u n−1 .Notice that there is no constrain on the value of u n .If we had used the divisor terminology, we may called this configuration a sorted n-reduced divisor.The optimized algorithm computes the rank via the following rather explicit expression for the rank of a sorted parking configuration the electronic journal of combinatorics 23(1) (2016), #P1.31 u in K n : rank(u) = n−1 i=1 max(0, q − i + u i + χ(i r)) − 1.
where u n + 1 = q(n − 1) + r is the euclidean division defining the quotient q and the non-negative remainder r, and χ(P ) is 1 if the proposition P is true and 0 otherwise.
The second optimized algorithm still manipulates the configurations as vectors.Yet the proof that it corresponds to a run of the first algorithm deeply relies on another coding of some configurations.These configurations on K n may be encoded by a Dyck word of size n − 1 and one or two integers depending on its additional properties.A word v on the two-letter alphabet {a, b} is a Dyck word of size n if |v| a = |v| b = n and for any prefix p of v, |p| a |p| b where |v| c denotes the number of occurrences of letter c in the word v.This data is embedded in a cut skew cylinder to make use of a cyclic symmetry.The skew cylinder of circumference n is an already known slight variation of the usual Z × Z/(n − 1)Z cylinder, for example already presented by Kramers and Wannier [22] in 1941.The main interest of this skew is that it merges the usually "parallel" finite cycles interpreting Z/(n − 1)Z into a single infinite spiral traversal isomorphic to Z.A cut of this skew cylinder is a self-avoiding directed cycle made up of north and east steps disconnecting the cylinder into two components.A classical cyclic lemma due to Dvoretsky and Motzkin [20] implies that any cut may be defined by the choice of a Dyck word of size n − 1 and a starting vertex.One interest of this change of encoding is that computation on configurations becomes simpler updates of the Dyck word or the integers.After all, our optimized algorithm on the configuration u = (u i ) i may be interpreted as a spiral traversal of u n + 1 cells on a related cut skew cylinder counting the occurrences of cells in one of the two components defined by the cut.
In Section 4, we describe as follows the generating function where C(q; z) is a classical Carlitz q-analogue of Catalan numbers counting the Dyck words according to size via the variable z and the later defined area via the variable q.
The formula for M(x, y; z) comes from the decomposition, on each cut skew cylinder, of the spiral traversal at crossings of the cut, leading to geometric sums of reasons x or y.If the sum in K n (r, d) were not restricted to sorted parking configurations, we would have reached a two-variable zeta function for graphs introduced recently by Lorenzini [28].
We provide a combinatorial interpretation of the generating function M n (x, y) in terms of cut skew cylinders.Those cut skew cylinders admits an natural involution ξ which roughly speaking consists in reversing the spiral traversal.This involution also explains via a superimposition principle why M n (x, y) = M n (y, x).In addition, this involution is related to the involution on configurations u → K Kn − u appearing in Riemann-Roch theorem for graphs.
In Section 5, we study connections of this work with q, t-Catalan numbers presented for example by Haglund in [23].These q, t-Catalan numbers (C n (q, t)) n∈N may be combinatorialy described by some pairs of statistics on a generic Dyck word w chosen among the later defined area(w), bounce(w) and dinv(w): C n (q, t) := w q area(w) t dinv(w) = w q area(w) t bounce (w)   where w runs over Dyck words of size n.The symmetry C n (q, t) = C n (t, q) is obvious once non-trivially proven equivalent to some alternative definitions.There is still no combinatorial explanation of this symmetry [24].In this context,Haglund designed an involution ζ on Dyck words which satisfies for any Dyck word w: (dinv(w), area(w)) = (area(ζ(w)), bounce(ζ(w))) establishing combinatorially the equivalence of the two presented definitions of C n (q, t).Our involution ξ on cut skew cylinders may be canonically restricted to Dyck words and this restriction also called ξ.It appears that dinv(ξ(w)) = dinv(w).An early optimization of our algorithm computing the rank leads us to the apparently new parameter prerank(w) = area(ξ(w)).Hence we have C n (q, t) = w q dinv(w) t prerank (w)   where w runs of Dyck words of size n.There is also a relation between the maps ζ and ξ: where R(w) classically maps the Dyck word w to its reverse word where each occurrence of a is replaced by b and conversely.

A first greedy algorithm
In our preliminaries, we recall classical properties of the abelian sandpile model and Baker's and, Norine's definition of the rank parameter.We then prove the correctness of our first version of a greedy algorithm computing the rank for a configuration in a complete graph.

Preliminaries
Let G be a non-oriented connected graph without loops and where multiple edges are allowed.We denote by V = {1, 2, . . .n} where n = |V | the vertex set of G and E its edge the electronic journal of combinatorics 23(1) (2016), #P1.31 set.The number of edges of E between the vertices i and j is denoted by e i,j .Hence the degree d i of the vertex i ∈ V is j∈V e i,j .A configuration u = (u i ) i∈V is a vector of Z n : the possibly negative number of grains u i is placed on vertex i in configuration u.Since a configuration u is a vector we can add or subtract configurations: the configuration w = u − v is defined by w i = u i − v i for any vertex i.The degree of the configuration u is degree(u) := i∈V u i .In the abelian sandpile model, the toppling of the vertex i in configuration u consists in sending from the vertex i one unit along each incident edge to the opposite endpoint of the edge.These amounts of one unit are also called grains.This leads to the configuration u = u − ∆ (i) where ∆ (i) i := d i and ∆ (i) j := −e i,j otherwise.This toppling is legal if u i d i ensuring that u i 0 and u j u j for any j = i.In this paper non legal topplings are sometimes allowed.The toppling of vertex i preserves the degree of any configuration since degree(∆ (i) ) = 0. Two configurations u and v are toppling equivalent if they differ by a finite combination of topplings: The symmetry of this equivalence relation comes from the relation i∈V ∆ (i) = 0 which allows to use −∆ (i) = j =i ∆ (i) to change signs in the combination.
We mainly summarize with our notation the definition of the rank presented by Baker and Norine in [6].A configuration u is positive, also denoted u 0, if u i 0 for any vertex i.A configuration v is effective if v is toppling equivalent to a positive configuration: ∃u, v ≡ ∆ u, and u 0. The rank of the configuration u is defined by the following optimization: rank(u where f runs over all positive configurations such that u − f is non-effective.An optimal choice f for the computation of rank(u) is called a proof for the rank of u.The set of such proofs is denoted by Proofs(u).
The test that a configuration u is effective is a first difficulty in this description of the rank since naively it may require to run over the infinite set of all configurations toppling equivalent to u. Hopefully, one can limit the test to a canonical configuration in the class of toppling equivalence: the n-parking configuration of u denoted park(u) which will be defined below. 1emma 1 ( [6],see also Proposition 37 in annex).We have u effective if and only if park(u) is positive.
The definition of these n-parking configurations requires additional notions.By convention the vertex n is distinguished and called the sink.A vertex i in configuration u is unstable if u i d i where d i is the degree of the vertex i in G.A configuration u is stable outside the sink if any vertex i = n is stable.A configuration u is positive outside the sink if for any vertex i = n, u i 0. This is also denoted by u =n 0. A subset of vertices ∈ A and, in the configuration u = u − a∈A ∆ (a) , we have u a 0 for any a ∈ A. In other words, A is set-unstable if the toppling of all the vertices of A leads to a configuration whose restriction to A is positive.If A is a singleton {i}, A is set-unstable if and only if i is unstable and hence the toppling of i is legal.A configuration u is set-stable if there is no subset of vertices set-unstable in u.A configuration u is n-parking, also shorten in parking, if u is stable and positive outside the sink and set-stable.We refer to the literature [15] for a proof that any configuration u is toppling equivalent to exactly one n-parking configuration.This property implies that the parking configuration park(u) toppling equivalent to the configuration u is well-defined.There exists many algorithms to compute the map u → park(u) on any graph.A recent one is due to Baker and Shokrieh [7].We will use the existence of such an algorithm in this section but in Section 3 we will design a most efficient one in the case of the complete graphs.
The stabilization process of the configuration u consists in toppling one unstable vertex distinct from the sink n while there exists at least one.A key classical property of the abelian sandpile model [15] is that this stabilization process terminates on a configuration denoted stabilize(u) which is stable outside the sink and do not depend on the hence unspecified order in which the unstable vertices are toppled.

A first greedy algorithm computing the rank on complete graphs
From now on we assume that G is a complete graph K n with n 2. Let (i) be the configuration with (i) i = 1 and for j = i, (i) j = 0. We consider the following greedy algorithm where the variable g is a configuration on K n : First greedy algorithm for the rank : Input: A configuration u on K n u ← park(u); rank ← −1; g ← 0; While u n 0 do let i = n such that u i = 0 in u ← park(u − (i) ); g ← g + (i) ;od; Output: rank (= rank(u)) and g (∈ Proofs(u)).
Proposition 2 (Correctness of the rank algorithm).Given any configuration u on K n , the greedy naive algorithm for the rank terminates and returns rank(u) in the variable rank and the configuration variable g ∈ Proofs(u) is a proof of this rank.
The postponed proof of this proposition requires two main proofs: one for the existence of some vertex i = n such that u i = 0 in any parking configuration and another one that g is a proof for rank(u).The second proof relies on the combination of the two following lemmas: the first is related on symmetries of the complete graph K n while the other, more general, is probably folklore.Lemma 3 (Greedy choice for rank's proof on K n ).Let u be a positive configuration on the complete graph K n such that there exists a vertex i for which u i = 0. Then there exists a proof g ∈ Proofs(u) for the rank of u such that g i > 0.
the electronic journal of combinatorics 23(1) (2016), #P1.31 Lemma 4 (Subproof for the rank).Let u be a configuration on any graph G and i a vertex of G. Assume there is a proof g for the rank of u such that g i > 0. Then any proof f for the rank of u = u − (i) leads to a proof f = f + (i) of the rank of u.
The possibility in our algorithm of a greedy choice for finding a proof for the rank comes from the numerous symmetries of the complete graph.Let σ be a generic permutation of the set S n of permutations on elements of {1, 2, . . .n}.The action of σ on a configuration u = (u i ) i=1...n is defined by σ.u := (u σ(i) ) i=1...n .We gather in the following lemma properties related to symmetries used in this section but also later: Lemma 5 (Symetries on K n and the rank).Let u and v be any configuration on K n and σ any permutation of S n .We have : Now we listed the required lemmas to prove the correctness of the algorithm, we use another schedule to prove them.
Proof.(of Lemma 3 Greedy choice for rank's proof on K n ) Let f ∈ Proofs(u).If f i > 0 then g = f concludes the proof.In the remaining case, we have f i = 0. Since f is a proof, u − f is non-effective hence there exists a vertex j such that u j − f j < 0. We have j = i since u i − f i = 0 − 0. We will show that g = f + (f j − u j )( (i) − (j) ) is the expected proof for the rank of u.By definition, g i = f j − u j > 0 and more generally g is positive and degree(g) = degree(f ).Hence it simply remains to show that u − g is non-effective.We consider u = u − f + (f j − u j ) (j) .Let σ = (ij) the transposition of S n which exchanges i and j: σ(i) = j, σ(j) = i and otherwise σ(k) = k.By definition u j = u j − f j + (f j − u j ) = 0 and u i = 0 − 0 = 0, so σ.u = u .Hence: Proof.(of Lemma 4 Subproof for the rank) Let g a proof of u such that g i > 0 and f a proof of u = u − (i) .On one hand, u − f = u − (f + (i) ) is non-effective so by definition of g, degree(f ) + 1 degree(g).On the other hand, u

Proof. (of Proposition 2 Correctness of the rank algorithm)
First, if u is a parking configuration on K n there exists a vertex i distinct from the sink such that u i = 0. Indeed we obtain a contradiction if for any i = n, u i = 0. Since u is positive outside of the sink, it means that u i 1. Hence A = {1, 2, . . .n − 1} = V − {n} is a set-unstable set.This is in contradiction with the assumption that u is parking.
We conclude the proof of correctness by an induction on the rank of the given configuration u.If rank(u) = −1, the configuration u is non-effective so, according to Lemma 1, park(u) has a negative value on the sink then the algorithm skips the while-loop and returns rank = −1 and g = 0 as expected.Let m 0. We assume that the algorithm is correct on any given configuration of rank at most m − 1.Let u be a configuration of rank m, v = park(u) and i the first chosen vertex by the algorithm such that v i = 0. Lemma 3 on the greedy choice for the rank implies the existence of a proof g for the rank of u such that g i > 0 and so g Our inductive assumption implies that the algorithm applied to v − (i) leads to a proof f of its rank.Applying Lemma 4 about subproofs for the rank, the configuration f + (i) is a proof for the rank of the given u.This is also the value in the variable g at the end of the run given the configuration u.

An algorithm of linear arithmetic complexity
In this section we optimize the correct greedy naive algorithm.Subsection 3.1 explains how to restrict quickly the algorithms to the manipulation of configurations soon defined and called compact and sorted.Subsection 3.2 motivates this restriction by a bijection between these compact and sorted configurations and pointed cut skew cylinders.This second class of combinatorial objects may be encoded by a Dyck word and one up to three integers.In the algorithms computing the rank or the parking configurations, atomic updates or tests on configurations admits more regular interpretations in terms of pointed cut skew cylinders.Subsection 3.3 translates a possible run of the algorithm for the rank into a simple partial spiral traversal in the cut skew cylinder.The analysis of this traversal leads to an explicit formula for the rank of a sorted and parking configuration based on a single euclidean division.Subsection 3.4 describes an algorithm adapted to the complete graph to find the parking configuration toppling equivalent to any given configuration.We conclude this section by discussing the details of a possible implementation in linear arithmetic complexity of an algorithm computing the rank of any configuration on K n .

Restriction to compact and sorted configurations
The distinguished sink n on K n implies that we frequently manipulate configurations where the sink is the only particular case.We often abbreviate a configuration u = (u 1 , . . .u n ) into (u i ; u n ) which means implicitly that the variable i, part of the notation, runs from 1 to n − 1.Our next definition illustrates this notation.
The compacted configuration u c of u is the configuration compact(u) := u c := ((u i − u n ) mod n; degree(u) In other words, for i = 1 . . .n − 1, u c i := (u i − u n ) mod n and for i = n, u c n := degree(u) − n−1 i=1 u c i .Lemma 6. (Compact configuration on K n ) For any configuration u on K n , we have compact(u) ≡ ∆ u.
Proof.On one hand, we topple u n times each vertex different from the sink in the configuration u to obtain On the other hand, by definition of u c := compact(u) there exists (k 1 , . . ., the electronic journal of combinatorics 23(1) (2016), #P1.31 where k i (∆ (i) − ∆ (n) ) cancels k i n in u c i + k i n and degree(u) is introduced using that topplings preserve the degree of configurations.The rightmost term is the preceding sequence of equalities is compact(u) which is hence proved to be toppling equivalent to u.
This definition of compact(u) particular to the complete graphs is inspired by a work on general graphs of Dhar, Ruelle and, Verma [18].One find similar ideas also in [7].We observe that compact(u) can be quickly computed, it is positive and stable outside of the sink but not necessarily equal to stabilize(u).
A configuration u on K n is compact if max i =n,j =n It is straightforward that the configuration compact(u) is compact.Moreover, most of the configurations appearing in the optimized algorithms are compacts.
Another aspect of the optimization consists in working at the level of orbits under the action of S n−1 ⊂ S n permuting the vertices 1, 2, . . .n − 1 distinct from the sink.The representative of the orbit of u will be the defined below sort(u) sorted configuration.A configuration u is sorted if u 1 , . . .u n−1 is weakly increasing: for i = 2 . . .n − 1, u i−1 u i .Notice that there is no constraint on u n .The configuration sort(u) is obtained by sorting in weakly increasing order of the first n − 1 entries of the configuration u.
We also combine the action of S n−1 and the toppling equivalence.Two configurations u and v on K n are toppling and permuting equivalent, denoted u ≡ ∆,S n−1 v if there exists a permutation σ ∈ S n−1 ⊂ S n such that u and σ.v are toppling equivalent.Lemma 7. (compatibilities for toppling and permuting equivalence) (1).The relation ≡ ∆,S n−1 is an equivalence relation.
(2).Moreover, for any configuration u, there exists a unique sorted and parking configuration v := sort(park(u)) toppling and permuting equivalent to u.
Proof.(1).The relation is symmetric mainly according to the second of the following equivalences: The transitivity of the relation comes from the composition of permutations.Let the electronic journal of combinatorics 23(1) (2016), #P1.31 (2).The existence of a sorted parking configuration toppling and permuting equivalent to u is straightforward since by definition sort(park(u)) is such a configuration.
Our proof of the uniqueness considers two configurations u and v toppling and permuting equivalent.By assumption, there is a permutation σ ∈ S n−1 such that σ.u is toppling equivalent to v. The uniqueness of the parking configuration in a toppling equivalent class implies that park(σ.u)= park(v).Using the identity 6.(d) of Lemma 5 on symmetries of K n , we deduce that σ.park(u) = park(v) hence sort(park(u)) = sort(park(v)) as expected.

From sorted and compact configurations to pointed cut skew cylinders
The parking configurations on the complete graph K n admits a more explicit description which explains the adjective parking.A parking function of size n is a map f from {1, 2, . . .n} to Z such that for i = 1 . . .n − 1, f (i) 0 and for j = 1 . . .n, |{i|f (i) j}| n − j.It was already noticed in [13] that a configuration u on K n is parking if and only if f defined by (f (i)) i=1...n−1 := (u i ) i=1...n−1 is a parking function of size n − 1.We already observed that u is parking if and only if σ.u where σ ∈ S n−1 ⊂ S n , in particular sort(u), is parking.Sorting simplifies the checking: a sorted configuration u is parking if and only if for i = 1 . . .n − 1, 0 u i < i.
Until now, we manipulated the configurations as vectors in Z n .We introduce an alternative description of sorted and compact configurations on K n which will simplify our analysis.This description requires some (painful but then rewarding) preliminaries.
Figure 1: Skew cylinder of circumference 6, two of its cuts and three oriented segments.
The skew cylinder of circumference n is a kind of skewed two dimensional grid embedded in a cylinder.A first precise definition considers the quotient of the usual grid of Z 2 where each vertex of integer coordinates (x, y) admits the four neighbours {(x + 1, y), (x − 1, y), (x, y + 1), (x, y − 1)} by the equivalent relation (x, y) ≡ (x , y ) if there exists k ∈ Z such that (x , y ) = (x + kn, y + k(n − 1)).A possible notation for this is Z 2 /(n, n − 1)Z.We fix our notation on a second precise and more explicit definition of skew cylinder which has the drawback to partially hide the invariance by translation.This definition is illustrated by the example in Figure 1.The strip of n−1 rows is the subgraph of the usual two dimensional grid Z 2 induced by the vertices {(x, y)|x ∈ Z, 0 y n−1}.The two-dimensional of cell coordinates (x, y) ∈ Z 2 is the unit square which corners are {(x, y), (x−1, y), (x−1, y +1), (x, y +1)}.In other words the two-dimensional coordinates of a cell are the coordinates of its south-east corner.For a cell c we denote by (x(c), y(c)) its two-dimensional coordinates.We will use the spiral coordinate as an alternative coordinate for the cells of the strip.The cell of two dimensional coordinate (0, 0) is labeled by the spiral coordinate 0 ∈ Z, then we label the cells, incrementing the spiral coordinate, from south-west to north-east in the cells along the diagonal in north-east direction, then the next diagonal is the next on the west.This spiral traversal labels all the cells of spiral coordinate k ∈ N. In Figure 1, the spiral coordinate of each cell is indicated by the small number written in the south-west corner.Negative coordinate −x is written x for graphical purpose.This number is blue for partial cells in the top row and means that these are repetitions of the cells on the bottom row.In the opposite direction and starting from the cell (0, 0), the reversed spiral traversal labels all the cells with a non-positive spiral coordinate.Hence, this spiral traversal defines a bijection between the cells of the strip of n − 1 rows and Z.We frequently use the cell (of spiral coordinate) k ∈ Z and the vertex (of spiral coordinate) k which is the south-east corner of this cell k.A more operational description is that the cell of two dimensional coordinates (x, y) in the strip has spiral coordinate ny − (n − 1)x and the cell of spiral coordinate k ∈ Z has two dimensional coordinates (r − q, r) where k = q(n − 1) + r is the euclidean division of k by n − 1.We turn this strip into the skew cylinder of circumference n by an identification of the vertices of coordinates (x, 0) and (x + n, n − 1) which implies that the south side of the cell (x, 0) is also the north side of the cell ( In a word w, we denote by |w| x the number of occurrences of the letter x.An almost balanced word of size n is a word on the alphabet {a, b} such that |w| a = n − 1 and |w| b = n.Let D n denotes the set of almost balanced words of size n.
Given a vertex k ∈ Z in the skew cylinder of circumference n and a word w on the two-letter alphabet {a, b}, the embedding of the word w at vertex k is the path starting from vertex k and such that an occurrence of letter a in w corresponds to a unit north step and an occurrence of letter b to a unit east step.The cell of a north step in such a path is the cell whose east side is the north step.
We first observe that the embedding at vertex m ∈ Z of an almost balanced word w ∈ D n in the skew cylinder of circumference n also ends at vertex m.This defines a (self-avoiding) loop that we call a cut.The resulting cut skew cylinder is denoted by cylinder[m w].In Figure 1, the blue path is a cut defining cylinder[10 abaababbabb] and the magenta path is a cut defining cylinder is the embedding of the word a n−1 at vertex k, and a i is the north step of the cut on cylinder[m w] which crosses the same row as the north step a k↑i and x(.) is the first coordinate of the two-dimensional coordinates of the starting vertex of a step.
In Figure 1, there are three oriented segments: the red one starts from 20, the orange one from −40 and the green one from 28.The last one is drawn into two green lines since it visits the two copies of the vertex 40.The red oriented segment, the blue cut and the integer 39 define the configuration  [20] states that among the 2n − 1 distinct cyclic conjugates of an almost balanced word w ∈ D n exactly one may be written vb where v is a Dyck word of size n − 1.We recover this lemma in our setting.In Figure 1, a dashed line indicates the Dyck factor abaababbab respectively aabbaababb in the cyclic conjugate for the blue, respectively magenta, cut.A first indication is that pairs (w, s) where w is a Dyck word of size n − 1 and s ∈ Z are in classical bijection with sorted parking configurations on K n as follows.
where2 w = b k 1 ab k 2 ab k 3 . . .ab kn .This bijection translates the fact that in a sorted parking configuration u we have 0 u i < i for i = 1 . . .n − 1 into the fact that w is a Dyck word.Another classical notion for an non-empty Dyck word w is its non-ambiguous decomposition at first return w = af bg where f and g are both possibly empty Dyck words.
We define the map T on sorted configurations on K n : and the map E on sorted parking configurations on K n which corresponds to the subtraction of one unit on a vertex with value 0 in the configuration: 1) .
Proposition 9. (From sorted compact configurations to pointed cut skew cylinders) 1.A configuration u on K n is sorted and compact if and only if there exists a word w ∈ D n and three integers (k, m, s) ∈ Z 3 such that u = scompact[k ⇒ m w; s].Moreover, the sorted and compact configurations toppling and permuting equivalent to scompact[k ⇒ 0 vb; s] are exactly the configurations

For any factorization
5. The restriction of T to sorted and compact configurations is well-defined and reversible.Moreover we have and for any sorted and compact configuration u on K n we have where gabf is a Dyck word and moreover the electronic journal of combinatorics 23(1) (2016), #P1.31 Conversely, given w ∈ D n and (m, k, s) ∈ Z 3 .Let k = q(n − 1) + r be the euclidean division of k by n − 1 and factorize w as w = b k 1 ab k 2 ab k 3 . . .ab kn .By definition we have u = scompact[k ⇒ m w; s] which is also defined by u n = s and u i = q + i j=1 k j .Hence u is sorted and Moving the start of the cut along the first step does not modify the cut skew cylinder.This remark leads to either cylinder Iterations of these two rules leads to the expected claim.
3. Two equal translations of the cut and the oriented segment preserve the pairs (a i , a k↑i ) and their differences x(a i ) − x(a k↑i ) hence proves the claim.
5. (see 4. below) Let u be a sorted and compact configuration.First we compute explicitly where sort induces the cyclic permutation τ of the n−1 first entry sending n−1 to 1, since n so v is also compact.The inverse of the cyclic permutation τ is well defined and also the inverse of the toppling of n − 1 which corresponds to the toppling of all vertices distinct from n − 1.The reader may then check that the inverse T −1 of T is the expected composition of these two inverses, ie During the computation of T 1−n = (T −1 ) n−1 , the fact that τ −1 is cyclic implies that each vertex distinct from the sink n is toppled n − 2 times and the sink n is toppled n − 1 times.Since toppling n − 2 times each vertex does not change the configuration and τ 1−n is the identity we deduce that T 1−n is equivalent to one toppling of the sink n as claimed.
6. First we suppose that u is parking.The cells at west of the oriented segment (a k↑i ) i=1...n−1 are (k + n(i − 1)) i=1...n−1 .We consider the vector (l i ) i=1...n−1 where l i is the minimal spiral coordinate of a cell in the left component of L[m w] on the same row as a k↑i .Hence by definition of scompact[k ⇒ m w; s], we have for i = n, u i = k+n(i−1)−l i n−1 .The configuration u is sorted and parking so we have u i < i.This is equivalent to Conversely, we suppose that k = min L[m w].The cut is made of east or south steps so k ∈ L[m w] implies recursively via the north sides of cells that k+n(i−1) ∈ L[m w] for i = 1, . . ., n − 1.Combined with the backward equivalences of the previous argument we have k l i k + n(i − 1) and so 0 u i < i.So u is a sorted parking configuration.
The power of T in the description of park(scompact[k ⇒ m w; s]) is chosen so that, in the resulting configuration, the oriented segment starts at the vertex in the south-east

An explicit formula for the rank of sorted parking configurations on K n
We describe a possible run of our correct first greedy algorithm for the rank presented in Section 2 combined with the action of the symmetric group S n−1 ⊂ S n .In a sorted parking configuration u, we necessarily have u 1 = 0 which will be our systematic choice of i = n such that u i = 0. Hence a possible run of the correct algorithm on parking configurations in terms of the sorted configurations is Algorithm selecting a run for the rank on sorted configurations: Input: A sorted parking configuration u on K n rank ← −1; While u n 0 do u ← sort(park(E.u));rank ← rank + 1; od; Output: rank(= rank(u)) This run is tightly related to the following spiral traversal of some cells of the cut skew cylinder such that u = scompact[m ⇒ m vb; s].We define S [m vb] (s) = min{s |s > s and s ∈ L[vb s]} which is the minimal spiral coordinate strictly greater than s of a left cell in cylinder[m vb].
Algorithms for the rank via a spiral traversal on a cut skew cylinder: The 14 visited cells in the left component contains a green disk so the returned value for the rank is 13.These two versions of the spiral traversal produce exactly the same values since all the additional cell visited in the extended version belongs to the right component by definition of S [m vb] (m + s).The extended spiral is closer to the algorithm selecting a run for the rank while the shortest spiral induces more symmetries in the forthcoming the enumerative studies.
This paragraph consider the connection between the extended spiral traversal for the rank and the selected run on sorted configurations for the rank.We discuss the beginning of this spiral traversal, if any.If s < 0, then S [m vb] (m+s) m so there is no loop iteration and the output rank = −1 as expected.Otherwise, let j = S Proof.The discussion preceding this proposition shows that the correct algorithm on sorted configurations with input u is simulated by the traversal algorithm on cylinder[m vb] so that both return rank(u).
We recall that by definition all the cells of spiral indices from m+s+1 to S [m vb] (s)−1, if any, are right cells so the extended and shortest spiral traversals, which differs only by these cells, returns the same value.We can also recover from the shortest traversal a proof g for the rank of the sorted parking configuration u = scompact[m ⇒ m vb; s].For a cut skew cylinder and i = 1 . . .n − 1 we define the set L i [m vb; s] of left cells of spiral coordinate at most m + s and on the same row as the step related to a m↑i the i-th step of the oriented segment a n−1 starting at m. Proof.In the correspondence between the selected run on sorted configurations and the extended traversal, a grain (i)  Theorem 12. (Formula for the rank of a sorted parking configuration) Let u be a sorted parking configuration on K n and u n + 1 = q(n − 1) + r the euclidean division of u n + 1 by n − 1.
and the proof for the rank found from the algorithm selecting a run for the rank by collecting removed grains is g = (max(0, q − i + 1 + u i + χ(i r); 0).
In this proof, we consider that the visited cells during the traversal algorithm are exactly the cells with spiral coordinate from m to m+s, if any.It means that we deliberately ignore the cells of spiral coordinates from m+s+1 to m+S [m vb] (m+s)−1.These cells are necessarily right cells by definition of S [m vb] (m + s).With this convention, the number of visited cells on the row crossed by a m↑i is q + χ(i r).Moreover, on this row the traversal begins by visiting all the right cells of spiral coordinate at least m.These cells are counted by i − 1 − u i 0 by definition of scompact[m ⇒ m vb; s].We conclude that since the visited left cell on the row crossed by a m↑i are the visited cells minus the possibly first visited right cells.This shows that g is the proof computed by the traversal algorithm and a summation leads to the formula for the rank.

Optimizing the search of the equivalent sorted parking configuration
We describe here an efficient algorithm to compute for any configuration u on K n the toppling and permuting equivalent configuration sort(park(u)).

Search toppling and permuting equivalent sorted parking configuration
Let k imax = q(n − 1) + r be the euclidean division by n − 1 defining q and r; For i from 1 to n − 1 do u i ← u ((i−1−r) mod (n−1))+1 − q + r + χ(i r);od; u n ← u n + k imax ; Output: The configuration u (= sort(park(u))).
Proposition 13.The preceding algorithm correctly returns u = sort(park(u)) and may be implemented with a linear arithmetic complexity.
Proof.First we show that this algorithm is correct.
We implicitly use a formula for T j .uwhere j ∈ Z and u is a sorted compact configuration: where j = q(n−1)+r is the euclidean division of j by n−1.This formula is obtain by iteration of the formula in the proof of 5. in Proposition 9. Roughly speaking, u (i−1−r mod n−1)+1 takes into account the cyclic permutations induced by T r , −q corresponds to the −q topplings of the sink, +r to the r topplings of vertices in T r and −nχ(i r) compensate in the case where the vertex is toppled once during the computation of T r .
The configuration u = sort(compact(u)) is a sorted and compact configuration.We search the power j ∈ Z such that T j .u= u = sort(park(u )).If u = T j .u is sorted and parking then in particular u 1 = 0. We use this equality as a criterion to filter the possible values of j.We discuss the n − 1 possible values of r and indeed the two values of χ(1 r).It will appear that for each value there exists a single value j r such that u (r) := T jr .usatisfies u (r) 1 = 0.For any choice of r, let j r = q r (n − 1) + r the euclidean division by n − 1 of this hypothetical j r and i = (1 − r) mod (n − 1) + 1.We then use the preceding formula for T jr .u .If r = 0 then i = r + 1 and u (r) Hence, the expected value of j appears in {(n − 1)u i + n(i − 1)} i=1...n−1 also called the {k i } i=1...n−1 in the algorithm.
We may write u = scompact[k ⇒ 0 w; s] for k = (n − 1)u 1 , s = u n and some almost balanced word w.Since by definition T jr .u= u (r) = scompact[k − j r ⇒ 0 w; s + j r ] satisfies u (r) 1 = 0, the cell of spiral coordinate k − j r is a left cell of cylinder[0 w].In the cut skew cylinder related to the sorted and parking u = T j .u the cell k − j should also be min L[0 w] according to 6. in Proposition 9.This means that j is the maximal value among the {j r } r=1...n−1 = {k i } i=1...n−1 .This value is called k imax in the algorithm.This algorithm is correct since it returns u = T k imax .ucomputed via the first formula of this proof.
Then we discuss how this algorithm may be implemented within a linear arithmetic complexity also called O(n).
The explicit definition of compact(u) may be evaluated in O(n).The sort of the compact configuration u = compact(u) may be performed in O(n) using a classical sort by values since those values are between 0 and n − 1.More precisely we use a vector v = (v i ) i=0...n−1 initialized to v = 0 ∈ Z n−1 , then we increment v[u i ] for i = 1 . . .n − 1 and finally we compute sort(u ) has the concatenation of blocks of v i values i for i from 0 to n − 1.Our model of complexity is called arithmetic since we assume that an euclidean division or a comparison may be performed in constant time, no matter of the size of the involved integers.Within this framework, the evaluation of the k i , the search of the the electronic journal of combinatorics 23(1) (2016), #P1.31 maximal element max{k i } i=1...n−1 by a classical loop and the evaluation of T k imax .uare explicitly in O(n).Theorem 14.There exists an explicit algorithm of linear arithmetic complexity computing the rank of any configuration on the complete graph K n .
Proof.Let u be a configuration on K n .We compute u = sort(park(sort(compact(u)))) in O(n) via the preceding algorithm.Then we return rank(u )(= rank(u)) computed via an evaluation in O(n) of the formula in Theorem 12.

Enumerative byproducts related to the context
The degree and rank parameters are the two parameters on configurations involved in the Riemann-Roch theorem for graphs.These two parameters are invariant by toppling and permuting vertices.We use as canonical element the unique sorted and parking configuration in each equivalence class by toppling and permuting.Hence, a natural generating function in this context is where u runs on sorted parking configurations on K n .This series is not a usual power series since degree(u) may be as small as wished however if is a formal Laurent series.x 2 y 2 x 3 y 3 x 4 y 4 x 5 y 5 x 6 y 6 x 7 y 7 Inspection of the data for the small values of n leads to conjecture a symmetry.In the left part of Figure 3 we present the values in a two dimensional array where the cell (i, j) contains the coefficient [d i r j ]K 5 (r, d) for configurations on the complete graph K 5 of degree between −2 and 12.The complete support of K 5 (d, r) would require to add an half-infinite diagonal and an half-infinite horizontal line filled with the value 14.The coefficients 1, 4, 7, 10, 13, 14, 14, . . .along the diagonal starting at r −1 d 5 also appears along the bottom horizontal row starting at the same r −1 d 5 .This property also appears for the next pairs of diagonals and horizontal rows.In the right part of the same Figure 3, where u runs overs sorted parking configurations on K n .This generating function is a power series in x and y since by definition rank(u) −1 so xpara(u) 0 and ypara(u) 0 will be deduced from the proof of the conjectural symmetry M n (x, y) = M n (x, y).This symmetry will be proven by the involution of Riemann-Roch theorem detailed in Subsection 4.1.We will interpret this involution in terms of cut skew cylinders.This interpretation will provide in Subsection 4.2 an alternative definition of the parameters xpara and ypara in terms of the traversal computing the rank.Moreover,in Subsection 4.3 geometric sums will appear along these computations and their summations will lead to an expression for as a rather simple rational function involving two copies of a classical generating function on Dyck words.

On the involution in Riemann-Roch theorem
For the graph G, the Riemann-Roch theorem relates the ranks of configurations u and K G − u on G.The map u → K G − u is an involution.For the complete graph G = K n , we have K G = (n−3; n−3).In this case, this involution combines nicely with the equivalence by toppling and permutation: if u and v are toppling and permuting equivalent then also are K G − u and K G − v.This leads to the involution on sorted parking configurations on K n , ξ.u := sort • park(K G − u).
Proof.The proof is similar for any configuration u on K n .The Riemann-Roch theorem applied to u implies that Applying the same proof to K G − u, we obtain ypara(K G − u) = xpara(u).
Corollary 16.For any n 1, we have M n (x, y) = M n (y, x).
the electronic journal of combinatorics 23(1) (2016), #P1.31 This involution ξ corresponds to an natural involution on cut skew cylinders.Roughly speaking, the involution on cut skew cylinders consists in reversing the order in which the cells are visited along the spiral traversal.
For a word w = w 1 w 2 . . .w k the reverse word is w = w k w k−1 . . .w 1 .For any Dyck word w, let w = f abg be the last maximum factorization where |f a| a − |f a| b is the longest prefix p of w where the maximal value |p| a − |p| b is reached.We define the map ξ(w) := a f bg.
This map is an involution since in the last maximum factorization f abg of ξ(w) we have f a = a f and bg = gb.A restriction of this involution ξ appears in previous work of one of the authors [27].
In terms of cut skew cylinder, the involution ξ on sorted parking configurations will map the cell of spiral coordinate to a cell of spiral coordinate C(w) − s where by definition Proposition 17.Let u = scompact[0 ⇒ 0 wb; s] be a sorted parking configuration on K n and w = f abg the last maximum factorization of w.We have  w ; s] as the image via the central symmetry with respect to the origin exchanging left and right and also top and bottom.An example is provided in Figure 4 where in red are the initial data and in green the new data.In this case, the green oriented segment 21 ↑ is reversed to become the red oriented segment 62 ↑.Inspection shows that k = −n 2 + 3n − 1 − k, m = 2n − 1 − m, and w = w.We also have since the differences of abscissa are opposite and the order of steps in the oriented segment k ↑ reversed compared to k ↑.We then use this superimposition principle in the proof of Proposition 17.

Proof. By definition, we have sort(K
the electronic journal of combinatorics 23(1) (2016), #P1.31 We factorize w in w = f abgb where v = f abg is the factorization at last maximal height of the Dyck word v defined by w = vb.Using the superimposition principle of Lemma 18 and changing the value of u n to its opposite, we have It appears that a f bgb = ξ(v)b is a cyclic conjugate of bgba f .According to 2. in Proposition 9, we change the start of the cut to make appear this cyclic conjugate: On one hand w is a cut, so we have n|w| Using 3. of Proposition 9, we increment the labeling of cells by C(w) so that the cut starts in cell 0: Adding n(n − 3) (n) modifies only the value on the sink n and the n − 3 topplings of this sink n are equivalent to T (1−n)(n−3) hence using 5. of Proposition 9 we obtain According to 6. (and then 5.) in Proposition 9, we apply T 3(1−n)+C(w) to obtain the toppling and permuting equivalent parking configuration sort(park(K Kn − u)) = ξ.u with the claimed expression in the proposition.We illustrate these definitions in Figure 5 in the particular case w = vb where v = aabaaabbabbabb is a Dyck word and so m = 0, and s = 10.This factorization w = vb is also proven by the dashed green diagonal.The traversal of cells computing rank(scompact[0 ⇒ 0 vb; s]) visits the cells of spiral coordinate from 0 to s and those cells are crossed by a green diagonal arrow in north-west direction.There the cells of CL[0 vb; s] = {0, 7, 8, 9} are marked by a green disk and the cells of UR[0 vb; s] = {11, 12, 18} by a red disk.The other identity is deduced from this first identity via an extension of the superimposition principle to the traversals computing the rank of u and ξ.u.An example of this superimposition with traversals is given in Figure 5.The green oriented vertical segment toward north, which defines u, starts from the south-east corner of spiral green coordinate 0. In red, we describe the same notions as in green but on

Interpretation of (xpara, ypara) on cut skew cylinders
The dashed red diagonal (drawn in two parts) matches ξ(w), the red oriented vertical segment toward south, which defines ξ.u, starts from the north-west corner of red spiral coordinate 0 and the visited cells during the computation of the rank of ξ.u are crossed by red diagonal arrows toward the south-west.
First we assume that s 0 and C(w) − s − 1 0 as in Figure 5.It means that (s + 1) + (C(w) − s − 1 + 1) = C(w) + 1 cells are crossed.This number corresponds exactly to the number of cells of spiral between the cell of spiral green coordinate 0 and the cell of spiral red coordinate 0. Hence the green and red sequences of diagonals both ends in the black disk which is the south-east corner of the cell of green spiral coordinate s+n(= 18 on example).Since the involution ξ on skew cylinders exchange left and right components, we deduce that the cells of spiral green coordinate UR[0 wb; s] are also the cells of spiral red If s < 0, then only red diagonal arrows may exist.Inspection shows that UR[0 wb If C(w) − s − 1 < 0, then only green diagonal arrows may exist.We have s C(w) = max(R[0 wb]s) so UR[0 wb; s] is empty.In addition, the value C(w) − s on the sink of ξ.u implies that this configuration is non-effective so rank(ξ.u)= −1.Hence, it this case one also has |UR[0 wb; s]| = 0 = xpara(ξ.u)= ypara(u).

Enumeration of sorted parking configurations according to (degree, rank)
According 7. in Proposition 9, the bijective decomposition u = scompact[0 ⇒ 0 vb; s] of sorted parking configuration on K n where v is a Dyck word of size n − 1 implies that x left[0 vb;s] y right [0 vb;s]   where v runs over Dyck words of size n − 1.We introduce a partial sum of M n (x, y) indexed by a Dyck word v: We also introduce a slightly more general and redundant notation for monomials in these sums First, we study independently each M v (x, y) for each Dyck word v defining the sorted and parking configurations (scompact[0 ⇒ 0 vb; s]) s∈Z .The partition (L[0 vb], R[0 vb]) of cells indexed by their spiral coordinate induces a partition of Z into maximal intervals totally contained either in L[0 vb] or R[0 vb].We describe this partition in intervals with the maximal elements of each interval, if any.This leads to the sets Lemma 20.Let v be a Dyck word and H(x, y) := 1−xy (1−x)(1−y) .We have The notation of the proof are illustrated in Figure 6.
To observe that on a given interval I of this partition, the sum s∈I M [0 vb;s] is a geometric sum of reason x or 1/y, the following key discussion comes directly from the definition of CL[0 vb; s] and UR[0 vb; s]: the electronic journal of combinatorics 23(1) (2016), #P1.31  using previous discussion for s = j − 1.This leads to the geometric sum of reason x Similarly, for i = 1, . . .k and the intervals [l i + 1, r i+1 ], we obtain geometric sums of reason 1/y leading to For the two remaining infinite intervals ]−∞, r 1 ] and [r k+1 +1, +∞[ we obtain respectively, after an inversion of summation order over first interval, In the sum M v (x, y) = +∞ j=−∞ M [0 vb;j] decomposed into geometric sum on these intervals, each term M [0 vb;r i ] appears twice for a total factor of H(x, y) = x 1−x + 1 1−y and each term M [0 vb;l i ] also twice for a total factor −H(x, y) as expected.
the electronic journal of combinatorics 23(1) (2016), #P1.31 q q q q q q q q q q q q q q q z z z z z z Figure 7: A Dyck path of size 6, area 5 and augmented area 11 Our final expression for M(x, y; z) = n 1 M n (x, y)z n uses the generating function of Dyck words/path according to the size and the area.Figure 7 contains in blue an embedding of the Dyck word aababbaaabbb as a Dyck path.Graphically, the area of the blue Dyck path is the number of cells completely included between the Dyck path and the dashed diagonal.We use the equivalent following definition in terms of words.The where f a runs over all prefixes of v ending by an occurrence of letter a.The size of the Dyck word v is denoted by size(v) := |v| a .The Carlitz q-analogue of Catalan numbers is where v runs over all possibly empty Dyck words.The augmented area of a Dyck path consists in adding to the area the cells crossed by the dashed diagonal in Figure 7.These cells also contain the variable z to suggest that its are counted by the size of the path.Hence the augmented area of v is area(v) + size(v) and the generating function of Dyck words according to augmented area and size is C(q; qz).This generating function will appear in our proof via its interpretation as the cells between the blue and orange paths in Figure 7   Proof.The assumption n 3 is comfortable in our generic proof that may degenerate for n = 1 or n = 2. Hence, we first consider that n = 1 and then n = 2.If n = 1, the sorted parking configurations are the ((; s)) s∈Z and degree((; s)) = s and rank((; s)) = max(−1, s).So K 1 (r, d) = s∈Z d s r max(−1,s) and after the change of variable, we have L 1 (x, y) =  The sequence of cells (r i + k) k=1...n−1 contains the minimal cell in each row of spiral coordinate strictly greater than r i .In Figure 8 at left, it corresponds to the cells crossed by the dashed blue diagonal.This observation proves that L In Figure 8, the cut skew cylinder cylinder[r i + n (ba) n−1 b] corresponds to the orange path.
By choice, r i ∈ R[0 vb] and r i + 1 ∈ L[0 vb] so the vertex in south-east corner of cell r i + n belongs to the cut of cylinder[0 vb] and is preceded and followed by east steps.Changing the start of the cut to Intersecting the two preceding observations, we have The embedding of (ba) n−1 b and bf b both starts at the same vertex r i + n.We factorize bf b at its steps which are common with those of (ba) n−1 b.In Figure 8  The proof for a cell l i is very similar and illustrated by the right example in Figure 8.The choice l i ∈ L[0 vb] and l i + 1 ∈ R[0 vb] implies that the vertex l i + n belongs to the cut of cylinder[0 vb] and is preceded and followed by north steps.Hence when the vertex l i + n is chosen as the start of the cut, it makes appear a cyclic conjugate af a of vb such that cylinder[0 vb] = cylinder[l i + n af a].We have The factorization of af a at the common steps of the embedding of af a and (ba) n−1 b leads to words in (Y − )b(XaYb) * (X − ) where the first Y factor and the last X factor are non empty due to the distinct extreme steps of these two embeded words.Hence we have, where v runs over Dyck words of size at least 2. We conclude the proof by a summation following Lemma 20 to get the expected expression.

Enumerative byproducts related to q, t-Catalan numbers
In a Dyck word v we denote by a i the i-th of the occurence of the letter a in the word v.The height h(a i ) of a i is defined by |p| a − |p| b where v = pa i q is a decomposition defining the prefix p.The letter a i and a j in the Dyck word v are in dinv-interaction if either i < j and h(a i ) = h(a j ) or j < i and h(a j ) = h(a i ) + 1.The parameter dinv(v) of the Dyck word v is the number of dinv-interactions in v. Haiman, quoted by Haglund [23], devised this statistic to provide a combinatorial interpretation of where v runs over Dyck words of size n.These polynomials initially appears as Hilbert series of some space of multivariate polynomials, see again [23] for the context.The algebraic definition of these Hilbert series has an obvious symmetry implying that C n (q, t) = C n (t, q).This symmetry has still no elementary explanation in terms of the combinatorial interpretation, see [24] a recent chapter due to Haglund.This work is not the first connection between the sandpile model and these q, t-Catalan numbers.For example, in [19], one of the author with his co-author interprets on sorted recurrent configurations the pair of statistics (area, bounce) also defining the same q, t-Catalan numbers.Classicaly the area parameter corresponds to the number of grains outside the sink.The bounce parameter, not defined in this paper, corresponds to the cumuled elapsed time on vertices before toppling in the maximally parallel execution of the Dhar criterion which topples the sink and then once all other vertices.
Hence, the additional results of this section are strengthening the connection between the sandpile model on K n and these q, t-Catalan numbers.Subsection 5.1 shows that the parameter dinv is preserved by the map ξ.Subsection 5.2 details a relation between ξ and a map ζ due to Haglund which maps the bistatistic (dinv, area) to the bistatistic (area, bounce).Subsection 5.3 introduces the parameter prerank(w) := area(ξ(w)) which appear in one of our ealy optimisation of the algorithm for the rank.The bistatistic (prerank, dinv) is another possible definition of C n (q, t).

A dinv statistic on cut skew cylinders.
The involution ξ on Dyck words related to the Riemann-Roch theorem for graphs preserves the dinv parameter.
The postponed proof of this proposition is based on a definition of a parameter cdinv on the cylinder cylinder[m w] such that dinv(v) = cdinv(cylinder[0 vb]).Then the superimposition principle will imply the proposition.
The (left-)contacts (c i ) i=1...n−1 in the cut skew cylinder cylinder[m w] are the cells where c i is the smallest spiral coordinate for a left cell in the row crossed by a m↑i .Two distinct contacts c i and The cyclic-dinv parameter cdinv(cylinder[m w]) is the number of pairs of contacts in cdinv-interaction.
In Figure 5 the green spiral coordinates of contacts for cylinder[0 aabaaabbabbabbb] are (c i ) i=1...n−1 = (0, 8, 9, 17, 25, 19, 13) so a 3 }, {a 2 , a 7 }, {a 3 , a 7 }, {a 7 , a 4 }, {a 7 , a 6 }, {a 4 , a 6 }, {a 6 , a 5 }}| Proof.The contacts c i and c j where i < j are in cdinv-interaction in cylinder[0 vb] if and only if either c i < c j and then h(a i ) = h(a j ) so a i and a j are in the first kind of dinv-interaction or c j < c i and then h(a i ) = h(a j ) + 1 so a j and a i are in the second kind of dinv-interaction.Hence cdinv(cylinder[0 vb]) = dinv(v).
Then we consider the superimposition of u = scompact[0 ⇒ 0 vb; s] and ξ.u = scompact[0 ⇒ 0 ξ(v)b; C(vb) − s] like in Figure 5.We remind that the spiral green coordinate k ∈ Z of a cell corresponds to the usual spiral coordinate in cylinder[0 vb] while the red spiral coordinate C(w)−k corresponds to the coordinate in the superimposed cylinder[0 ξ(v).b].We consider the contact of green spiral coordinate c i in cylinder[0 vb].By definition, the east side of c i belongs to the cut.The other cell at east sharing this side has green coordinate c i − (n − 1) and red coordinate For any other contact c j , a similar proof leads to the contact where bounce is a statistic still undefined in this paper, see [23].An anonymous referee for a conference where this work was presented [12] suggested to study possible relations between the maps ζ and ξ.We use the notation R(w) := κ( w) for a word w to describe the relation we found between ξ and ζ.In other words, the operator R reverses the letters of v and then replace each letter a by a letter b and each letter b by a letter a.
Proposition 23.For any Dyck word v, we have The proof of this proposition is based on reformulations of the ζ map in our framework and leads to another application of the superimposition principle.The height vector of a Dyck word v of size n is (h(a i )) i=1...n where we recall that a i is the i-th occurrence of a letter a in v.
Proof.We reformulate Haglund's definition of ζ(v) by the following equivalent algorithm on the height vector: Haglund's ζ map via height vector Input: v of size n − 1 w ← ; For h from 0 to n do Haglund's definition is slightly different and a bit more trickier.It distinguishes as particular the two degenerated loop iterations for h = 0, where no letter b can be read and for h = 1 + max i h(a i ) where no letter a can be read.Moreover it reads the height vector and the factors η h from right to left.It is left to the reader to figure out that our definition is equivalent.In Figure 9, we use the same example as Haglund (see page 50 in [23]).We embed our first algorithm describing the ζ map in a cut skew cylinder.The spiral traversal visit the cells diagonals by diagonals drawn in orange.Split diagonal by diagonal, this traversal corresponds to the nested loops on h and i in the algorithm defining ζ via the height vector.We consider the cells visited during the traversal of the h-th diagonal supposed to define η (h) .If a cell is a contact c i in this diagonal, it means that the a step in vb in the same row is at height h in v.So it exactly corresponds to adding a letter a to η (h) .We mark such a cell by a green letter a in the cell c i .If a cell is c j + (n − 1) where c j is a contact, it means that the a step in vb in the same row is at height h − 1 in v.So it exactly corresponds to adding a letter b in η (h) .We mark such a cell by a green letter b in the cell c j + (n − 1).Since the traversal of the diagonal respect the order of the inner loop on i in the algorithm, we deduce that η (h) is also define by the order in which the preceding cells c i or c j + (n − 1) are visited.These observation should convince the reader that the second algorithm entitled "Haglund's ζ map via traversal" also defines the ζ map.On the example, collecting the green letters on each orange diagonal leads to η (0) = a,η (1) = baa, η (2) = baaaba,η (3) = bbbab and η (4) = b.
We reformulated the definition of ζ into a spiral traversal since it is well suited for the superimposition principle.The proof is similar to the proof of Proposition 22 that ξ preserves the dinv parameter.We keep only the (green) spiral coordinates here.The vertical step defining the contact c i in vb shows that ζ(v) add a letter a in cell c i and a letter b in cell c i + (n − 1).But this vertical step also appears in ξ(v)b and in the computation of ζ(ξ(v)), we add a (red) letter a in cell c i − (n − 1) and a letter (red) b in cell c i − 2(n − 1).Moving the red letters two west steps and exchanging the red letters a and b on each row leads exactly to the position of the green letters.Then inspection shows that the reversed traversal in the computation of ζ(ξ(v)) leads also to R(ζ(v)).
Proposition 24.For any n 0, we have where v runs over Dyck words of size n.
We call this parameter prerank because of an early partial optimization of our algorithms computing the rank.A staircase (sorted parking) configuration u on K n is such that for i = n, u i = i − 1 and there are no restriction on u n .Any staircase configuration may be written u = scompact[m ⇒ m (ab) n−1 b; s].Applying 8. in Proposition 9, we have sort(park(u − (1) ) which is also a staircase configuration.By induction, we have Hence one may accelerate the algorithm computing the rank as soon as we reach a staircase configuration.It appears that, if s is big enough, the number of loops before we reach such a staircase configuration is finite and is exactly the prerank of the initial Dyck word in the cut vb.
6 Annex: A proof of the Riemann Roch Theorem for graphs We consider the following solitary game on an undirected (non oriented) connected graph G = (X, E) without loops: at the beginning integer values f i are attributed to the n vertices x 1 , x 2 , . . .x n of the graph, these values can be positive or negative and define a configuration f .At each step a toppling can be performed by the player on a vertex x i , it consists in subtracting d i (the number of edges incident to x i ) to the amount f i and for each neighbor x j of x i increase f j by the number of edges between these two vertices.In this operation the amount of vertex x i may become, or stay negative.The aim of the player is to find a sequence of toppling operations which will end with a configuration where all the f i are non negative.Since the sum of the f i is invariant by toppling, a the electronic journal of combinatorics 23(1) (2016), #P1.31 necessary condition to succeed is that in the initial configuration this sum should be non negative.We will see that this condition is not sufficient.
This game has much to do with the chip firing game (see [10], [9]) and the sandpile model (see [5], [15], [16]), for which recurrent configurations where defined and proved to be canonical representatives of the classes of configurations equivalent by a sequence of topplings (for a more algebraic treatment see also [31]).
The game was introduced and studied in detail by Baker and Norine in [6] who also introduced a new parameter on graph configurations: the rank.One characteristic of the rank ρ(f ) of a configuration f is that it is non negative if and only if one can get from f a configuration non-negative on every vertices by performing a sequence of topplings.For this parameter they obtain a simple formula expressing a symmetry similar to the Riemann-Roch formula for surfaces and curves (a classical reference to this formula is the book by H. Farkas and I. Kra [21]).
Our aim here is to give a simple presentation of this Riemann-Roch like theorem for graphs.It's wortwhile in this context to mention the independant work of Backman [3] and the precedings works [30,1].

Configurations on a graph
Let G = (X, E) be a multi-graph with n vertices, where X = {x 1 , x 2 , . . ., x n } is the vertex set and E is a symmetric matrix such that e i,j is the number of edges with endpoints x i , x j , hence e i,j = e j,i .In all this paper n denotes the number of vertices of the graph G and m the number of its edges.We assume that G is connected and has no loops, so that e i,i = 0 for all i.
We will consider configurations on a graph, these are elements of the discrete lattice Z n .Each configuration f may be considered as assigning (positive or negative) tokens to the vertices.The symbol ε (i) will denote the configuration in which the value 1 is assigned to vertex x i and the value 0 is assigned to all other vertices.
The degree of the configuration f is the sum of the f i 's it is denoted by deg(f ).

The Laplacian configurations
These configurations correspond to the rows of the Laplacian matrix of a graph, a classical tool in Algebraic Graph Theory.The Laplacian configuration ∆ (i) is given by: ∆ j) , where d i = n i=1 e i,j is the degree of the vertex x i .These configurations which degrees are equal to 0 play a central role.
We denote by L G the subgroup of Z n generated by the ∆ (i) , and two configurations f and g will be said toppling equivalent if f − g ∈ L G , which will also be written as f ∼ L G g.
In the sandpile model, the transition from configuration f to the configuration f −∆ (i) is allowed only if f i d i and is called a toppling.The same condition is assumed in the theory of chip firing games, and toppling is called firing; here we omit this condition and perform topplings even if f i < d i .
the electronic journal of combinatorics 23(1) (2016), #P1.31 Notice that n i=1 ∆ (i) = 0 and that for a connected graph this is the unique relation (up to multiplication by a constant) satisfied by the ∆ (i) , moreover the principal minors of the Laplacian matrix are all equal to the number of spanning trees of the graph.

Recurrent configurations
We use in this section the notation usually considered in the sandpile model, so that we will call sandpile configuration a configuration f such that f i 0 for all i < n.This corresponds to the fact that in the sandpile model the vertex x n is considered as a sink collecting tokens, so that the number of tokens of the sink has not taken into account in this context.Definition 25.In the sandpile model, a toppling on vertex x i , where i = n, may occur in a sandpile configuration only if f i d i .A sandpile configuration f is stable if no toppling can occur, that is f i < d i for all i < n.
Notice that when a toppling occurs in the sandpile model, the configuration f − ∆ (i) is also a sandpile configuration.
The toppling operation for a sandpile configuration will be denoted by f → g.We also write: f * → g if f and g are sandpile configurations and if g is obtained from f by a sequence of toppling operations meeting only sandpile configurations.Notice that f * → g implies f ∼ L G g. Sequences of topplings may be performed in any order until a stable configuration is attained as the following proposition states, the proof of which may be found in [17] or in [26] pages 42, and 70.Proposition 26.For any sandpile configuration f there exists a unique stable configuration f such that f * → f .A configuration is recurrent in an evolving system if it could be observed after a long period of the evolution of the system.In the case of the sandpile model, the system is considered to evolve by adding a token in any cell at random and then applying topplings until a stable configuration is reached.This translates into the following notion which is central : Definition 27.A configuration f is recurrent if it is stable and there exists a sandpile configuration g = 0 such that f + g * −→ f .
The following important result, giving canonical representatives in the classes of the relation ∼ L G is obtained in [14,9,13] by different ways.
Theorem 28.For any configuration f there exists a unique recurrent configuration g such that f ∼ L G g.
In order to characterize the recurrent configurations D. Dhar used the configuration ∆ (n) and proposed the following algorithm.
Theorem 29.Burning Algorithm.A stable configuration u is recurrent if and only if Moreover in this sequence of topplings each vertex different from x n topples exactly once.
This algorithm can be translated into another characterization, giving: Corollary 30.A stable configuration f is recurrent if and only if for any non-empty subset Y of X \ {x n } there is at least an x k in Y such that its degree in the subgraph spanned by Y is not greater than f k , more precisely if the following condition is satisfied: Proof.Let f be a recurrent configuration, and Y be a subset of X, then by Dhar's Burning Algorithm, starting from the configuration f − ∆ (n) there is a sequence of topplings of the vertices in which any vertex topples.We may suppose that the vertices are numbered in the order in which they topple, x 1 just after x n , then x 2 and so on until x n−1 then for allowing a toppling at vertex x i each f i has to satisfies the condition: Now for any subset Y of X, let k be the smallest integer such that x k ∈ Y , then since there is no x i ∈ Y with i less than k we have: Putting i = k in the first inequality and the two inequalities together gives the result.Conversely if f is a stable configuration satisfying condition 1 we build a toppling sequence starting with vertex x n , then taking as x 1 the vertex in Y = {x 1 , x 2 , . . ., x n−1 } satisfying f 1 n−1 i=2 e 1,i , this vertex can topple after x n since in that case f 1 + e 1,n n i=2 e 1,i = d 1 .Then at each step, a vertex x j such that f j n−1 i=j+1 e i,j exists taking Y = X \ {x n , x 1 , x 2 , . . .x j−1 }, this vertex can topple at this stage.We have thus built a sequence of toplings proving that f is recurrent.

Parking configurations
We consider a kind of dual notion to that of recurrent configuration, such configurations are often called parking configurations since in the case of complete graphs, these are exactly the parking functions, a central object in combinatorics.Definition 31.A sandpile configuration f on a graph G is a parking configuration if for any subset Y of X \ {x n } there is a vertex x k in Y such that f k is less than the number of edges which are incident to x k and a vertex out of Y .More precisely if the exists x k ∈ Y such that f k < x i / ∈Y e i,k .
the electronic journal of combinatorics 23(1) (2016), #P1.31 In other words a sandpile configuration f is a parking configuration if and only if there is no toppling of all the vertices in a subset Y of {x 1 , x 2 , . . .x n−1 } leaving all the f i 0. For this reason these configurations are also called superstable (as for instance in [31]).
Proposition 32.Let f be a stable configuration and let δ be the configuration such that δ Proof.It suffices to compare Corollary 30 and Definition 31 and to notice that: Corollary 33.For any configuration f there exists a unique parking configuration g such that f ∼ L G g.
Proof.For any configuration f let g be the recurrent configuration such that g In this paper we will often consider the parking configuration in a class as a representative of this class.A parking configuration f in a graph with n vertices will be represented by the subsequence consisting of this first n − 1 terms and an integer s such that: hence s represents the number of tokens on the distinguished often called " sink " vertex x n .

Parking configurations and acyclic orientations
An orientation of G is a directed graph obtained from G by orienting each edge, so that one end vertex becomes the head and the other one the tail.A directed path in such a graph consists of a sequence of edges such that the head of an edge is equal to the tail of the subsequent one.
The orientation is acyclic if there is no directed circuit, i.e. a directed path starting and ending at the same vertex.We associate to any parking configuration f an acyclic orientation by : Proposition 34.For any parking configuration f on G = (X, E) there exists at least one acyclic orientation − → G such that for any vertex x i , i = n, f i is strictly less than its indegree d − i (i.e. the number of edges with head x i ).Proof.We orient the edges using an algorithm that terminates after n steps.Consider Y = {x 1 , x 2 , . . ., x n−1 }.From the definition of parking configurations, there is at least one vertex x i such that f i < e i,n then orient all these e i,n edges from x n (the tail) to x i (the head), and remove x i from Y .Repeat the following operation until Y is empty: ∈Y e k,j ; orient all the edges joining any vertex j outside Y to x k from x j to x k and remove x k from Y .
In the preceding proof one may recognize a scheduling of topplings related to the Dhar criterion applied to the recurrent configuration β(f ).Notice that more precise results involving maximal parking configurations are given in [8].

Effective configurations
In this section we define the notion of L G -effective configuration and recall the main results of [6], the proofs we give in this section are more or less a reformulation in our terms of the proofs of them given in [6].The game described in the introduction can be translated in determining if a configuration is L G -effective with the following definition of effectiveness: Definition 35.A configuration f is effective if f i 0 for all i.A configuration f is L G -effective if there exists an effective configuration g toppling equivalent to f (recall that this means f − g ∈ L G ).
Since two equivalent configurations by ∼ L G have the same degree, it is clear that a configuration with negative degree is not L G -effective.However we will prove that configurations with positive degree are not necessarily L G -effective as these two examples show:   ).We will show that for any linear combination g = n i=1 a i ∆ (i) the sum h of g and f is not an effective configuration.Let ε i,j denote the number of edges with head x j and tail x i in − → G .Then e i,j = ε i,j + ε j,i (but notice that since the orientation is acyclic, at least one of the two values in the sum above is equal to 0).
For any vertex x i of G we have d − i = n j=1 ε j,i so that: a j e i,j Using d i = n j=1 e j,i and decomposing each e i,j into ε i,j + ε j,i gives for any i: Separating the edges for which x i is a head in − → G form those for which it is a tail, we get: Now take i be such that a i j for all j = i, we have a i − a j 0 and 1 + a i − a j 1.If there is a unique minimal value in the sequence a j we have 1 + a j − a i 0, hence h i < 0.
the electronic journal of combinatorics 23(1) (2016), #P1.31 If there are many a i 's attaining the minimal value take k among them such that ε j,k = 0 for all the j such that a j = a k .The existence of such a k follows from the acyclicity of − → G .Then for this k we have h k < 0.

Characterization of L G -effective configurations
We can see that computing the parking configuration toppling equivalent to a given configuration allows to determine if it is effective since we have Proposition 37. A configuration f is L G -effective if and only if the parking configuration g equivalent to f is such that g n 0.
Proof.If g n 0 g is effective so that f is L G -effective.If f is L G -effective then there exists an effective configuration h such that f ∼ L G h. Then g is the unique parking configuration such that h ∼ L G g, it may be obtained form h performing subset topplings.These do not decrease the value of h n , hence g n h n 0.
The following Theorem is the central result in [6].
Theorem 38.For any configuration f one and only one of the following assertions is satisfied: (1) But the degree of this configuration is negative, giving a contradiction.

The rank of configurations
From now on it will be convenient to denote effective configurations using greek letters λ, µ and configurations with no particular assumptions on them by letters f, g, h.

Definition of the rank
Definition 40.The rank ρ(f ) of a configuration f is the integer equal to: • or, if f is L G -effective, the largest integer r such that for any effective configuration λ of degree r the configuration f − λ is L G -effective.
Denoting P the set of effective configurations and E the set of L G -effective configurations this definition can be given by the following compact formula which is valid in both cases: In other words let f be a configuration of rank ρ(f ) and λ be an effective configuration such that deg(λ) ρ(f ) then f − λ is L G -effective; moreover there exists an effective configuration µ of degree ρ(f ) + 1 such that f − µ is not L G -effective.
An immediate consequence of this definition is that if deg(f ) < 0 or if f = C( − → G ) for an acyclic orientation − → G then the rank of f is −1.Moreover if two configurations f and g are such that f i g i for all i then ρ(f ) ρ(g).
The following notion will be useful do prove properties of the rank: We give here a proof of the following theorem first proved in [6] which we estimate shorter and simpler than the original one.κ which may be written as: Giving that κ − f − µ is not L G -effective since the reverse of an acyclic orientation is also acyclic.Hence by the definition of the rank we have The degree of µ is obtained from (5) giving:

Definition 8 .
A cut skew cylinder cylinder[m w] and two additional integers k ∈ Z and s ∈ Z allow the definition of a configuration on K n scompact[k ⇒ m w; s] := (u i ; u n ) = (x(a i ) − x(a k↑i ); s) where the a k↑i for i = 1 . . .n − 1 are the n − 1 north steps of the oriented segment which the electronic journal of combinatorics 23(1) (2016), #P1.31

scompact[ 20 ⇒
10 abaababbabb; 39] = (2, 3, 3, 4, 6; 39) = (x(10) − x(20), x(11) − x(26), x(17) − x(32), x(18) − x(38), x(14) − x(44); 39).The properties of the description scompact[k ⇒ m w; s] require additional preliminary definitions.Two cells are connected in a cut skew cylinder if they share a common side which is not a step of the cut.In the cut skew cylinder cylinder[m w] there are two connected components of cells: the left component L[m w], which contains the cell m, and the other called the right component R[m w].A cell is left if it belongs to L[m w] and right otherwise.A Dyck word of size n is a word w on the two-letters alphabet A = {a, b} where for any prefix p of w, |p| a |p| b and in addition |w| a = |w| b = n.Any factorization w = w w defines a cyclic conjugate v = w w of the word w.The classical cyclic lemma due to Dvoreztky and Motzkin

3 . 4 .
w = w w of w ∈ D n we have cylinder[m w w ] = cylinder[m + n|w | a − (n − 1)|w | b w w ].For any p ∈ Z, we have scompact[k ⇒ m w; s] = scompact[k + p ⇒ m + p w; s].The map (v, k, s) → scompact[k ⇒ 0 vb; s] defines a bijection between the triplets made up of a Dyck word v of size n − 1 and two integers (k, s) ∈ Z 2 and the sorted and compact configurations on K n .

6 .
The configuration scompact[k ⇒ m w; s] is parking if and only if k = min L[m w] where we use the spiral coordinate for cells of L[m w].Moreover park(scompact[k ⇒ m w; s]) = T k−min L[m w] .scompact[k⇒ m w; s] = scompact[min L[m w] ⇒ m w; s + k − min L[m w]].7.The map (v, s) → scompact[0 ⇒ 0 vb; s] defines a bijection between the pairs made up of a Dyck word v of size n − 1 and one integer s ∈ Z and the sorted and parking configurations on K n .8. Let u = scompact[m ⇒ m vb; s] and v = af bg be the factorization at first return of the Dyck word v and j = min(L[m vb] − {m}) the second smallest spiral coordinate of a left cell, we have the electronic journal of combinatorics 23(1) (2016), #P1.31 corner of the cell min L[m w].This choice is correct by uniqueness of the toppling and permuting equivalent sorted and parking configuration.7. Let u = scompact[k ⇒ m w; s] be a parking configuration.According to 6., k = min L[m w] ∈ L[m w].Hence the cell k − (n − 1) sharing the vertical east side of the cell k belongs to R[m w].So this vertical side is a step of the cut of cylinder[m w] and according to 2. there exists a cyclic conjugate w of w and k ∈ Z such that u = scompact[k ⇒ k w ; s].According to 3., we have u = scompact[0 ⇒ 0 w ; s].We have min L[0 w ] = 0 so the cells (−i) i=1...n−1 belong to R[0 w ].This implies that w = vb where v is a Dyck word of size n − 1. Conversely, if u = scompact[0 ⇒ 0 vb; s] where v is a Dyck word of size n − 1, then min L[0 vb] = 0 so u is sorted and parking.The map (v, s) → scompact[0 ⇒ 0 vb; s] is obviously injective.Hence this map is the expected bijection.4. Let u be a sorted and compact configuration and u = sort • park(u).According to 6., there exists m ∈ Z such that u = T m .u .According to 8., u = scompact[0 ⇒ 0 vb; s] where v is a Dyck word of size n − 1 and s ∈ Z and the pair (v, s) is unique.Hence, according to 5., u = T m .scompact[0⇒ 0 vb; s] = scompact[m ⇒ 0 vb; s − m].The observation of the value on the sink n shows that all sorted and compact configurations (scompact[m ⇒ 0 vb; s − m]) m∈Z are distinct and toppling and permuting equivalent to u and also u. 8.By definition, m = min L[m af bgb].Inspection shows that the explicit occurrence of the letter b in the factor af b corresponds to the south side of the cell j.Hence j = m + |af b| a and the vertex j belongs to the cut.Changing the start of the cut from m to j, we also have u = scompact[m ⇒ j gbaf b; s].By definition the occurrence of the letter a in gbabf b, appears in the definition of u 1 .Hence the commutation of this occurrence of a with the preceding occurrence, which is necessarily a letter b, has two consequences.First, exactly u 1 is decremented by one, leading to the sorted and compact configuration E.u = scompact[m ⇒ j gabf b; s].Second, the left cell m in scompact[m ⇒ j gbaf b; s] becomes a right cell in scompact[m ⇒ j gabf b; s] since the cut visiting the south and east side of cell m in the first case, visits the west and north side of this cell after the commutation.As expected, we have L[j gabf b] = L[m af bgb] − {m}.Moreover, after the deletion of the smallest value m, the second smallest value j becomes minimal: min L[j gabf b] = j.By application of 6., we deduce that sort(park(E.u))= T m−j .E.u = scompact[j ⇒ j gabf b; s − (j − m)].

Figure 2 :
Figure 2: Calculation of the rank on a Dyck path [m vb] (m).We consider the iterations for k from m to j − 1.It visits j − m cells m,m + 1,. . .j − 1 where m is a left cell and all other cells are right while j is the next left cell.This part may be interpreted as the computation of sort(park(E.u))= scompact[j ⇒ j gabf b; s − (j − m)] as described by 8. in Proposition 9: move via operator E the left cell m = min L[m vb] to the right component, increment the rank, then visit via operator T −1 all the j − m cells starting at m in spiral order until you find the next left cell j = min L[j gabf b].In addition, the value of s is decremented at each visit of a cell so we have S [m vb] (m+s) = S [j gabf b] (j +s).Hence, by induction, we observe that this traversal simulates the run of the sorted version of the correct algorithm.Proposition 10. (Reading a proof for the rank using spiral traversals) Let u = scompact[m ⇒ m vb; s] be a sorted parking configuration.The extended spiral traversal for the rank on cylinder[m vb] returns rank(u).

Proposition 11 .
(Reading a proof for rank in spiral traversals) Let u = scompact[m ⇒ m vb; s] be a sorted parking configuration on K n .The configuration g = (g i ; g n ) := (|L i [m vb; s]|; 0) is a proof for rank(u).
is removed on the vertex i each time a cell of the row related to u i is moved from the left to the right component.All such left cells are the left cells in L[m vb] of spiral coordinate between m and m + s since between m + s + 1 and m + S [m vb] (m + s) − 1 there are only right cells, if any.When those cells are partitioned the electronic journal of combinatorics 23(1) (2016), #P1.31 into rows, it corresponds exactly to the definition of L i [m vb; s].Hence g i count the number of removed grains on vertex i during the algorithm so g is a proof for the rank of u according to the sorted version of the correct greedy naive algorithm.It appears that the (|L i [m vb; s]|) i=1...n−1 may be efficiently computed via a single euclidean division.

Figure 3 :
Figure 3: Part of the support of K 5 (r, d) and the related support of M 5 (x, y)

2 − 2 −
the electronic journal of combinatorics 23(1) (2016), #P1.31 the change of variable (degree, rank) → (rank + 1, n−1 degree + rank) lay the values out so that the symmetry is the more explicit symmetry along the main diagonal.This motivates the definition of the two parameters xpara(u) := rank(u) + 1 and ypara(u) := n−1 degree(u) + rank(u) on a configuration u and the definition of the generating function M n (x, y) := u x xpara(u) y ypara(u)

Figure 4 :
Figure 4: Example of the superimposition principle
a + (n − 1)|w| b = 0, hence n|bgb| a − (n − 1)|bgb| b = −n|f a| a +(n−1)|f a| b .On another hand, since m = 0 = min L[0 w], C(w) = max R[0 f abg] is also the spiral label of the cell whose west vertical side is related to the explicit occurence of a in w = f abgb, hence C(w) = n|f a| a − (n − 1)|f a| b − (2n − 1).These two observations leads to Let u = scompact[0 ⇒ 0 vb; s] be a sorted parking configuration on K n .Let w a cyclic conjugate of vb and m ∈ Z be such that cylinder[m w] = cylinder[0 vb] proven by a change of the start for the cut.The parameters xpara(u) and ypara(u) admits a description in terms of cylinder[m w] and s.The crossed left cells of u = scompact[k ⇒ m w; s] are CL[m w; s] := {k|k s and k ∈ L[m w]}.We also consider the uncrossed right cells defined by UR[m w; s] := {k|k > s and k ∈ R[m w]}.We denote the cardinalities of these sets by left[m w; s] := |CL[m w; s]| and right[m w; s] := |UR[m w; s]| the electronic journal of combinatorics 23(1) (2016), #P1.31

Figure 6 :
Figure 6: Example of decomposition of M v (x, y) into an alternation of geometric sums.
or the symmetric picture according to the main dashed diagonal.Let Y be the language/set of possibly empty Dyck words and the empty word.So Y− denotes the language of non-empty Dyck words.Let κ the morphism on words defined on letters by κ(a) := b and κ(b) := a.Let X := κ(Y).For example, v = aababb ∈ Y and κ(v) = κ(a)κ(a)κ(b)κ(a)κ(b)κ(b) = bbabaa = ãababb.An alternative definition of X is the set of reverses of Dyck words in Y.For a language L, we recall a classical notion of formal languages: L * := ∪ n 0 L n where L n is formed by the concatenations of n words in L.

Figure 8 :
Figure 8: r i leads to bf b ∈ bXaY(bXaY) * b and l i leads to af a ∈ (Y − )b(XaYb) * (X − ) at left, the steps of the electronic journal of combinatorics 23(1) (2016), #P1.31 bf b are magenta if forced and otherwise blue while the steps of (ba) n−1 b are orange.Hence we factorize bf b at the blue (or magenta) and orange steps.This example should help to convince the reader that bf b = b(ba)a(aabb)b(ba)a()b is in general factorized as a word of bXaY(bXaY) * b.This factorization in non-ambiguous since the word (ba) n−1 b is constant and the factors in X and Y are well defined.Conversely, any word w ∈ bXaY(bXaY) * b such that |w| a 2 is almost balanced and may be written bf b and is a cyclic conjugate of some word vb where v is a Dyck word.Moreover, in the decomposition showing bf b ∈ bXaY(bXaY) * b, the augmented area of factors in X counts the cells of CL[0 vb; r i ] and the augmented area of factors in Y counts the cells of UR[0 vb; r i ].On the example of bf b = b(ba)a(aabb)b(ba)a()b, the first factor (ba) corresponds to {12} ⊂ CL[0 vb; r i ], the factor (aabb) corresponds to {4, 3, 3} = CL[0 vb; r i ] and the second factor (ba) corresponds to {8} ⊂ CL[0 vb; r i ] and the empty factor () in Y adds no cell to UR[0 vb; r i ].In terms of generating function, it leads to v r i ∈RL[0 vb] M [0 vb;r i ] = C(x; xz)zC(y; yz) 1 − C(x; xz)zC(y; yz) − z where v runs over Dyck words of size at least 2.More precisely, C(x;xz)zC(y;yz) 1−C(x;xz)zC(y;yz) is the generating function of all the almost balanced words written bf b according to the augmented area of factors X, counted by the variable x, and the augmented area of factors Y, counted by the variable y, and the size |bf b| a 1 counted by z.The subtracted term z corresponds to the excluded almost balanced word of size 1, bab.

Figure 9 :
Figure 9: Description of Haglund's ζ map via traversal of a cut skew cylinder

Figure 10 :
Figure 10: An L G -effective configuration and a non L G -effective one

Figure 11 :
Figure 11: An orientation of G and the corresponding configuration

2 )
There exists an acyclic orientation− → G such that C( − → G ) − f is L G -effective.Proof.Let f be non L G -effective, consider the parking configuration g equivalent to f and let − → G be the acyclic orientation given by Proposition 34, leth = C( − → G ) − g.Then for i = n we have h i = d − i − 1 − f i 0 and since g n < 0: h n = −1 + g n 0.Hence h is effective, moreover since f and g are in the same class, so areC( − → G ) − f and C( − → G ) − g = h showing that C( − → G ) − f is L G -effective.Notice that f and C( − → G ) − f cannot be both L G -effective since their sum C( − → G ) would be too, contradicting Proposition 36.Corollary 39.Any configuration f with degree greater than m − n is L G -effective.Proof.If f such that deg(f ) > m−n is not L G -effective, by the above theorem there exists an acyclic orientation − → G of G such that C( − → G ) − f is.

Definition 41 . 1 .
An effective configuration µ is a proof for the rank ρ(f) of an L G -effective configuration f if f − µ is not L G -effective and f − λ is L G -effective for any effective configuration λ such that deg(λ) < deg(µ).Notice that if λ is a proof for ρ(f ) then ρ(f ) = deg(λ) − Proposition 42.A configuration f of degree greater than 2m − 2n has rankr = deg(f ) − m + n − 1Proof.We first show that for any effective configuration λ such that deg(λ) = r, the configuration f − λ is L G -effective.This follows from deg(f − λ) = deg(f ) − r = m − n + 1 by Corollary 39.We now build a effective configuration λ of degree r + 1 such that f − λ is not L Geffective.Consider any acyclic orientation− → G of G and let g = f − C( − → G ) then g is L G -effective since its degree is equal to deg(f ) − m + n hence greater than m − n.Let λ be the effective configuration such that g ∼ L G λ, then f − λ is such that C( − → G ) ∼ L G f − g ∼ L G f − λ so that f − λ is not L G -effective by Proposition 36.And the Proposition results from:deg(λ) = deg(g) = deg(f ) − deg(C( − → G )) = deg(f ) − m + n = r + 1the electronic journal of combinatorics 23(1) (2016), #P1.31 6.3.2Riemann-Roch like theorem for graphs

Theorem 43 . 5 )
Let κ be the configuration such that κ i = d i − 2 for all 1 i n, so that deg(κ) = 2(m − n).Any configuration f satisfies:ρ(f ) − ρ(κ − f ) = deg(f ) + n − mProof.The main ingredient for the proof is to use Theorem 38 and remark that for any acyclic orientation− → G the orientation ← − G of G obtained from − →G by reversing the orientations of all the edges is such that:C( − → G ) + C( ← − G ) = κ.Let f be any configuration we first give an upper bound for ρ(κ − f ), we define λ to be a proof for the rank of f if f is L G -effective, and to be equal to0 if f is not L G -effective.So that ρ(f ) = deg(λ) − 1 in both cases.Since f − λ is not L G -effective, we have by Theorem 38 that there exists an acyclic orientation− → G of G such that C( − → G ) − (f − λ) is L G -effective, hence equivalent to an effective configuration µ.This may be written as:C( − → G ) − (f − λ) ∼ L G µ (Now consider the orientation ← − G of G obtained from − → Gby reversing the orientations of all the arrows, clearly C( − → G ) + C( ← − G ) = κ.Hence adding C( ← − G ) to both sides of (5) we have: