-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgenericSRG.sage
48 lines (39 loc) · 1.22 KB
/
genericSRG.sage
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
spectrum = [32] + [2]*56+[-8]*18
# FIXME fix it.
def does_interlace(Y, X):
for i in xrange(1,len(Y)+1):
x1 = i-1
y = i-1
x2 = (len(X)-len(Y)+i)-1
if not (X[x1] >= Y[y] and Y[y] >= X[x2]):
return False
return True
def does_interlace_float(Y, X) :
for i in xrange(1,len(Y)+1):
x1 = i-1
y = i-1
x2 = (len(X)-len(Y)+i)-1
if not ((X[x1]-Y[y] >= 0.00000001 or abs(X[x1]-Y[y]) < 1/10**11) and ( abs(Y[y]-X[x2]) < 1/10**11 or Y[y]-X[x2] >= 0.000001)):
return False
return True
def spec(G):
return sorted(G.eigenvalues(), reverse=True)
def partitionedAM(G, field=QQ):
v = 75
k = 32
A = G.am()
n = G.order()+1
M = matrix(field,n,n)
inbe = 0
for i in xrange(n-1):
for j in xrange(i+1, n-1):
M[i,j] = M[j,i] = A[i,j]
M[i,n-1] = k-G.degree(i)
inbe += M[i,n-1]
M[n-1,i] = (k-G.degree(i))/(v-n+1)
M[n-1,n-1] = 2*(k*v/2.0 - G.size()-inbe)/(v-n+1)
return M
def isInterlaced(G):
return does_interlace(spec(partitionedAM(G)), spectrum)
def isInterlacedFast(G):
return does_interlace_float(spec(partitionedAM(G, field=RDF)), spectrum)