Thursday, November 20, 2025
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
32405 POSTS0 COMMENTS
Milvus
97 POSTS0 COMMENTS
Nango Kala
6778 POSTS0 COMMENTS
Nicole Veronica
11927 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11995 POSTS0 COMMENTS
Shaida Kate Naidoo
6905 POSTS0 COMMENTS
Ted Musemwa
7163 POSTS0 COMMENTS
Thapelo Manthata
6861 POSTS0 COMMENTS
Umr Jansen
6846 POSTS0 COMMENTS