SymPy | Python中的 Prufer.next()
Prufer.next() :next()是一个 sympy Python库函数,它返回比当前序列差 delta 的 Prufer 序列。
Syntax :
sympy.combinatorics.Prufer.prufer.next()
Return :
Prufer sequence that is delta beyond the current one
代码 #1:next() 示例
# Python code explaining
# SymPy.Prufer.next()
# importing SymPy libraries
from sympy.combinatorics import Permutation, Cycle
from sympy.combinatorics.prufer import Prufer
# Using from
# sympy.combinatorics.prufer.Prufer.next()
# Creating Prufer
a = Prufer([1, 2, 3], [2, 4, 5])
# next value
print ("Prufer a next : ", a.next(1))
输出 :
Prufer a next : Prufer([1, 2, 4])
代码 #2:next() 示例
# Python code explaining
# SymPy.Prufer.next()
# importing SymPy libraries
from sympy.combinatorics import Permutation, Cycle
from sympy.combinatorics.prufer import Prufer
# Using from
# sympy.combinatorics.prufer.Prufer.next()
# Creating Prufer
b = Prufer([1, 2, 3, 2, 4, 5], [6, 7], [8])
# next value
print ("Prufer b next : ", b.next(1))
输出 :
Prufer b next : Prufer([1, 2, 3, 2, 4, 6])