如何在igraph中基于社区成员资格和大小对图表进行子集化

时间:2015-01-19 20:21:35

标签: r igraph

我正在尝试根据社区成员资格对图表进行分组,条件是我不希望结果中包含1号社区(大小为1的图表) 我想出的但不是一个成功的人:

karate <- graph.famous("Zachary")
karate <- add.vertices(karate, 6) #to have zero degree vertices
wckarate=walktrap.community(karate) 
lapply(sort(unique(membership(wckarate))), function(g) {
  subg<-induced.subgraph(karate, which((membership(wckarate)==g)  & ( sizes( wckarate)[[g]]!=1)))})

结果:

[[1]]
IGRAPH U--- 9 15 -- Zachary
+ attr: name (g/c)

[[2]]
IGRAPH U--- 7 6 -- Zachary
+ attr: name (g/c)

[[3]]
IGRAPH U--- 9 15 -- Zachary
+ attr: name (g/c)

[[4]]
IGRAPH U--- 4 4 -- Zachary
+ attr: name (g/c)

[[5]]
IGRAPH U--- 5 6 -- Zachary
+ attr: name (g/c)

[[6]]
IGRAPH U--- 0 0 -- Zachary
+ attr: name (g/c)

....

[[11]]
IGRAPH U--- 0 0 -- Zachary
+ attr: name (g/c)

如何避免使用NULL图形对象?

提前谢谢

0 个答案:

没有答案