📜  SymPy | Python中的 Prufer.edges()

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

SymPy | Python中的 Prufer.edges()

Prufer.edges() :edges()是一个 sympy Python库函数,它返回节点数和给定运行的边列表,这些运行连接整数标记树中的节点。

代码 #1:edges() 示例

# 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)

输出 :

代码 #2:edges() 示例

# 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)

输出 :