Hey!
Apologies for that, Here you go!
def probzu(A,S): #A is the adjacency matrix of the graph and S is the sample
p=1
k= np.repeat(A, S, axis=0)
A1= np.repeat(k, S, axis=1) #A1 is An of the paper where the rows and columns are repeated as per the sample
z= np.abs(haf(A1)) ** 2 #The hafnian calculation of An
_, s, _ = np.linalg.svd(A, full_matrices=True)
c = 1 / ( np.max(s) + 1e-8 ) #Calculation of the maximum singular value of A
Ab = c * np.block([ #Calculating Q so building \Tilde{A} for that
[A, np.zeros(A.shape)],
[np.zeros(A.shape), A]
])
X = np.block([ #The X matrix
[np.zeros(A.shape), np.identity(A.shape[0])],
[np.identity(A.shape[0]), np.zeros(A.shape)]
])
I = np.identity(Ab.shape[0])
Q = np.linalg.inv(I - X @ Ab) #Calculating Q as per paper
B = math.sqrt(np.linalg.det(Q)) #Square root of determinent of Q
for i in range(len(S)):
p= p*math.factorial(S[i]) #factorial n! of the sample
prob= z/(p*B) #probability calculation with hafian divided by sqrt(detQ)*factorial
return prob
A= np.array([[0,0,1,0,1], #example
[0,0,0,1,1],
[1,0,0,1,1],
[0,1,1,0,0],
[1,1,1,0,0]])
print(probzu(A,[0,0,0,0,0])) #passing the example with a sample all 0
print(sf.apps.similarity.prob_orbit_exact(nx.from_numpy_array(A),[0,0,0,0,0])) #all-zero orbit probability
probzu is my function that calculates probability as per eq.3 of paper. Yes my displacement is 0 too!
Apologies for the inconvenience.