Theoretical Computer Science 307 (2003) 241 – 256
www.elsevier.com/locate/tcs
Watermelon uniform random generation with
applications
Nicolas Bonichon∗ , Mohamed Mosbah
LaBRI-Universite Bordeaux 1, 351 Cours de la Liberation, 33405 Talence, France
Abstract
Watermelons are particular con gurations of vicious walkers. In these con gurations, each path
starts and ends at the same ordinate. We present a simple uniform random generation algorithm
of watermelons based on enumeration formulas of star con gurations (with or without a wall).
The performance of this algorithm is better than earlier ones in the case of watermelons with
few walkers.
Using appropriate bijections, these algorithms can also generate underdiagonal paths, realizers
(or Schnyder Trees), twin parallelogram polyominoes according to their perimeter and width,
Baxter permutations according to the number of rises, etc. Moreover, we present some experimental results on the height of watermelons and realizers.
c 2003 Elsevier B.V. All rights reserved.
Keywords: Vicious walkers; Watermelon; Uniform; Random; Realizer; Baxter permutation
1. Introduction
The vicious walker model describes the situation where p walkers at regular time
intervals simultaneously take one step (north-east or south-east) and never share the
same position. The walkers are called vicious since if two or more of them arrive at
the same site, they annihilate one another. This problem is discussed by Fisher [23] in
a paper where many useful results and techniques are given.
In watermelon con gurations, the walkers start at (0; 0); (0; 2); : : : ; (0; 2p − 2) and
end at (l; d); (l; d + 2); : : : ; (l; d + 2p − 2) respectively. d is called the deviation of
the watermelon. The star con gurations are similar except that there is no constraint
∗
Corresponding author.
E-mail addresses:
[email protected] (N. Bonichon),
[email protected] (M. Mosbah).
c 2003 Elsevier B.V. All rights reserved.
0304-3975/03/$ - see front matter
doi:10.1016/S0304-3975(03)00218-4
242
N. Bonichon, M. Mosbah / Theoretical Computer Science 307 (2003) 241 – 256
e3 = 6
e2 = 2
d=2
e1 = - 2
l=8
l=6
(a)
(b)
Fig. 1. (a) A watermelon with a wall of length 8 with 3 branches and a deviation of 2. (b) A star without
a wall restriction of length 6 with 3 branches that, respectively, ends at −2; 2 and 6.
on the y-coordinate of the endpoints (see Fig. 1). The trajectory of the ith walker is
called the ith branch of the watermelon.
Here we will also consider the case of watermelons with a wall. In this case, the
walkers cannot cross the axis y = 0. The watermelon con gurations are similar to noncrossing Dyck (or Grand-Dyck) path con gurations.
There are many combinatorial problems that are equivalent to the vicious random
walker models. These include Baxter permutations [20,21,35], random matrices [4],
Young Tableaux [18,27], underdiagonal walks [26], twin binary trees [21], realizer of
plane graphs [5], perfect matching in honeycomb graphs [17], etc. They are also related
to several physical problems [22,23]. In fact, by considering appropriate bijections, it
is possible to map a type of vicious walkers to each of these problems. Therefore,
the algorithm we give to randomly generate vicious walkers can be applied to these
problems.
The uniform random generation is a powerful tool to study certain properties of combinatorial objects. It is usually used to study the average complexity of an algorithm.
It can also be useful to create conjectures.
The watermelons with (resp. without) a wall with p = 1 and d = 0 corresponds to
Dyck paths (resp. Grand Dyck paths). Such paths can be uniformly generated in linear
time [3] (resp. [36]). A watermelon without a wall with 2 branches and unconstrained
deviation is equivalent to a parallelogram polyominoes of perimeter 2n + 4. As there
is a direct bijection between parallelogram polyominoes of perimeter 2n + 2 and Dyck
paths of length 2n, the former can be generated randomly in linear time.
For an arbitrary number p of branches and an arbitrary deviation, there exist algorithms [29,37] with quadratic complexity considering the branch lengths.
Using enumeration formulas of stars (with a wall [22] or without a wall [8,30]), we
propose another random generation algorithm of watermelons for p and d xed. This
algorithm is exponential considering the number of branches but linear considering the
branches’ length. Hence, it is very ecient to long watermelon con gurations with few
branches. Note that when the number of branches is not small (p¿log(l)), the algorithms proposed in [29,37] are more ecient than the algorithms proposed in this paper.
N. Bonichon, M. Mosbah / Theoretical Computer Science 307 (2003) 241 – 256
243
Our generating algorithms make the p walkers move simultaneously. At each time
interval, each walker can make a north-east or south-east step. Using the enumeration
formulas, the algorithm computes a probability for each of the 2p possible transitions.
The transitions are chosen according to these probabilities.
Using this algorithm, we compute interesting statistical parameters related
to watermelons. For instance, the average maximum height of a Dyck path is H (l) = l=2 +
O(1) [10]. We also give the experimental average height of a watermelon with
p branches.
Realizers were introduced by Schnyder in 1989 [34]. It is a partition of the inner
edges of a maximal plane graph into three particular trees. These objects have been
already investigated [7,9,24,32]. They are used in several graph drawing algorithms
[6,11,31,34]. They are in bijection with watermelons with a wall, having 2 branches
and without deviation [5]. Using this bijection, we can randomly generate realizers. Our
experiments show that the average number of 3-colored faces is O(n=2), where n is
the number of nodes in the graph.
√ They also show that the average height of a tree in
a realizer is experimentally 0:97 n.
The rest of this paper is organized as follows. In Section 2, we present watermelons and we recall some enumeration theorems. The random generation algorithm is
introduced. Applications and bijections between watermelons and other combinatorial
objects are given in Section 3. Some experiments are presented in Section 4.
2. Random generation of watermelons with xed deviation
In this section, we recall some enumerating formulas of star con guration and we
give an algorithm to generate watermelons.
2.1. Random word generation
Let L be a language on an alphabet A. Let Ll be the set of words of L of length l.
For a word w in L, a letter a in A and an integer l, let us de ne p(w; a; l) as follows:
p(w; a; l) =
Number of words in Ll beginning by wa
:
Number of words in Ll beginning by w
Using this function, it is possible to generate uniformly a word of Ll with the algorithm
below.
Algorithm 1. Uniform random word
w←
while |w|¡l do
a ← a random letter with probability p(w; a; l)
w ← wa
end while
244
N. Bonichon, M. Mosbah / Theoretical Computer Science 307 (2003) 241 – 256
Let w = (w1 w2 ; : : : ; wl ) be a word of Ll . The probability p(w) for the word w to be
generated by the algorithm 1 is
|words beginning by w1 | |words beginning by w1 w2 |
···
|words beginning by | |words beginning by w1 |
|words beginning by w1 w2 : : : wl |
···
|words beginning by w1 w2 : : : wl−1 |
|words beginning by w1 w2 : : : wl |
=
|words beginning by |
1
=
:
|Ll |
p(w) =
Hence, this algorithm generates uniformly words of Ll . This algorithm has been applied
for rational words [13–16], Dyck words [3], Fibonacci words [33]. The complexity of
the algorithm depends on the way p(w; a; l) is computed.
2.2. Watermelon generation
The idea of the algorithm is to choose simultaneously for all walkers the steps with
the appropriate probabilities. A transition tr is a vector of size p composed of +1 and
−1 values that indicate for each walker whether it makes a north-east or south-east
step. For example, tri = +1 indicates that the ith branch makes a north-east step.
Like in the random word generation, we can de ne the probability of a transition tr
by
p(w; tr; l) =
Number of watermelons in Wl beginning by w + tr
:
Number of watermelons in Wl beginning by w
Let w be a left factor of length k of a watermelon (i.e. a star of length k). Let
(e1 ; e2 ; : : : ; ep ) be the ends of the branches of w. The number of watermelons of length l
beginning with w is exactly the number of stars of length l−k that end at (e1 ; e2 ; : : : ; ep ).
The following theorems give the enumeration of such stars with and without a wall.
Theorem 1 (Essam and Guttmann [22], Krattenthaler et al. [30]). Let e1 ¡e2 ¡ · · · ¡ep
with ei ≡ l (mod 2); i = 1; 2; : : : ; p. The number of stars of length l without a wall,
which end at (e1 ; e2 ; : : : ; ep ) is
p
2−( 2 )
16i6p
(l − i + p)!
(ej − ei ):
((l + ei )=2)!((l − ei )=2 + p − 1)! 16i¡j6p
Theorem 2 (Brak and Essam [8], Krattenthaler et al. [30]). Let e1 ¡e2 ¡ · · · ¡ep with
ei ≡ l (mod 2); i = 1; 2; : : : ; p. The number of stars of length l with a wall which end
at (e1 ; e2 ; : : : ; ep ) is
2−p
2
+p
(ei +1)(l+2i −2)!
(ej −ei )(ei +ej + 2):
16i6p ((l+ ei )=2 + p)!((l−ei )=2 +p −1)! 16i¡j6p
N. Bonichon, M. Mosbah / Theoretical Computer Science 307 (2003) 241 – 256
(a)
245
(b)
Fig. 2. (a) A random watermelon of 8 branches of length 200 with a wall. (b) A random watermelon of 8
branches of length 200 without a wall.
Note that the probability of a transition depends only on the respective height of
each branch and on the remaining length. So p(w; tr; l) = p(e; d; tr; l) where e is the
vector of the ends of w and d is the length of w.
Moreover, since the respective height of each branch of w and w + tr di er only
by one step, p(e; d; tr; l) can be computed eciently. Algorithms 2 and 3 compute
p(e; d; tr; l) with and without a wall.
The probabilities are computed using rational numbers. Hence, we compute the exact
values of the probabilities p(e; d; tr; l).
To pick a transition tr with probability p(e; d; tr; l), the classical inversion method
[19] can be used.
tr can be seen as a vector of bits coding an integer i in base 2. Next(tr) is the
vector coding the integer i + 1.
Fig. 2 shows an example of random watermelon with and without a wall obtained
using the previous algorithms.
We assume that p is small. Hence, the uniform complexity [1] is considered. In this
model, all arithmetic operations can be computed in O(1). This model can be used
since the numbers are not bigger than lq , where q is a function of p.
Algorithm 2. p(e; d; tr; l) for watermelons with p branches and with a wall
prob ← 1
for i = 1 to p − 1 do
for j = i + 1 to p do
e +tr −(e +tr )
e +tr +e +tr +2
prob ← prob × j ej j −eii i × i eii +ejj +2 j
end for
end for
for i = 1 to p do
ei +tri +1
prob ← prob × (ei +1)(l−d+2i+1)
if tri ¿0 then
i
prob ← prob × ( l−d−1−e
+ p)
2
else
i
prob ← prob × ( l−d+1+e
+ p)
2
end if
end for
return prob
246
N. Bonichon, M. Mosbah / Theoretical Computer Science 307 (2003) 241 – 256
Algorithm 3. p(e; d; tr; l) for watermelons of p branches and without a wall
prob ← 1
for i = 1 to p − 1 do
for j = i + 1 to p do
e +tr −(e +tr )
prob ← prob × j ej j −eii i
end for
end for
for i = 1 to p do
if tri ¿0 then
i +p=2
prob ← prob × l−d−1−e
2(l−d−i+p)
else
l−d+1+ei
prob ← prob × 2(l−d−i+p)
end if
end for
return prob
Theorem 3. There exists an algorithm which uniformly generates a watermelon. Such
an algorithm is linear time for a xed value of p.
Algorithm 4. Select a transition tr with probability p(e; d; tr; l)
h ← random number between 0 and 1
tr ← 1
p ← p(e; d; tr; l)
while p¡h do
tr ← Next(tr)
p ← p + p(e; d; tr; l)
end while
return tr
Algorithms 2 and 3 compute the probability of a transition. It takes O(p2 ) arithmetic
operations to compute the probability of a transition with these algorithms (two nested
loops). For each step, at most O(2p ) transitions have to be computed. So in the worst
case, algorithm 4 takes O(p2 2p ) arithmetic operations. As there are n steps to compute,
it takes O(p2 2p n) to generate a watermelon with or without a wall. The above algorithms have been implemented 1 in C++ using the Gnu-Multi-Precision library [28].
Fig. 3 shows the time used to compute a watermelon with p branches of length l. We
can see that the uniform complexity model gives a good evaluation of the e ective
complexity of the algorithm.
1
This implementation is available at the following URL: http://www.labri.fr/∼bonichon/watermelon.
N. Bonichon, M. Mosbah / Theoretical Computer Science 307 (2003) 241 – 256
247
25000
Duration (s)
20000
p=1
p=2
p=3
p=4
p=5
p=6
15000
10000
5000
0
0
200000
400000
600000
800000 1000000
Branches length
Fig. 3. Complexity of the generation algorithms (test performed on a Pentium 166).
3. Applications to other combinatorial objects
3.1. Parallelogram polyominoes
A polyomino is a nite connected union of elementary cells (unity squares) without cut points and de ned up to translations. A polyomino is column convex (resp.
row convex) if all columns (resp. rows) are connected. A polyomino is convex if
it is column convex and row convex. Parallelogram polyominoes are a particular
case of convex polyominoes. They are de ned by paths composed of north and east
steps. These paths are disjoint except that they have common ends. These paths can
be obtained from fan of two Grand Dyck paths by adding elementary steps at the
beginning and at the end and a rotation of =4 in the counter-clockwise direction
(see Fig. 4).
Parallelogram polyominoes of perimeter 2n can be generated uniformly using the
bijection with Dyck words of length 2n − 2 [12].
The width of a polyomino is the number of columns of the polyomino.
Corollary 4. Parallelogram polyominoes can be uniformly generated in linear time
according to their perimeter and width.
This corollary is based on the direct bijection between parallelogram polyominoes
of perimeter 2l + 4 and width 1 + (l − d)=2, and watermelons with two branches of
length l and deviation d without a wall.
Two parallelogram polyominoes are twin polyominoes if the top border of the
rst one matches the bottom border of the second one. k parallelogram polyominoes
p1 ; p2 ; : : : ; pk are twin polyominoes if for all i¡k, the top border of pi matches the
bottom border of pi+1 . There is an obvious bijection between k twin polyominoes and
watermelons of k + 1 branches without a wall.
248
N. Bonichon, M. Mosbah / Theoretical Computer Science 307 (2003) 241 – 256
Fig. 4. Transformation of a watermelon with 2 branches into a parallelogram polyomino.
Fig. 5. Seven twin polyominoes of perimeter 404 and width 101.
Theorem 5. k twin polyominoes can be uniformly generated in linear time according
to their perimeter and width.
Fig. 5 displays an example of 7 twin polyominoes of perimeter 404 and width 101.
They correspond to the watermelon of Fig. 2(a).
3.2. Underdiagonal paths
The paths considered in this section are paths composed of elementary steps north,
south, west and east. An underdiagonal path is a path that starts from (0; 0), and
remains in the positive quarter plane below the main diagonal. An underdiagonal loop
is a path that ends at (0; 0). In order to count underdiagonal paths, Gouyou–Beauchamps
[26] shows that underdiagonal paths of length l which end at (x; y) are in bijection
with pairs of non-crossing Dyck paths where the paths respectively end at (l; y) and
(l; y + x). Therefore, underdiagonal loops are in bijection with watermelons with 2
branches with a wall.
The correspondence between a watermelon with a wall and with 2 branches (p1 ; p2 )
and an underdiagonal path sp is the following: when both branches p1 and p2 go
north-east (resp. south-east), sp moves east (resp. west). When the branches p1 ; p2
N. Bonichon, M. Mosbah / Theoretical Computer Science 307 (2003) 241 – 256
249
Fig. 6. A random underdiagonal loop of length 105 .
diverge (resp. converge), then the path sp moves north (resp. south). Fig. 6 shows a
random underdiagonal path of length 105 .
Corollary 6. Underdiagonal paths can be generated uniformly according to their
length and their end points in linear time.
3.3. Twin binary trees and Baxter permutations
Let Treen be the set of binary trees having n vertices. Classically, a binary tree t
is coded with a Dyck word, which can be recursively de ned in the following way:
code(t) = z code(left subtree(t)) z code(right subtree(t)) and code(∅) = , where ∅ is
the binary tree representing Tree0 . The set of twin binary trees Twinn ⊆ Treen × Treen
is the set Twinn = {(a1 ; a2 ): a1 ; a2 ∈ Treen and (code(a1 )) = c (code(a2 ))}, where
consists of labeling left (resp. right) leaves of a binary tree (which is completed) by
the letter 0 (resp. letter 1) except two extreme leaves and c is identical to except
that letters 0 and 1 are swapped.
Dulucq and Guibert have shown in [21] that the twin binary trees of size n are in
bijection with watermelons without a wall with 3 branches of length n. This bijection
is based on that between binary trees and parallelogram polyominoes [12].
Theorem 7. Twin binary trees with n nodes and r right edges in the rst tree can be
uniformly generated in linear time.
Let Sn be the set of integers ranging from 1 to n. A permutation of Sn is a Baxter
permutation if and only if, for all integer p ∈ [n − 1]; can be uniquely factorized by
¡ ¿
¿ ¡
¡
¿
= ′ :p: : :p+1:′′ or = ′ :p: : :p+1:′′ , where all the letters of (resp. )
are lower than p (resp. greater than p + 1).
250
N. Bonichon, M. Mosbah / Theoretical Computer Science 307 (2003) 241 – 256
0
2
1
u
1
0
2
Fig. 7. Edge coloration and orientation around a vertex.
Dulucq and Guibert gave in [20] a bijection between Baxter permutations on [n]
with r rises and twin binary trees of Twinn with r right edges in the rst tree. The
algorithm that computes a Baxter permutation from twin binary trees computes in the
worst case in O(n2 ). Hence Baxter permutations of Sn with r rises can be uniformly
generated in O(n2 ).
3.4. Realizers of maximal plane graphs
We assume that the reader is familiar with graph theory. A drawing of a graph is
a mapping of each vertex to a point of the plane and of each edge to the continuous
curve joining the two ends of this edge. A planar drawing, or plane graph is a drawing
without crossing edges except, eventually, on a common extremity. A graph that has
a planar drawing is a planar graph. A plane graph splits the plane into topologically
connected regions, called face regions. A face is the counter-clockwise walk of the
boundary of a face region. One of the regions is unbounded and its associated face
is named the external face of the plane graph. The vertices and edges of this face
are also quali ed as external. A planar graph G is maximal (or triangulated) if all
the other graphs with a same number of vertices that contain it are not planar. The
faces of a maximal plane graph are triangles. In this case, we denote v0 ; v1 ; v2 the three
vertices of the external face of this plane graph.
A realizer of a maximal plane graph G is a partition of the interior edges of G in
three sets T0 ; T1 and T2 of directed edges such that for each interior vertex u there
holds:
(1) u has out-degree exactly once in each of T0 , T1 ; T2 .
(2) The counter-clockwise order of the incident edges of u is: leaving in T0 , entering
in T2 , leaving in T1 , entering in T0 , leaving in T2 and entering in T1 . (Fig. 7)
Theorem 8. A random realizer of size n can be uniformly generated in linear time.
A realizer can also be seen as set of three particular ordered rooted spanning trees
whose edges are oriented to their roots, the external vertices v0 ; v1 ; v2 . An example of
a graph, and a realizer of this graph are given in Fig. 8.
The size of a realizer is the number of vertices of the underlying graph. In [5] a
bijection between realizers of size n and watermelons with a wall with 2 branches of
lengths 2n − 6 has been proposed. The transformation of a watermelon into a realizer
can be achieved in linear time and space.
251
N. Bonichon, M. Mosbah / Theoretical Computer Science 307 (2003) 241 – 256
v1
v2
v1
v2
3-colored
triangle
3-colored
face
v0
v0
(a)
(b)
Fig. 8. (a) An example of maximal plane graph. (b) One of its realizers.
Fig. 9. Random realizer of 100 vertices.
Fig. 9 shows a random realizer of 100 vertices constructed from a random watermelon with a wall and with 2 branches using the bijection presented in [5]. This graph
has been drawn with the Schnyder algorithm [34].
4. Experiments
In this section, we study certain parameters related to watermelons and give some
experimental results.
4.1. Height of branches in watermelons
Here we consider watermelons with a wall and without deviation (d = 0).
The height of a branch is the maximum ordinate of the branch. Let w be a watermelon con guration with a wall. H (w; i) is de ned as the height of the ith branch.
H w (i; p; l), with i6p, is the average height of the ith branch of a watermelon with
p branches of length l with a wall.
252
N. Bonichon, M. Mosbah / Theoretical Computer Science 307 (2003) 241 – 256
25000
20000
Hw(p,n)²
p=1
15000
p=2
p=3
10000
p=4
p=5
5000
p=6
p=7
0
0
500
1000
1500
2000
Branches length
Fig. 10. Height of watermelons with a wall.
10000
9000
Hnw(n,p)²
8000
7000
p=1
6000
p=2
p=3
5000
p=4
4000
p=5
3000
p=6
p=7
2000
1000
0
0
500
1000
1500
2000
Branches length
Fig. 11. Height of watermelons without a wall.
The average height of a Dyck path has already been computed in [10]:
l
H w (1; 1; l) =
+ O(1):
2
Our aim is to generalize this result to watermelons. We have made some experimental
results shown in Figs. 10 and 11.
The average height of a watermelon with p branches and with a wall is experimentally
√
H w (p; p; l) ≈ (1:67p − 0:06)l + o( l):
The average height of a watermelon with p branches without a wall is experimentally
√
H nw (p; p; l) ≈ (0:82p − 0:46)l + o( l):
N. Bonichon, M. Mosbah / Theoretical Computer Science 307 (2003) 241 – 256
253
1.4
1.2
a(p)
1
0.8
0.6
0.4
0.2
0
1
2
3
4
5
6
7
8
9
10
p : Number of branches
√
√
Fig. 12. a(p), where H w (1; p; l) = a(p) l + o( l).
The average height of the rst branch of a watermelon with p branches and with a
wall is experimentally
√
√
H w (1; p; l) ≈ a(p) l + o( l);
where the values of a(p) are presented in Fig. 12. From these experiments, we also
observe that a(p) is approximately
−0:36
a(p) ≈ p
:
2
These presented values in Figs. 10–12 are the result of the generation of watermelons
which lengths range from 100 to 2000 by a progression of 100. Hundred watermelons
of each size have been generated for each considered length.
4.2. Random realizer properties
Using the bijection between watermelons with a wall and realizers [5], experiments
have been performed on realizers. For some graph drawing algorithms [6,11,31], the
size of the drawing depends on the number of leaves in one of the trees of the realizer.
A 3-colored face is a face with an edge of each color. Similarly, a 3-colored triangle
is a cycle of length 3 with an edge of each color. Let be the number of 3-colored
faces. Let + (resp. − ) be the number of 3-colored faces in which the edges are
turning in the clockwise order (resp. counter-clockwise order). Obviously = + +− .
This parameter is related to the number of inner nodes in each tree of the realizer:
Theorem 9 (Bonichon et al. [7]). For any realizer R = (T0 ; T1 ; T2 ) of a maximal plane
graph G : 0 + 1 + 2 − = n − 1, where i denotes the number of inner nodes in Ti
and denotes the number of 3-colored faces.
Fig. 13 shows the number of 3-colored faces and 3-colored triangles in random
realizers of di erent sizes. The experiments on random realizers show that the
N. Bonichon, M. Mosbah / Theoretical Computer Science 307 (2003) 241 – 256
Average value over 50 random realizers of
size n
254
300
250
200
3-colored Triangles
3-colored faces
150
100
50
0
0
100
200
300
400
500
600
n: number of vertices
Fig. 13. Number of 3-colored faces and 3-colored triangles.
average number of 3-colored faces is = n=2 + o(n). Therefore, in a random realizer
R = (T0 ; T1 ; T2 ), the average number of leaves of the tree Ti is n=2 + o(n).
Moreover, the rate of 3-colored faces over 3-colored faces is approximately 92%.
To end with the number of 3-colored faces, we give a last conjecture on the variance
of 3-colored faces:
Conjecture 10.
Var(+ ) = Var(− ) =
n
+ o(n);
16
3n
+ o(n):
Var() =
8
n
+ o(n);
8
CoVar(+ ; − ) =
Remark. The third formula can be deduced from the two rsts since Var(X + Y ) =
Var(X ) + Var(Y ) + 2 CoVar(X; Y ).
In the bijection between watermelons and realizers [5], the tree T0 is encoded by
the rst branch of the watermelon. The height of the rst branch corresponds to the
height
√ of the√ tree T0 . As a result of our experiments, the average height of Ti is
0:97 n + o( n), for a realizer R = (T0 ; T1 ; T2 ).
5. Conclusion
In this paper, we have presented an algorithm to randomly and uniformly generate
p watermelons. This algorithm is ecient for p small (O((p2 × 2p )l)), particularly
N. Bonichon, M. Mosbah / Theoretical Computer Science 307 (2003) 241 – 256
255
for the examples we gave (p = 2; 3). We think that the proposed algorithms could be
enhanced to a O((p × 2p )l) time complexity, using “gray code” [25] order for the
operation Next(tr). In such an order, only one entry of the transition vector is di erent
in Next(tr) from tr. Therefore, the probability of Next(tr) could be eciently computed
from the previous positive computed probability. However, for “large” values of p, our
method is less ecient than the existing ones. Note that with slight modi cations of
our algorithm generating watermelons, we can generate stars with xed endpoints. On
the other hand, to generate watermelons with unconstrained deviation, we have just to
choose a deviation with the appropriate probabilities. This could be done using similar
techniques as presented by Alonso [2].
Acknowledgements
The authors would like to thank Mireille Bousquet-Melou, Philippe Duchon, Serge
Dulucq, Olivier Guibert and Xavier Gerard Viennot for fruitful discussions and suggestions. The authors would also like to thank the anonymous referees for their helpful
comments and corrections.
References
[1] A.V. Aho, J.E. Hopcroft, J.D. Ullman, The Design and Analysis of Computer Algorithms,
Addison-Wesley, Reading, MA, 1974.
[2] Laurent Alonso, Rene Schott, Random Generation of Trees. Kluwer Academic Publishers, Dordrecht,
1995.
[3] D.B. Arnold, M.R. Sleep, Uniform random generation of balanced parenthesis strings, ACM Trans.
Programming Languages Systems 2 (1) (1980) 122–128.
[4] J. Baik, Random vicious walks and random matrices, Comm. Pure Appl. Math. 53 (11) (2000)
1385–1410.
[5] N. Bonichon, A bijection between realizers of maximal plane graphs and pairs of non-crossing dyck
paths, in: Proc. FPSAC’02, Melbourne, Australia, 2002, pp. 123–132.
[6] N. Bonichon, B. Le Saec, M. Mosbah, Optimal area algorithm for planar polyline drawings, in:
Graph-Theoretic Concepts in Computer Science (WG 2002), Lecture Notes in Computer Science,
Vol. 2573, 2002, pp. 35–46.
[7] N. Bonichon, B. Le Saec, M. Mosbah, Wagner’s theorem on realizers, in: Internat. Coll. Automata,
Languages and Programming 2002 (ICALP’02), Lecture Notes in Computer Science, Vol. 2380, 2002,
pp. 1043–1053.
[8] R. Brak, J.W. Essam, Return polynomials for non-intersecting paths above a surface on a directed square
lattice, J. Phys. A—Math. Gen. 34 (2001) 10763–10782.
[9] E. Brehm, 3-Orientations and Schnyder 3-tree-decompositions, Ph.D. Thesis, FB Mathematik und
Informatik, Freie Universitat Berlin, 2000.
[10] N.G. De Bruijn, D.E. Knuth, S.O. Rice, The average height of planted plane trees, in: R.C. Read (Ed.),
Graph Theory and Computing, Academic Press, New York, 1972, pp. 15 –22.
[11] Yi-Ting Chiang, Ching-Chi Lin, Hsueh-I LU, Orderly spanning trees with applications to graph encoding
and graph drawing, in: Proc. 12th Symp. Discrete Algorithms, ACM and SIAM, 2001, pp. 506 –515.
[12] M.P. Delest, G. Viennot, Algebraic languages and polyominoes enumeration, Theoret. Comput. Sci. 34
(1984) 169–206.
[13] A. Denise, Generation aleatoire et uniforme de mots, in: Proc. FPSAC’93, Florence, Italy, 1993,
pp. 153–164.
256
N. Bonichon, M. Mosbah / Theoretical Computer Science 307 (2003) 241 – 256
[14] A. Denise, Enumeration et generation aleatoire de chemins, in: Proc. FPSAC’94, 1994, pp. 91–97.
[15] A. Denise, Generation aleatoire et uniforme de mots, Discrete Math. 153 (1996) 69–84.
[16] A. Denise, Generation aleatoire uniforme de mots de langages rationnels, Theoret. Comput. Sci. 159
(1996) 43–63.
[17] M. Desainte-Catherine, A honeycomb graph perfect matchings enumeration, J. Math. Chem. 13 (1993)
133–143.
[18] M. Desainte-Catherine, G. Viennot, Enumeration of certain Young tableaux with bounded height, in:
G. Labelle, P. Leroux (Eds.), Combinatoire Enum
erative, Montreal, Springer, 1986, pp. 58– 67.
[19] L. Devroye, Non-uniform Random Variate Generation, Springer, Berlin, 1986.
[20] S. Dulucq, O. Guibert, Stack words, standard tableaux and Baxter permutations, Discrete Math. 157
(1996) 91–106.
[21] S. Dulucq, O. Guibert, Baxter permutations, Discrete Math. 180 (1998) 139–150.
[22] J.W. Essam, A.J. Guttmann, Vicious walkers and directed polymer networks in general dimensions,
Phys. Rev. E 52 (1995) 5849–5862.
[23] M.E. Fisher, Walks, walls, wetting, and melting, J. Statist. Phys. 34 (1984) 667–729.
[24] H. de Fraysseix, P.O. de Mendez, On topological aspects of orientations, Discrete Math. 229 (1–3)
(2001) 57–72.
[25] E.N. Gilbert, Gray codes and paths on the n-cube, Bell Systems Tech. J. 37 (1958) 815–826.
[26] D. Gouyou-Beauchamps, Chemins sous-diagonaux et tableaux de Young, in: Colloque de Combinatoire
Enumerative, Montreal, UQAM 1985, Lecture Notes in Mathematics, Vol. 1234, 1986, pp. 112–125.
[27] D. Gouyou-Beauchamps, Standard Young tableaux of height 4 and 5, European J. Combin. 10 (1989)
69–82.
[28] T. Granlund, The GNU Multiple Precision arithmetic library, http://www.gnu.org/manual/gmp/
ps/gmp.ps.gz, 1996.
[29] C. Krattenthaler, Another involution principle-free bijective proof of stanley’s hook-content formula,
J. Combin. Theory Ser. A 88 (1999) 66–92.
[30] C. Krattenthaler, A.J. Guttmann, X.G. Viennot, Vicious walkers, friendly walkers and Young tableaux
ii: with a walls, J. Phys. A: Math. Gen. 33 (2000) 8123–8135.
[31] Chien-Chi Lioa, Ching-Chi Lin, Hsu-Chun Yen, Floor-planning via orderly spanning trees, in: Proc. 9th
Internat. Symp. on Graph Drawing (GD 2001), September 23–26 2001, Vienna, Austria, Lecture Notes
in Computer Science, Vol. 2265, Springer, Berlin, 2002, pp. 367–377.
[32] P.O. Mendez, Orientations bipolaires, Ph.D. Thesis, Ecole des Hautes Etudes en Sciences Sociales,
1994.
[33] J.G. Penaud, O. Roques, Tirage a pile ou face de mots de Fibonacci, Publications du LaCIM, 27, 2000.
[34] W. Schnyder, Planar graphs and poset dimension, Order 5 (1989) 323–343.
[35] G. Viennot, A bijective proof for the number of Baxter permutations, in: Seminaire Lotharingien de
Combinatoire, Le Klebach (1981), 1981.
[36] H.S. Wilf, A uni ed setting for sequencing, ranking, and selection algorithms for combinatorial objects,
Adv. in Math. 24 (1977) 281–291.
[37] D. Wilson, Determinant algorithms for random planar structures, in: Proc. 18th Symp., Discrete
Algorithms, ACM and SIAM, 1997, pp. 258–267.