davegimo

Untitled

Jan 20th, 2023
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. #n nodi
  2. # 0,1,2,3,4,5,6...n-1
  3. #tipologia = [B,P,B,P,P,P,P,B.......A]
  4.  
  5. def es1(G):
  6. n = size(G)
  7.  
  8. for i in range(n):
  9. if tipologia[i] == "B":
  10. dist = Dijkstra(G,i)
  11. minimi = trova_3_minimi(dist)
  12. print(i,minimi)
  13.  
  14.  
  15.  
  16. def trova_3_minimi(dist):
  17. piscine = []
  18.  
  19. for i in range(len(dist)):
  20. if tipologia[i] == 'P':
  21. piscine.append((i,dist[i]))
  22.  
  23. piscine = mergesort(piscine)
  24. minimi = []
  25. if len(piscine) > 3:
  26.  
  27. minimi.append(piscine[0][0])
  28. minimi.append(piscine[1][0])
  29. minimi.append(piscine[2][0])
  30.  
  31. else:
  32. for i in range(len(piscine)):
  33. minimi.append(piscine[i][0])
  34.  
  35. return minimi
Advertisement
Add Comment
Please, Sign In to add comment