# NOT RUN {
## generate a graphon of type No.5 with 3 clusters
W = gmodel.preset(3,id=5)
## create a probability matrix for 100 nodes
graphW = gmodel.block(W,n=100)
P = graphW$P
## draw 10 observations from a given probability matrix
A = gmodel.P(P,rep=10)
## apply the method
res_r3 = est.completion(A,rank=3) # use rank-3 approximation
res_r9 = est.completion(A,rank=9) # use rank-9 approximation
res_rN = est.completion(A,adjust=FALSE) # stop the code if guess works poorly
## visualize
opar = par(no.readonly=TRUE)
par(mfrow=c(1,3), pty="s")
image(res_r3, main="rank 3")
image(res_r9, main="rank 9")
image(res_rN, main="rank is guessed")
par(opar)
# }
Run the code above in your browser using DataLab