Python | SymPy Permutation.cyclic_form() method
Last Updated :
26 Aug, 2019
Permutation.cyclic_form() : cyclic_form() is a sympy Python library function that returns the cyclic notation from the canonical notation, by omitting the singletons.
Syntax :
sympy.combinatorics.permutations.Permutation.cyclic_form()
Return :
cyclic notation from the canonical notation
Code #1 : cyclic_form() Example
from sympy.combinatorics.partitions import Partition
from sympy.combinatorics.permutations import Permutation
a = Permutation([ 2 , 0 , 3 , 1 , 5 , 4 ])
b = Permutation([ 3 , 1 , 2 , 5 , 4 , 0 ])
print ( "Permutation a - cyclic_form form : " , a.cyclic_form)
print ( "Permutation b - cyclic_form form : " , b.cyclic_form)
|
Output :
Permutation a – cyclic_form form : [[0, 2, 3, 1], [4, 5]]
Permutation b – cyclic_form form : [[0, 3, 5]]
Code #2 : cyclic_form() Example – 2D Permutation
from sympy.combinatorics.partitions import Partition
from sympy.combinatorics.permutations import Permutation
a = Permutation([[ 2 , 4 , 0 ],
[ 3 , 1 , 2 ],
[ 1 , 5 , 6 ]])
print ( "Permutation a - cyclic_form form : " , a.cyclic_form)
|
Output :
Permutation a – cyclic_form form : [[0, 3, 5, 6, 1, 2, 4]]
Share your thoughts in the comments
Please Login to comment...