SymPy | Prufer.next () in Python

Python Methods and Functions

Prufer.next (): next () — nice Python library function that returns a Prufer sequence that is different from the current one.

Syntax:
sympy.combinatorics.Prufer.prufer.next ()

Return:
Prufer sequence that is delta beyond the current one

Code # 1: next () example

# Python code explaining
# SymPy.Prufer.next ( )

 
# import SymPy libraries

from sympy.combinatorics import Permutation, Cycle

from sympy.combinatorics.prufer import Prufer

 
# Use from
# sympy.combinatorics.prufer.Prufer.next ()

  
# Create Prufer

a = Prufer ([ 1 , 2 , 3 ], [ 2 , 4 , 5 ])

 
# next value

print ( "Prufer a next: " , a. next ( 1 ))

Output:

Prufer a next: Prufer ([1, 2, 4])

Code # 2: next () example

# Python code explaining
# SymPy.Prufer.next ()

 
# import SymPy libraries

from sympy.combinatorics import Permutation, Cycle

from sympy.combinatorics.prufer import Prufer

  
< code class = "comments"> # Use from
# sympy.combinatorics.prufer.Prufer.next ()

 
# Create Prufer

b = Prufer ([ 1 , 2 , 3 , 2 , 4 , 5 ], [ 6 , 7 ], [ 8 ])

 
# next value

print ( "Prufer b next:" , b. next ( 1 ))

Output:

Prufer b next: Prufer ([1, 2, 3, 2, 4, 6])





Tutorials