SymPy | Prufer.edges() in Python
Last Updated :
28 Aug, 2019
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
from sympy.combinatorics import Permutation, Cycle
from sympy.combinatorics.prufer import Prufer
a = Prufer.edges([ 1 , 2 , 3 ], [ 2 , 4 , 5 ])
print ( "Prufer a edges : " , a)
|
Output :
Prufer a edges : ([[0, 1], [1, 2], [1, 3], [3, 4]], 5)
Code #2 : edges() Example
from sympy.combinatorics import Permutation, Cycle
from sympy.combinatorics.prufer import Prufer
b = Prufer.edges([ 1 , 2 , 3 , 2 , 4 , 5 ], [ 6 , 7 ], [ 8 ])
print ( "Prufer b edges : " , b)
|
Output :
Prufer b edges : ([[0, 1], [1, 2], [1, 3], [3, 4], [5, 6]], 7)
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...