Advertisement
Guest User

circle

a guest
Oct 24th, 2016
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.46 KB | None | 0 0
  1. import sys
  2. import random
  3. import heapq
  4. # import cProfile
  5.  
  6. def circleMST(n):
  7.  
  8. E = [-2] * (n - 1)
  9. for i in range((n - 1) * (n - 2) / 2):
  10. d = random.uniform(0, 2)
  11. if d < -E[0]:
  12. heapq.heappop(E)
  13. heapq.heappush(E, -d)
  14. print -sum(E)
  15.  
  16. if __name__ == "__main__":
  17. if len(sys.argv) > 1:
  18. testMST(int(sys.argv[1]))
  19. else:
  20. print("No valid argument")
  21. # cProfile.run('circleMST(10000)')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement