-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTestGraphs.py
More file actions
79 lines (61 loc) · 1.61 KB
/
Copy pathTestGraphs.py
File metadata and controls
79 lines (61 loc) · 1.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
def generateXi(x0,m,a,c):
Xi = []
Xi.append(x0)
nextnum = (a*x0+c) % m
i = 1
while nextnum not in Xi:
Xi.append(nextnum)
nextnum = (a*Xi[i]+c) % m
i += 1
return Xi
def generateYi(Xi,n):
Yi = []
i = 0
while i < len(Xi):
Yi.append(Xi[i] % n)
i += 1
return Yi
def gcd(a,b):
if b > a:
if b % a == 0:
return a
else:
return gcd(b % a,a)
else:
if a % b == 0:
return b
else:
return gcd(b,a % b)
def generateEdges(Yi,vb,n,m):
#Chromatic number of the graph
k = gcd(n,m)
i = 0
openfile = open("g1.txt","w")
while i < len(vb):
tempYi = Yi[:]
if vb[i] >= 1:
j = vb[i]
while j >= 1:
openfile.write(str(tempYi[0:k-i]))
openfile.write("\n")
del tempYi[:k-i]
j -= 1
i += 1
openfile.close()
def main():
n = int(raw_input("Enter Number of nodes: "))
a = int(raw_input("Enter the value of the multiplier: "))
c= int(raw_input("Enter the value of the increment: "))
m = int(raw_input("Enter the value of the modulo: "))
x0 = int(raw_input("Enter the initial value of the sequence Xi: "))
rawb = raw_input("Enter the (k-1) vector b: ")
b = map(int,rawb.split(","))
xi = generateXi(x0, m, a, c)
yi = generateYi(xi,n)
#print(xi)
#print(yi)
#print(len(xi))
#print("\n")
#print(len(yi))
generateEdges(yi, b, n, m)
main()