📜  SymPy | Python中的 Prufer.to_tree()

📅  最后修改于: 2022-05-13 01:54:56.158000             🧑  作者: Mango

SymPy | Python中的 Prufer.to_tree()

Prufer.to_tree() : to_tree()是一个 sympy Python库函数,它返回 Prufer 序列的树表示。

代码 #1:to_tree() 示例

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

输出 :

代码 #2:to_tree() 示例

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

输出 :