我有一个有几个组件的网络,我想:
玩具例子:
g <- graph(c("a","b","b","c","c","a","f","g","h","g"))
result_g <- graph(c("f", "g","h","g"))发布于 2018-12-05 18:59:29
为此,您可以首先使用components函数将图拆分为连接的组件。然后,您可以测试每个组件,看看它是否是一个完整的子图。图是满的当且仅当边数等于n(n-1)/2,其中n是节点数。所以,用你的例子:
CompList = components(g)
NotFull = c()
for(i in 1:CompList$no) {
COMP = induced_subgraph(g, which(CompList$membership==i))
VC = vcount(COMP)
if(ecount(COMP) != VC*(VC-1)/2) {
NotFull = c(NotFull, which(CompList$membership==i)) }
}
result_g = induced_subgraph(g, NotFull)
result_g
IGRAPH 5d61ea5 DN-- 3 2 --
+ attr: name (v/c)
+ edges from 5d61ea5 (vertex names):
[1] f->g h->ghttps://stackoverflow.com/questions/53638449
复制相似问题