Advertisement
Guest User

Untitled

a guest
Nov 18th, 2016
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.28 KB | None | 0 0
  1. import random
  2. import math
  3. import sys
  4.  
  5.  
  6. f = open('../cplusplus/'+sys.argv[2]+'.txt', 'w')
  7. nodes = int(sys.argv[1]);
  8. width = 600;
  9. height = 600;
  10. clusters = 2;
  11. wstep = width / clusters;
  12. hstep = height / clusters;
  13. f.write(str(nodes) + '\n');
  14.  
  15. def circleCoords(r):
  16. radian = random.uniform(0,6.3);
  17. return (r*math.cos(radian), r * math.sin(radian))
  18.  
  19. for x in range(nodes):
  20. i = random.randint(1,clusters-1);
  21. ch = random.choice([1,2,3,4,5,6]);
  22. if ch == 1:
  23. f.write(str(random.uniform(0,wstep) + i * wstep) + ' ' + str(random.uniform(0,hstep) + i * hstep) + '\n')
  24. elif ch == 2:
  25. f.write(str(random.uniform(0,wstep) + i * wstep) + ' ' + str(random.uniform(0,hstep) + (clusters-i - 1) * hstep) + '\n')
  26. elif ch == 3:
  27. f.write(str(random.uniform(0,wstep) + (clusters - i - 1) * wstep) + ' ' + str(random.uniform(0,hstep) + i * hstep) + '\n')
  28. elif ch == 4:
  29. f.write(str(random.uniform(0,wstep) + (clusters-i-1) * wstep) + ' ' + str(random.uniform(0,hstep) + (clusters-i-1) * hstep) + '\n')
  30. elif ch == 5:
  31. f.write(str(random.uniform(0,wstep)) + ' ' + str(random.uniform(0,hstep) + i * hstep) + '\n')
  32. elif ch == 6:
  33. f.write(str(random.uniform(0,wstep) + i * wstep)+ ' ' + str(random.uniform(0,hstep)) + '\n')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement