Open In App

SymPy | Permutation.next_trotterjohnson() in Python

Last Updated : 27 Aug, 2019
Improve
Improve
Like Article
Like
Save
Share
Report

Permutation.next_trotterjohnson() : next_trotterjohnson() is a sympy Python library function that returns the next permutation in Trotter-Johnson order. If self is the last permutation it returns None.

Syntax : sympy.combinatorics.permutations.Permutation.next_trotterjohnson()

Return : next permutation in Trotter-Johnson order

Code #1 : next_trotterjohnson() Example




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


Output :

Permutation a – next_trotterjohnson form : (0 3 1 2)
Permutation b – next_trotterjohnson form : (0 1 5)(2 3 4)

Code #2 : next_trotterjohnson() Example – 2D Permutation




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


Output :

Permutation a – next_trotterjohnson form : (6)(0 3 5 1 2 4)



Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads