Я попытался написать функцию, которая получала бы 2 аргумента: (amount_of_nodes, степень_of_each_edge).Эта функция должна построить граф с узлами amount_of_nodes, и каждый узел имеет степень deg_of_each_edge.Эта функция не работает правильно, и мне нужна помощь, чтобы исправить это, помогите мне, пожалуйста:
def k_degree_graph(amount_of_vertex, degree_of_vertex):
global G
degree_of_vertex-=1
G=nx.Graph()
list_of_nodes = [i for i in range(1, amount_of_vertex + 1)]
G.add_nodes_from(list_of_nodes)
for i in range(1, amount_of_vertex + 1):
for j in range(1, degree_of_vertex + degree_of_vertex%2):
if i>j:
buffer=(i, i-j)
else:
buffer=(i, i-j+amount_of_vertex)
G.add_edge(*buffer)
draw_graph()