diff --git a/src/sage/sets/recursively_enumerated_set.pyx b/src/sage/sets/recursively_enumerated_set.pyx index 073e7c6e95e..9d90f3581ed 100644 --- a/src/sage/sets/recursively_enumerated_set.pyx +++ b/src/sage/sets/recursively_enumerated_set.pyx @@ -93,15 +93,15 @@ Identity permutation as seed and ``permutohedron_succ`` as successor function:: sage: succ = attrcall("permutohedron_succ") - sage: seed = [Permutation([1..5])] - sage: R = RecursivelyEnumeratedSet(seed, succ, structure='graded') - sage: R + sage: seed = [Permutation([1..5])] # optional - sage.combinat + sage: R = RecursivelyEnumeratedSet(seed, succ, structure='graded') # optional - sage.combinat + sage: R # optional - sage.combinat A recursively enumerated set with a graded structure (breadth first search) Depth first search iterator:: - sage: it_depth = R.depth_first_search_iterator() - sage: [next(it_depth) for _ in range(5)] + sage: it_depth = R.depth_first_search_iterator() # optional - sage.combinat + sage: [next(it_depth) for _ in range(5)] # optional - sage.combinat [[1, 2, 3, 4, 5], [1, 2, 3, 5, 4], [1, 2, 5, 3, 4], @@ -110,8 +110,8 @@ Depth first search iterator:: Breadth first search iterator:: - sage: it_breadth = R.breadth_first_search_iterator() - sage: [next(it_breadth) for _ in range(5)] + sage: it_breadth = R.breadth_first_search_iterator() # optional - sage.combinat + sage: [next(it_breadth) for _ in range(5)] # optional - sage.combinat [[1, 2, 3, 4, 5], [2, 1, 3, 4, 5], [1, 3, 2, 4, 5], @@ -120,20 +120,20 @@ Breadth first search iterator:: Elements of given depth iterator:: - sage: sorted(R.elements_of_depth_iterator(9)) + sage: sorted(R.elements_of_depth_iterator(9)) # optional - sage.combinat [[4, 5, 3, 2, 1], [5, 3, 4, 2, 1], [5, 4, 2, 3, 1], [5, 4, 3, 1, 2]] - sage: list(R.elements_of_depth_iterator(10)) + sage: list(R.elements_of_depth_iterator(10)) # optional - sage.combinat [[5, 4, 3, 2, 1]] Graded components (set of elements of the same depth):: - sage: sorted(R.graded_component(0)) + sage: sorted(R.graded_component(0)) # optional - sage.combinat [[1, 2, 3, 4, 5]] - sage: sorted(R.graded_component(1)) + sage: sorted(R.graded_component(1)) # optional - sage.combinat [[1, 2, 3, 5, 4], [1, 2, 4, 3, 5], [1, 3, 2, 4, 5], [2, 1, 3, 4, 5]] - sage: sorted(R.graded_component(9)) + sage: sorted(R.graded_component(9)) # optional - sage.combinat [[4, 5, 3, 2, 1], [5, 3, 4, 2, 1], [5, 4, 2, 3, 1], [5, 4, 3, 1, 2]] - sage: sorted(R.graded_component(10)) + sage: sorted(R.graded_component(10)) # optional - sage.combinat [[5, 4, 3, 2, 1]] Forest structure @@ -955,7 +955,7 @@ cdef class RecursivelyEnumeratedSet_generic(Parent): sage: child = lambda i: [(i+3) % 10, (i+8) % 10] sage: R = RecursivelyEnumeratedSet([0], child) - sage: R.to_digraph() + sage: R.to_digraph() # optional - sage.graphs Looped multi-digraph on 10 vertices Digraph of an recursively enumerated set with a symmetric structure of @@ -964,20 +964,20 @@ cdef class RecursivelyEnumeratedSet_generic(Parent): sage: succ = lambda a: [(a[0]-1,a[1]), (a[0],a[1]-1), (a[0]+1,a[1]), (a[0],a[1]+1)] sage: seeds = [(0,0)] sage: C = RecursivelyEnumeratedSet(seeds, succ, structure='symmetric') - sage: C.to_digraph(max_depth=3) + sage: C.to_digraph(max_depth=3) # optional - sage.graphs Looped multi-digraph on 41 vertices The ``max_depth`` argument can be given at the creation of the set:: sage: C = RecursivelyEnumeratedSet(seeds, succ, structure='symmetric', max_depth=2) - sage: C.to_digraph() + sage: C.to_digraph() # optional - sage.graphs Looped multi-digraph on 25 vertices Digraph of an recursively enumerated set with a graded structure:: sage: f = lambda a: [a+1, a+I] sage: C = RecursivelyEnumeratedSet([0], f, structure='graded') - sage: C.to_digraph(max_depth=4) + sage: C.to_digraph(max_depth=4) # optional - sage.graphs Looped multi-digraph on 21 vertices """ successors = self.successors @@ -2093,12 +2093,12 @@ class RecursivelyEnumeratedSet_forest(Parent): sage: F = RecursivelyEnumeratedSet(seeds, succ, ....: structure='forest', enumeration='depth') - sage: y = var('y') + sage: y = var('y') # optional - sage.symbolic sage: def map_function(t): ....: li, sum, _ = t ....: return y ^ sum sage: reduce_function = lambda x,y: x + y - sage: F.map_reduce(map_function, reduce_function, 0) + sage: F.map_reduce(map_function, reduce_function, 0) # optional - sage.symbolic y^45 + y^44 + y^43 + 2*y^42 + 2*y^41 + 3*y^40 + 4*y^39 + 5*y^38 + 6*y^37 + 8*y^36 + 9*y^35 + 10*y^34 + 12*y^33 + 13*y^32 + 15*y^31 + 17*y^30 + 18*y^29 + 19*y^28 + 21*y^27 + 21*y^26 + 22*y^25 + 23*y^24 + 23*y^23 + 23*y^22 + 23*y^21 + 22*y^20 + 21*y^19 + 21*y^18 + 19*y^17 + 18*y^16 + 17*y^15 + 15*y^14 + 13*y^13 + 12*y^12 + 10*y^11 + 9*y^10 + 8*y^9 + 6*y^8 + 5*y^7 + 4*y^6 + 3*y^5 + 2*y^4 + 2*y^3 + y^2 + y Here is an example with the default values::