I was missing the spam library. I did some testing with m x m matrices (see below). Computing 'a' is the villain. The computation time for 'a' is exponential in m. For a 100 by 100 matrix, the predicted time is about 20 seconds. Thus, 100,000 runs, would take about 23 days.
library(igraph) library(spdep) library(spam) d=5:40 tim1=NULL tim2=NULL tim3=NULL for(i in 1:length(d)){ x=rbinom(d[i]^2,1,0.5) dim(x)=c(d[i],d[i]) tim1[i]=system.time( a <- as.spam.listw(nb2listw(cell2nb(nrow(x),ncol(x),torus=T), style="B")) )[3] tim2[i]=system.time( g <- delete.vertices(graph.adjacency(a), which(x!=1)-1) )[3] tim3[i]=system.time( clusters(g) )[3] } reg=lm(log(tim1)~log(d)) par(mfcol=c(1,2)) plot(log(tim1)~log(d)) lines(x=log(d),y=coef(reg)[1]+coef(reg)[2]*log(d),type="l") plot(tim1~d) lines(x=d,y=exp(coef(reg)[1]+coef(reg)[2]*log(d)),type="l") #estimated time for a 100 by 100 matrix exp(predict(reg,newdata=data.frame(d=100))) #observed time for a 100 by 100 matrix d=100 x=rbinom(d^2,1,0.5) dim(x)=c(d,d) system.time(a <- as.spam.listw(nb2listw(cell2nb(nrow(x),ncol(x),torus=T), style="B"))) Best, Daniel -- View this message in context: http://r.789695.n4.nabble.com/Spatial-number-of-independent-components-tp2262018p2263168.html Sent from the R help mailing list archive at Nabble.com. ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.