# 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

 # Python code explaining # SymPy.Prufer.edges()    # importing SymPy libraries from sympy.combinatorics import Permutation, Cycle from sympy.combinatorics.prufer import Prufer    # Using from  # sympy.combinatorics.prufer.Prufer.edges()    # Creating Prufer a = Prufer.edges([1, 2, 3], [2, 4, 5])    # edge value print ("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 libraries from sympy.combinatorics import Permutation, Cycle from sympy.combinatorics.prufer import Prufer    # Using from  # sympy.combinatorics.prufer.Prufer.edges()    # Creating Prufer b = 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)

Article Tags :
Practice Tags :