本文介绍了按标签对igraph图形进行分组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试通过边缘特征(如其标签)对igraph图形进行子集化.在一个可复制的示例中,我做了一点改动就从另一个帖子中偷偷摸摸偷了,我希望能够将最佳朋友"关系(BF)与家庭关系"(FAM)分开:
I am trying to subset a igraph graph by an edge characteristics (like its label). In the reproducible example I have shamelessly stolen from another post with a little modification, I would like to be able to separate the Best Friend ties (BF) from the Family ties (FAM):
edges <- matrix(c(103, 86, 24, 103, 103, 2, 92, 103, 87, 103, 103, 101, 103, 44), ncol=2, byrow=T)
g <- graph(as.vector(t(edges)))
E(g)[c(2:4,7)]$label<-"FAM"
E(g)[c(1,5,6)]$label<-"BF"
到目前为止,我能做的最好的事情就是显示具有一种领带类型的边缘:
The best I can do so far is display the edges which have one type of tie:
E(g)[E(g)$label=="BF"]
V(g)[E(g)$label=="BF"]
推荐答案
如何:
gfam <- subgraph.edges(graph=g, eids=which(E(g)$label=="FAM"), delete.vertices = TRUE)
gbf <- subgraph.edges(graph=g, eids=which(E(g)$label=="BF"), delete.vertices = TRUE)
有关igraph/网络分析教程/无耻插件的建议: http://sna.stanford.edu/rlabs .php
Suggestion for igraph/network analysis tutorial/shameless plug: http://sna.stanford.edu/rlabs.php
这篇关于按标签对igraph图形进行分组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!