本文整理汇总了Python中sage.combinat.permutation.Permutation.cycle_tuples方法的典型用法代码示例。如果您正苦于以下问题:Python Permutation.cycle_tuples方法的具体用法?Python Permutation.cycle_tuples怎么用?Python Permutation.cycle_tuples使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sage.combinat.permutation.Permutation
的用法示例。
在下文中一共展示了Permutation.cycle_tuples方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: to_non_crossing_set_partition
# 需要导入模块: from sage.combinat.permutation import Permutation [as 别名]
# 或者: from sage.combinat.permutation.Permutation import cycle_tuples [as 别名]
def to_non_crossing_set_partition(self):
r"""
Returns the noncrossing set partition (on half as many elements)
corresponding to the perfect matching if the perfect matching is
noncrossing, and otherwise gives an error.
OUTPUT:
The realization of ``self`` as a noncrossing set partition.
EXAMPLES::
sage: PerfectMatching([[1,3], [4,2]]).to_non_crossing_set_partition()
Traceback (most recent call last):
...
ValueError: matching must be non-crossing
sage: PerfectMatching([[1,4], [3,2]]).to_non_crossing_set_partition()
{{1, 2}}
sage: PerfectMatching([]).to_non_crossing_set_partition()
{}
"""
from sage.combinat.set_partition import SetPartition
if not self.is_non_crossing():
raise ValueError("matching must be non-crossing")
else:
perm = self.to_permutation()
perm2 = Permutation([(perm[2*i])/2 for i in range(len(perm)/2)])
return SetPartition(perm2.cycle_tuples())