Skip to content

Commit bda5453

Browse files
committed
update: imagens
1 parent 401ffc4 commit bda5453

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

arvore.png

22.1 KB
Loading

grafo.png

7.36 KB
Loading

prim.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def prim(n, n_out):
3030
arv_ger_mim = []
3131

3232
print(f"\nIniciando o algoritmo a partir da raiz: {raiz}\n")
33-
33+
cont = 0
3434
while n_edge < n - 1:
3535
while True:
3636
c, a, b = heapq.heappop(H)
@@ -43,15 +43,18 @@ def prim(n, n_out):
4343

4444
marcados[b] = True
4545
custo_tot += c
46-
print("\n###### RESULTADOS ######")
46+
print(f"\n###### RESULTADOS ({cont}) ######")
47+
cont +=1
4748
arv_ger_mim.append((a, b))
4849
n_edge += 1
4950

5051
for (x, c) in n_out[b]:
5152
if not marcados[x]:
5253
heapq.heappush(H, (c, b, x))
5354

54-
print(f"Custo Total da Árvore Geradora Mínima: {custo_tot}\n")
55+
print("\n### HEAP ###")
56+
print(H)
57+
print(f"\nCusto Total da Árvore Geradora Mínima: {custo_tot}\n")
5558

5659
print("Arestas da Árvore Geradora Mínima:")
5760
for a, b in arv_ger_mim:

0 commit comments

Comments
 (0)