xxxxxxxxxx
#Define variables if you want to use them
x = var('x')
#Define the length of each step (should sum up to one...)
I=[0.3,0.3,0.4]
#Define the values of the graphon W on each step in a len(I)xlen(I) matrix
W=[[0.3,0.3,0],[1,0.1,0.4],[0.5,0,1]]
#Define the number of vertices of the graph H
n=4
#Define the edge set of H, write edges: [i,j] with i<j using the vertex set 0,...,n-1
H=[[0,1],[1,2],[2,3],[0,3]]
#########Below is the code (ignore)###########
#Function generating all possible distributions of the vertices of H among the steps
def distr(l):
if l == 0:
yield []
else:
for vector in distr(l-1):
for l in range(len(I)):
yield vector + [l]
#Function to calculate the density
def density(H,W,I):
#Generate list of distributions of vertices
Distributions=[ w for w in distr(n) ]
result=0
#Loop over all distributions
for D in Distributions:
#Calculate the probability that this vertex distribution occurs
p=1
for i in range(n):
p=p*I[D[i]]
#Calculate the H-density for this vertex distribution
d=1
for i in range(n):
for j in range(i,n):
if [i,j] in H:
d=d*W[D[i]][D[j]]
#sum up the weighted partial H-densities
result=result+p*d
return simplify(result)
density(H,W,I)
xxxxxxxxxx
exp(pi*i)