本文整理汇总了Python中sage.combinat.permutation.Permutation.bruhat_lequal方法的典型用法代码示例。如果您正苦于以下问题:Python Permutation.bruhat_lequal方法的具体用法?Python Permutation.bruhat_lequal怎么用?Python Permutation.bruhat_lequal使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sage.combinat.permutation.Permutation
的用法示例。
在下文中一共展示了Permutation.bruhat_lequal方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: SymmetricGroupBruhatIntervalPoset
# 需要导入模块: from sage.combinat.permutation import Permutation [as 别名]
# 或者: from sage.combinat.permutation.Permutation import bruhat_lequal [as 别名]
def SymmetricGroupBruhatIntervalPoset(start, end):
"""
The poset of permutations with respect to Bruhat order.
INPUT:
- ``start`` - list permutation
- ``end`` - list permutation (same n, of course)
.. note::
Must have ``start`` <= ``end``.
EXAMPLES:
Any interval is rank symmetric if and only if it avoids these
permutations::
sage: P1 = Posets.SymmetricGroupBruhatIntervalPoset([1,2,3,4], [3,4,1,2])
sage: P2 = Posets.SymmetricGroupBruhatIntervalPoset([1,2,3,4], [4,2,3,1])
sage: ranks1 = [P1.rank(v) for v in P1]
sage: ranks2 = [P2.rank(v) for v in P2]
sage: [ranks1.count(i) for i in uniq(ranks1)]
[1, 3, 5, 4, 1]
sage: [ranks2.count(i) for i in uniq(ranks2)]
[1, 3, 5, 6, 4, 1]
"""
start = Permutation(start)
end = Permutation(end)
if len(start) != len(end):
raise TypeError("Start (%s) and end (%s) must have same length."%(start, end))
if not start.bruhat_lequal(end):
raise TypeError("Must have start (%s) <= end (%s) in Bruhat order."%(start, end))
unseen = [start]
nodes = {}
while len(unseen) > 0:
perm = unseen.pop(0)
nodes[perm] = [succ_perm for succ_perm in perm.bruhat_succ()
if succ_perm.bruhat_lequal(end)]
for succ_perm in nodes[perm]:
if succ_perm not in nodes:
unseen.append(succ_perm)
return Poset(nodes)