In general, what is the question, there is a list (graph). If you run this code. That result will be not full but i want that the result will be where the arrow shows. How to fix my problem? If you could rewrite this code. I tryid use 1 more list for keys (first number in pair) and finding this and rewrite to second list. I want to go down the graph. RESULT
link = [[1, 3], [3, 2], [2, 6], [1, 4], [4, 3], [3, 7], [7, 8], [8, 9]]
link_keys = []
cpy_link = []
number = 0
diametr = 0
k = len(link)
m = 0
def circle_for_net(number):
for j in range(k):
while number == link[j][0]:
number = link[j][1]
cpy_link.append(number)
circle_for_net(number)
number = 0
break
def create_keys(link):
for j in range(k):
link_keys.append(link[j][0])
for i in range(k - 1):
for j in range(k - i - 1):
if link[j][0] > link[j + 1][0]:
link[j], link[j + 1] = link[j + 1], link[j]
create_keys(link)
for i in range(k):
number = link[i][1]
cpy_link.append(link[i][0])
cpy_link.append(number)
circle_for_net(number)
print(cpy_link)
if(diametr < len(cpy_link)):
diametr = len(cpy_link)
cpy_link.clear()
print(diametr)