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.combinatorics import Permutation, Cycle from sympy.combinatorics.prufer import Prufer # Using from # sympy.combinatorics.prufer.Prufer.tree_repr() # Creating Prufer a = Prufer([1, 2, 3], [2, 4, 5]) # tree_repr value # rank = 2 # n = 5 print ("Prufer a tree_repr : ", a.tree_repr) |
Output :
Prufer a tree_repr : [[0, 1], [1, 2], [2, 3], [3, 4]]
Code #2 : tree_repr() Example
# Python code explaining # SymPy.Prufer.tree_repr() # importing SymPy libraries from sympy.combinatorics import Permutation, Cycle from sympy.combinatorics.prufer import Prufer # Using from # sympy.combinatorics.prufer.Prufer.tree_repr() # Creating Prufer b = Prufer([1, 2, 3, 2, 4, 5], [6, 7], [8]) # tree_repr value # rank = 2 # n = 5 print ("Prufer b tree_repr : ", b.tree_repr) |
Output :
Prufer b tree_repr : [[0, 1], [1, 2], [3, 6], [2, 3], [2, 4], [4, 5], [5, 7]]
Recommended Posts:
- How to write an empty function in Python - pass statement?
- Operator Functions in Python | Set 2
- Time Functions in Python | Set-2 (Date Manipulations)
- Send mail from your Gmail account using Python
- Python – The new generation Language
- Print Single and Multiple variable in Python
- Increment and Decrement Operators in Python
- str() vs repr() in Python
- Swap two variables in one line in C/C++, Python, PHP and Java
- Generate all permutation of a set in Python
- Class or Static Variables in Python
- trunc() in Python
- Division Operators in Python
- Interesting facts about strings in Python | Set 1
- When to use yield instead of return in Python?
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.



