Open In App
Related Articles

SymPy | Prufer.nodes() in Python

Improve
Improve
Improve
Like Article
Like
Save Article
Save
Report issue
Report
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
# Python code explaining
# SymPy.Prufer.nodes()
  
# importing SymPy libraries
from sympy.combinatorics import Permutation, Cycle
from sympy.combinatorics.prufer import Prufer
  
# Using from 
# sympy.combinatorics.prufer.Prufer.nodes()
  
# Creating Prufer
a = Prufer([1, 2, 3], [2, 4, 5])
  
# nodes value
print ("Prufer a nodes : ", a.nodes)

                    
Output :
Prufer a nodes : 5
Code #2 : nodes() Example
# Python code explaining
# SymPy.Prufer.nodes()
  
# importing SymPy libraries
from sympy.combinatorics import Permutation, Cycle
from sympy.combinatorics.prufer import Prufer
  
# Using from 
# sympy.combinatorics.prufer.Prufer.nodes()
  
# Creating Prufer
b = Prufer([1, 2, 3, 2, 4, 5], [6, 7], [8])
  
# nodes value
print ("Prufer b nodes : ", b.nodes)

                    
Output :
Prufer b nodes : 8


Last Updated : 26 Aug, 2019
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads