Skip to content

Commit de98279

Browse files
committed
Added Examples tag before the examples
1 parent 191993a commit de98279

File tree

1 file changed

+17
-13
lines changed

1 file changed

+17
-13
lines changed

src/sage/sets/recursively_enumerated_set.pyx

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ to be a forest, symmetric, or graded. However, it may have other
2828
structure, such as not containing an oriented cycle, that does not
2929
help with the enumeration.
3030
31+
EXAMPLES:
32+
3133
In this example, the seed is 0 and the successor function is either ``+2``
3234
or ``+3``. This is the set of non negative linear combinations of 2 and 3::
3335
@@ -53,7 +55,9 @@ Symmetric structure
5355
5456
The origin ``(0, 0)`` as seed and the upper, lower, left and right lattice
5557
point as successor function. This function is symmetric since `p` is a
56-
successor of `q` if and only if `q` is a successor or `p`::
58+
successor of `q` if and only if `q` is a successor or `p`:
59+
60+
EXAMPLES::
5761
5862
sage: succ = lambda a: [(a[0]-1,a[1]), (a[0],a[1]-1), (a[0]+1,a[1]), (a[0],a[1]+1)]
5963
sage: seeds = [(0,0)]
@@ -88,7 +92,9 @@ Graded structure
8892
----------------
8993
9094
Identity permutation as seed and ``permutohedron_succ`` as successor
91-
function::
95+
function:
96+
97+
EXAMPLES::
9298
9399
sage: succ = attrcall("permutohedron_succ")
94100
sage: seed = [Permutation([1..5])]
@@ -138,6 +144,8 @@ Graded components (set of elements of the same depth)::
138144
Forest structure
139145
----------------
140146
147+
EXAMPLES:
148+
141149
The set of words over the alphabet `\{a,b\}` can be generated from the
142150
empty word by appending the letter `a` or `b` as a successor function. This set
143151
has a forest structure::
@@ -160,10 +168,7 @@ Breadth first search iterator::
160168
sage: [next(it) for _ in range(6)]
161169
['', 'a', 'b', 'aa', 'ab', 'ba']
162170
163-
Example: Forest structure
164-
-------------------------
165-
166-
This example was provided by Florent Hivert.
171+
The following example of Forest structure was provided by Florent Hivert.
167172
168173
How to define a set using those classes?
169174
@@ -229,10 +234,7 @@ or::
229234
sage: S.list()
230235
['', 'a', 'aa', 'ab', 'ac', 'b', 'ba', 'bb', 'bc', 'c', 'ca', 'cb', 'cc']
231236
232-
Example: Forest structure 2
233-
---------------------------
234-
235-
This example was provided by Florent Hivert.
237+
The following example of Forest structure was provided by Florent Hivert.
236238
237239
Here is a little more involved example. We want to iterate through all
238240
permutations of a given set `S`. One solution is to take elements of `S` one
@@ -386,7 +388,7 @@ def RecursivelyEnumeratedSet(seeds, successors, structure=None,
386388
387389
.. WARNING::
388390
389-
If you do not set a valid structure, you might obtain bad results,
391+
If you do not set a good structure, you might obtain bad results,
390392
like elements generated twice::
391393
392394
sage: f = lambda a: [a-1,a+1]
@@ -1554,9 +1556,9 @@ def search_forest_iterator(roots, children, algorithm='depth'):
15541556
[0, 1, 2], [0, 2, 1], [1, 0, 2], [1, 2, 0], [2, 0, 1], [2, 1, 0]]
15551557
"""
15561558
# Little trick: the same implementation handles both depth and
1557-
# breadth first search. Setting position to -1 initiates a depth search
1559+
# breadth first search. Setting position to -1 results in a depth search
15581560
# (you ask the children for the last node you met). Setting
1559-
# position on 0 initiates a breadth search (enumerate all the
1561+
# position on 0 results in a breadth search (enumerate all the
15601562
# descendants of a node before going on to the next father)
15611563
if algorithm == 'depth':
15621564
position = -1
@@ -1690,6 +1692,8 @@ class RecursivelyEnumeratedSet_forest(Parent):
16901692
recover the corresponding integers, and discard tuples finishing
16911693
by zero.
16921694
1695+
EXAMPLES:
1696+
16931697
A first approach is to pass the ``roots`` and ``children``
16941698
functions as arguments to :meth:`RecursivelyEnumeratedSet_forest.__init__`::
16951699

0 commit comments

Comments
 (0)