tda1=function(M,B,be,gammat) ## M = number of nodes of the graph ## B = number of Monte Carlo replicates ## be = beta parameter of the Mittag-Leffler distribution (0 < be <= 1) ## gammat = scale factor (parameter of the exponential distribution if beta is 1) { tda=rep(0,B) for (b in 1:B) { A=matrix(rep(0,M^2),nrow=M) c=0 t=0 while (c==0) { tau <- rexp(1) if (be < 1) { u <- runif(1) w <- sin(be*pi)/tan(be*pi*u) - cos(be*pi) tau <- tau* (w^(1/be)) } tau <- gammat * tau deltat=tau i=sample(1:M, 2, replace = FALSE) if (A[i[1],i[2]]==0) { A[i[1],i[2]]=1 A[i[2],i[1]]=1 t=t+deltat for (j in 1:M) { if ((j!=i[1])&(j!=i[2])) { if (A[i[1],j]*A[i[2],j]==1) {c=1} } } } else { A[i[1],i[2]]=0 A[i[2],i[1]]=0 t=t+deltat } } tda[b]=t } tda1=tda } ###################################### ## First experiment M=10 B=10000 gammat <- 1 tda90=tda1(M,B,0.90,1) tda95=tda1(M,B,0.95,1) tda98=tda1(M,B,0.98,1) tda99=tda1(M,B,0.99,1) tdatot=c(tda90,tda95,tda98,tda99) beta=c(rep(0.90,B),rep(0.95,B),rep(0.98,B),rep(0.99,B)) boxplot(tdatot ~ beta,main="First example (Triangles)",xlab="beta",ylab="time",sub="M=10 nodes") by(tdatot,beta,summary) ###################################### ## Second experiment B=10000 be <- 0.99 gammat <- 1 mtda=matrix(rep(0,10*B),ncol=10) Mlab=5*(1:10) for (M in (1:10)) { mtda[,M]=tda1(5*M,B,be,gammat) } boxplot(mtda,names=Mlab,main="First example (Triangles)",xlab="number of nodes",ylab="time",sub="beta=0.99") mtda_mean=mean(as.data.frame(mtda)) mtda_med=rep(0,10) for (M in 1:10) { mtda_med[M]=median(mtda[,M]) } grange=range(mtda_mean,mtda_med) plot(Mlab,mtda_med,type="o",col="blue",main="First example (Triangles)",xlab="number of nodes",ylab="time",sub="beta=0.99",ylim=grange) lines(Mlab,mtda_mean, type="o", pch=22, lty=2, col="red") legend(5, grange[2], c("median","mean"), cex=1, col=c("blue","red"), pch=21:22, lty=1:2)