Open In App

SymPy | Prufer.edges() in Python

Last Updated : 28 Aug, 2019
Improve
Improve
Like Article
Like
Save
Share
Report

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)



Similar Reads

SymPy | Prufer.rank() in Python
Prufer.rank() : rank() is a sympy Python library function that returns the rank of the Prufer sequence. Syntax : sympy.combinatorics.Prufer.prufer.rank() Return : rank of the Prufer sequence Code #1 : rank() Example # Python code explaining # SymPy.Prufer.rank() # importing SymPy libraries from sympy.combinatorics import Permutation, Cycle from sym
1 min read
SymPy | Prufer.size() in Python
Prufer.size() : size() is a sympy Python library function that returns the size of the Prufer sequence. Syntax : sympy.combinatorics.Prufer.prufer.size() Return : size of the Prufer sequence Code #1 : size() Example # Python code explaining # SymPy.Prufer.size() # importing SymPy libraries from sympy.combinatorics import Permutation, Cycle from sym
1 min read
SymPy | Prufer.to_prufer() in Python
Prufer.to_prufer() : to_prufer() is a sympy Python library function that returns the Prufer sequence for a argumented tree which is given as a list of edges and n is the number of nodes in the tree. Syntax : sympy.combinatorics.Prufer.prufer.to_prufer() Return : Prufer sequence for a argumented tree Code #1 : to_prufer() Example # Python code expla
1 min read
SymPy | Prufer.unrank() in Python
Prufer.unrank() : unrank() is a sympy Python library function that returns the unranked Prufer sequence. Syntax : sympy.combinatorics.Prufer.prufer.unrank() Return : unranked Prufer sequence Code #1 : unrank() Example # Python code explaining # SymPy.Prufer.unrank() # importing SymPy libraries from sympy.combinatorics import Permutation, Cycle from
1 min read
SymPy | Prufer.tree_repr() in Python
Prufer.tree_repr() : tree_repr() is a sympy Python library function that returns the tree representation of Prufer sequence. Syntax : sympy.combinatorics.Prufer.prufer.tree_repr() Return : tree representation of Prufer sequence Code #1 : tree_repr() Example # Python code explaining # SymPy.Prufer.tree_repr() # importing SymPy libraries from sympy.c
1 min read
SymPy | Prufer.prufer_rank() in Python
Prufer.prufer_rank() : prufer_rank() is a sympy Python library function that calculates the rank of a Prufer sequence Syntax : sympy.combinatorics.Prufer.prufer.prufer_rank() Return : rank of a Prufer sequence Code #1 : prufer_rank() Example # Python code explaining # SymPy.Prufer.prufer_rank() # importing SymPy libraries from sympy.combinatorics i
1 min read
SymPy | Prufer.prev() in Python
Prufer.prev() : prev() is a sympy Python library function that returns the Prufer sequence that is delta before the current one. Syntax : sympy.combinatorics.Prufer.prufer.prev() Return : Prufer sequence that is delta before the current one Code #1 : prev() Example # Python code explaining # SymPy.Prufer.prev() # importing SymPy libraries from symp
1 min read
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 # Python code explaining # SymPy.Prufer.nodes() # importing SymPy libraries from sympy.combinatorics import Permutation, Cycle
1 min read
SymPy | Prufer.prufer_repr() in Python
Prufer.prufer_repr() : prufer_repr() is a sympy Python library function that returns the Prufer sequence for the Prufer object. By removing the highest numbered vertex, then recording the node it was attached to, and finally continuing until only two vertices remain, the sequence can be found. Syntax : sympy.combinatorics.Prufer.prufer.prufer_repr(
1 min read
SymPy | Prufer.next() in Python
Prufer.next() : next() is a sympy Python library function that returns the Prufer sequence that is delta beyond the current one. Syntax : sympy.combinatorics.Prufer.prufer.next() Return : Prufer sequence that is delta beyond the current one Code #1 : next() Example # Python code explaining # SymPy.Prufer.next() # importing SymPy libraries from symp
1 min read
Article Tags :
Practice Tags :