SymPy | Prufer.prufer_repr() in Python
Last Updated :
26 Aug, 2019
Prufer.prufer_repr() : prufer_repr() is a sympy Python library function that returns the Prufer sequence for the Prufer object. By removing the highest numbered vertex, then recording the node it was attached to, and finally continuing until only two vertices remain, the sequence can be found.
Syntax :
sympy.combinatorics.Prufer.prufer.prufer_repr()
Return :
Prufer sequence for the Prufer object
Code #1 : prufer_repr() Example
from sympy.combinatorics import Permutation, Cycle
from sympy.combinatorics.prufer import Prufer
a = Prufer([ 1 , 2 , 3 ], [ 2 , 4 , 5 ])
print ( "Prufer a prufer_repr : " , a.prufer_repr)
|
Output :
Prufer a prufer_repr : [1, 2, 3]
Code #2 : prufer_repr() Example
from sympy.combinatorics import Permutation, Cycle
from sympy.combinatorics.prufer import Prufer
b = Prufer([ 1 , 2 , 3 , 2 , 4 , 5 ], [ 6 , 7 ], [ 8 ])
print ( "Prufer b prufer_repr : " , b.prufer_repr)
|
Output :
Prufer b prufer_repr : [1, 2, 3, 2, 4, 5]
Share your thoughts in the comments
Please Login to comment...