Skip to content
Related Articles

Related Articles

Improve Article

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




# Python code explaining
# SymPy.Permutation.cyclic_form()
  
# importing SymPy libraries
from sympy.combinatorics.partitions import Partition
from sympy.combinatorics.permutations import Permutation
  
# Using from sympy.combinatorics.permutations.Permutation.cyclic_form() method 
  
# creating 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




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

Output :

Permutation a – cyclic_form form : [[0, 3, 5, 6, 1, 2, 4]]

 Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.  

To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course. And to begin with your Machine Learning Journey, join the Machine Learning – Basic Level Course




My Personal Notes arrow_drop_up
Recommended Articles
Page :