📜  SymPy | Python中的 Prufer.nodes()

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

SymPy | Python中的 Prufer.nodes()

Prufer.nodes() :nodes()是一个 sympy Python库函数,它返回树中的节点数。

代码 #1:nodes() 示例

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

输出 :

代码 #2:nodes() 示例

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

输出 :