def children(self, x): r""" Returns the list of children of the element ``x``. This method is required to build the tree structure of ``self`` which inherits from the class :class:`~sage.combinat.backtrack.SearchForest`. EXAMPLES:: sage: I = IntegerVectorsModPermutationGroup(PermutationGroup([[(1,2,3,4)]])) sage: I.children(I([2,1,0,0], check=False)) [[2, 2, 0, 0], [2, 1, 1, 0], [2, 1, 0, 1]] """ return canonical_children(self._sgs, x, -1)
def children(self, x): r""" Returns the list of children of the element ``x``. This method is required to build the tree structure of ``self`` which inherits from the class :class:`~sage.sets.recursively_enumerated_set.RecursivelyEnumeratedSet_forest`. EXAMPLES:: sage: I = IntegerVectorsModPermutationGroup(PermutationGroup([[(1,2,3,4)]])) sage: I.children(I([2,1,0,0], check=False)) [[2, 2, 0, 0], [2, 1, 1, 0], [2, 1, 0, 1]] """ return canonical_children(self._sgs, x, -1)
def __iter__(self): r""" TESTS:: sage: I = IntegerVectorsModPermutationGroup(PermutationGroup([[(1,2,3,4)]]),4) sage: for i in I: i [4, 0, 0, 0] [3, 1, 0, 0] [3, 0, 1, 0] [3, 0, 0, 1] [2, 2, 0, 0] [2, 1, 1, 0] [2, 1, 0, 1] [2, 0, 2, 0] [2, 0, 1, 1] [1, 1, 1, 1] sage: I = IntegerVectorsModPermutationGroup(PermutationGroup([[(1,2,3,4)]]), sum=7, max_part=3) sage: for i in I: i [3, 3, 1, 0] [3, 3, 0, 1] [3, 2, 2, 0] [3, 2, 1, 1] [3, 2, 0, 2] [3, 1, 3, 0] [3, 1, 2, 1] [3, 1, 1, 2] [3, 0, 2, 2] [2, 2, 2, 1] """ if self._max_part < 0: return self.elements_of_depth_iterator(self._sum) else: SF = SearchForest( (self([0] * (self.n), check=False), ), lambda x: [ self(y, check=False) for y in canonical_children(self._sgs, x, self._max_part) ], algorithm='breadth') if self._sum is None: return iter(SF) else: return SF.elements_of_depth_iterator(self._sum)
def __iter__(self): r""" TESTS:: sage: I = IntegerVectorsModPermutationGroup(PermutationGroup([[(1,2,3,4)]]),4) sage: for i in I: i [4, 0, 0, 0] [3, 1, 0, 0] [3, 0, 1, 0] [3, 0, 0, 1] [2, 2, 0, 0] [2, 1, 1, 0] [2, 1, 0, 1] [2, 0, 2, 0] [2, 0, 1, 1] [1, 1, 1, 1] sage: I = IntegerVectorsModPermutationGroup(PermutationGroup([[(1,2,3,4)]]), sum=7, max_part=3) sage: for i in I: i [3, 3, 1, 0] [3, 3, 0, 1] [3, 2, 2, 0] [3, 2, 1, 1] [3, 2, 0, 2] [3, 1, 3, 0] [3, 1, 2, 1] [3, 1, 1, 2] [3, 0, 2, 2] [2, 2, 2, 1] """ if self._max_part < 0: return self.elements_of_depth_iterator(self._sum) else: SF = SearchForest( (self([0] * (self.n), check=False),), lambda x: map(lambda y: self(y, check=False), canonical_children(self._sgs, x, self._max_part)), algorithm="breadth", ) if self._sum is None: return iter(SF) else: return SF.elements_of_depth_iterator(self._sum)