我是R的新手,我的课程已经完成了作业。我必须创建1000个鄂尔多斯 - 仁义模型网络。问题是,我实际上可以创建一个模型,检查它的参数,如度分布,绘制它等。我也可以检查它的传递性等等。但是,我必须将这1000个网络的平均聚类系数(本地传递性)与我们在Cytoscape中处理类的某个网络进行比较。这是我已经知道的代码:
library(igraph)
g<-erdos.renyi.game(1000,2000, type=c("gnm"))
transitivity(g) #and other atrributes...
g2<-replicate(g,1000)
transitivity(g2[[1]])
#now I have sort of list with every graph but when I try to analyze
#I got the communicate that it is not a graph object
我必须从这1000个网络计算标准偏差并表示ACC,然后进行比较。 我会感激任何帮助。
我实际上做了很多尝试:
g<-erdos.renyi.game(1026,2222,type=c("gnm"))
g2<-1000*g
transitivity(g2[2]) # this however ends in "not a graph object"error
g2[1] #outputs the adjacency matrix but instead of 1026 vertices,
#I've got 1026000 vertices, so multiplication doesn't replicate function
#but parameters
另外,我尝试统一图表列表
glist<-1000*g
acc<-union(glist, byname="auto")
transitivity(acc) #outputs the same value as first function g (only one
#erdos-renyi graph
答案 0 :(得分:1)
要使多个图形相乘,请使用
下面的复制功能g<-erdos.renyi.game(100, 20, type=c("gnm"))
g2<-replicate(1000, erdos.renyi.game(100, 20, type=c("gnm")), simplify=FALSE);
sapply(g2, transitivity)
计算某些属性的平均值,如平均度或传递性使用:
mean(sapply(g2, transitivity))