■
library(igraph) g<-read.graph(commandArgs()[5], format="edgelist",directed=FALSE) cs<-clusters(g) csh<-hist(cs$csize,breaks=seq(min(cs$csize),max(cs$csize),1)) S<-0 for(i in 1:max(csh$breaks)){ cat(i,csh$counts[i],"\n") if(!is.na(csh$counts[i])) S<-S+(csh$counts[i]*(csh$breaks[i]^2))/vcount(g) } S
igraphを使ったネットワークの統計量
g<-read.graph(commandArgs()[5], format="edgelist",directed=FALSE)
- 平均経路長
average.path.length(g)
- ノード数
vcount(g)
- リンク数
ecount(g)
- クラスター数
clusters(g)
正確には
cs <- clusters(g)
cs$no
- ネットワークの直径
diameter(g,unconnected=TRUE)
- write.tableで失敗?
write.table(Out,FN,append=T) : これではダメ
write.table(Out,FN,append=TRUE) : 失敗
TRUEまですべて書かないとダメっぽい。@unixマシンにて。Windowsでは試してない。