Necklaces¶
The algorithm used in this file comes from
- Sawada, Joe. “A fast algorithm to generate necklaces with fixed content”, Source Theoretical Computer Science archive Volume 301 , Issue 1-3 (May 2003)
-
sage.combinat.necklace.
Necklaces
(content)¶ Return the set of necklaces with evaluation
content
.A necklace is a list of integers that such that the list is the smallest lexicographic representative of all the cyclic shifts of the list.
See also
INPUT:
content
– a list or tuple of non-negative integers
EXAMPLES:
sage: Necklaces([2,1,1]) Necklaces with evaluation [2, 1, 1] sage: Necklaces([2,1,1]).cardinality() 3 sage: Necklaces([2,1,1]).first() [1, 1, 2, 3] sage: Necklaces([2,1,1]).last() [1, 2, 1, 3] sage: Necklaces([2,1,1]).list() [[1, 1, 2, 3], [1, 1, 3, 2], [1, 2, 1, 3]] sage: Necklaces([0,2,1,1]).list() [[2, 2, 3, 4], [2, 2, 4, 3], [2, 3, 2, 4]] sage: Necklaces([2,0,1,1]).list() [[1, 1, 3, 4], [1, 1, 4, 3], [1, 3, 1, 4]]
-
sage.combinat.necklace.
Necklaces_evaluation
¶ Necklaces with a fixed evaluation (content).
INPUT:
content
– a list or tuple of non-negative integers