SymPy | Prufer.nodes() in Python
Prufer.nodes() : nodes() is a sympy Python library function that returns the number of nodes in the tree.
Syntax :
sympy.combinatorics.Prufer.prufer.nodes()
Return :
the number of nodes in the tree
Code #1 : nodes() Example
from sympy.combinatorics import Permutation, Cycle
from sympy.combinatorics.prufer import Prufer
a = Prufer([ 1 , 2 , 3 ], [ 2 , 4 , 5 ])
print ( "Prufer a nodes : " , a.nodes)
|
Output :
Prufer a nodes : 5
Code #2 : nodes() 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 nodes : " , b.nodes)
|
Output :
Prufer b nodes : 8
Last Updated :
26 Aug, 2019
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...