Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import random
- import math
- import sys
- f = open('../cplusplus/'+sys.argv[2]+'.txt', 'w')
- nodes = int(sys.argv[1]);
- width = 600;
- height = 600;
- clusters = 2;
- wstep = width / clusters;
- hstep = height / clusters;
- f.write(str(nodes) + '\n');
- def circleCoords(r):
- radian = random.uniform(0,6.3);
- return (r*math.cos(radian), r * math.sin(radian))
- for x in range(nodes):
- i = random.randint(1,clusters-1);
- ch = random.choice([1,2,3,4,5,6]);
- if ch == 1:
- f.write(str(random.uniform(0,wstep) + i * wstep) + ' ' + str(random.uniform(0,hstep) + i * hstep) + '\n')
- elif ch == 2:
- f.write(str(random.uniform(0,wstep) + i * wstep) + ' ' + str(random.uniform(0,hstep) + (clusters-i - 1) * hstep) + '\n')
- elif ch == 3:
- f.write(str(random.uniform(0,wstep) + (clusters - i - 1) * wstep) + ' ' + str(random.uniform(0,hstep) + i * hstep) + '\n')
- elif ch == 4:
- f.write(str(random.uniform(0,wstep) + (clusters-i-1) * wstep) + ' ' + str(random.uniform(0,hstep) + (clusters-i-1) * hstep) + '\n')
- elif ch == 5:
- f.write(str(random.uniform(0,wstep)) + ' ' + str(random.uniform(0,hstep) + i * hstep) + '\n')
- elif ch == 6:
- 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