-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgrafo.py
More file actions
21 lines (19 loc) · 752 Bytes
/
grafo.py
File metadata and controls
21 lines (19 loc) · 752 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
while True:
user = input("Digite os valores para adicionar na árvore:\nExemplo de input: 2,5,6,8\nPara sair digite: 0,0,0\nValores: ").split(",")
list_nodes = [int(x.strip()) for x in user]
if list_nodes.count(0) == 3:
break
arvore = AVL(list_nodes)
while True:
user = input("\n1 - Imprimir árvore binária\n2 - Balancear árvore\n3 - Inserir novo vértice\n4 - Sair\nOpcao: ")
if user == "1":
print(arvore)
elif user == "2":
arvore.BalanceTree()
elif user == "3":
new_node = int(input("Valor do novo vértice: "))
arvore.insertNode(new_node)
elif user == "4":
break
else:
print("Comando inválido.")