Thursday, January 22, 2026
HomeLanguagesSymPy | Permutation.next_trotterjohnson() in Python

SymPy | Permutation.next_trotterjohnson() in Python

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)

Dominic
Dominichttp://wardslaus.com
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

Most Popular

Dominic
32475 POSTS0 COMMENTS
Milvus
119 POSTS0 COMMENTS
Nango Kala
6847 POSTS0 COMMENTS
Nicole Veronica
11977 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12064 POSTS0 COMMENTS
Shaida Kate Naidoo
6986 POSTS0 COMMENTS
Ted Musemwa
7220 POSTS0 COMMENTS
Thapelo Manthata
6933 POSTS0 COMMENTS
Umr Jansen
6912 POSTS0 COMMENTS