Thursday, December 18, 2025
HomeLanguagesSymPy | Prufer.to_prufer() in Python

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


Output :

Prufer a size : [0, 0]

Code #2 : to_prufer() Example




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


Output :

Prufer b size : [0, 0]

Dominic
Dominichttp://wardslaus.com
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

Most Popular

Dominic
32455 POSTS0 COMMENTS
Milvus
108 POSTS0 COMMENTS
Nango Kala
6823 POSTS0 COMMENTS
Nicole Veronica
11958 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12037 POSTS0 COMMENTS
Shaida Kate Naidoo
6958 POSTS0 COMMENTS
Ted Musemwa
7203 POSTS0 COMMENTS
Thapelo Manthata
6911 POSTS0 COMMENTS
Umr Jansen
6890 POSTS0 COMMENTS