Friday, November 14, 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
32399 POSTS0 COMMENTS
Milvus
95 POSTS0 COMMENTS
Nango Kala
6765 POSTS0 COMMENTS
Nicole Veronica
11916 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11984 POSTS0 COMMENTS
Shaida Kate Naidoo
6889 POSTS0 COMMENTS
Ted Musemwa
7141 POSTS0 COMMENTS
Thapelo Manthata
6837 POSTS0 COMMENTS
Umr Jansen
6839 POSTS0 COMMENTS