📜  Python| SymPy Permutation.cycle_structure() 方法

📅  最后修改于: 2022-05-13 01:55:32.012000             🧑  作者: Mango

Python| SymPy Permutation.cycle_structure() 方法

Permutation.cycle_structure() :cycle_structure()是一个 sympy Python库函数,它以字典的形式返回排列的循环结构,这将指示每个循环长度的多重性。

代码 #1:cycle_structure() 示例

# Python code explaining
# SymPy.Permutation.cycle_structure()
  
# importing SymPy libraries
from sympy.combinatorics.partitions import Partition
from sympy.combinatorics.permutations import Permutation
  
# Using from 
# sympy.combinatorics.permutations.Permutation.cycle_structure() method 
  
# creating Permutation
a = Permutation([2, 0, 3, 1, 5, 4])
  
b = Permutation([3, 1, 2, 5, 4, 0])
  
  
print ("Permutation a - cycle_structure form : ", a.cycle_structure)
print ("Permutation b - cycle_structure form : ", b.cycle_structure)

输出 :

代码 #2:cycle_structure() 示例– 2D 排列

# Python code explaining
# SymPy.Permutation.cycle_structure()
  
# importing SymPy libraries
from sympy.combinatorics.partitions import Partition
from sympy.combinatorics.permutations import Permutation
  
# Using from 
# sympy.combinatorics.permutations.Permutation.cycle_structure() method 
  
# creating Permutation
a = Permutation([[2, 4, 0], 
                 [3, 1, 2],
                 [1, 5, 6]])
  
# SELF COMMUTATING    
print ("Permutation a - cycle_structure form : ", a.cycle_structure)

输出 :