Prufer.edges() : edges() is a sympy Python library function that returns the number of nodes and a list of edges from the given runs that connect nodes in an integer labelled tree.
Syntax :
sympy.combinatorics.Prufer.prufer.edges()Return :
number of nodes and a list of edges
Code #1 : edges() Example
# Python code explaining# SymPy.Prufer.edges() # importing SymPy librariesfrom sympy.combinatorics import Permutation, Cyclefrom sympy.combinatorics.prufer import Prufer # Using from # sympy.combinatorics.prufer.Prufer.edges() # Creating Prufera = Prufer.edges([1, 2, 3], [2, 4, 5]) # edge valueprint ("Prufer a edges : ", a) |
Output :
Prufer a edges : ([[0, 1], [1, 2], [1, 3], [3, 4]], 5)
Code #2 : edges() Example
# Python code explaining# SymPy.Prufer.edges() # importing SymPy librariesfrom sympy.combinatorics import Permutation, Cyclefrom sympy.combinatorics.prufer import Prufer # Using from # sympy.combinatorics.prufer.Prufer.edges() # Creating Pruferb = Prufer.edges([1, 2, 3, 2, 4, 5], [6, 7], [8]) # edge value print ("Prufer b edges : ", b) |
Output :
Prufer b edges : ([[0, 1], [1, 2], [1, 3], [3, 4], [5, 6]], 7)
Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.
To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course. And to begin with your Machine Learning Journey, join the Machine Learning – Basic Level Course


