在igraph中生成社区图

编程入门 行业动态 更新时间:2024-10-28 09:26:09
本文介绍了在igraph中生成社区图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我一直在寻找这个问题的答案,但找不到任何提及,因此我决定在此处发布.我正在尝试查看igraph或任何软件包是否提供了一种创建社区图"的简单方法,其中每个节点代表网络中的社区,而联系关系则代表了社区之间的联系.我可以使社区检测算法在igraph中正常工作,但是我找不到一种方法来折叠结果以仅显示每个社区之间的联系.任何帮助将不胜感激.

I have been searching for an answer to this question but could not find any mention, so I decided to post here. I am trying to see if igraph or any packages provide a simple way to create a "community graph" where each node represents a community in the network and the ties represent ties between the communities. I can get the community detection algorithm to work fine in igraph, but I could not find a way to collapse the results to just show connections between each community. Any assistance would be appreciated.

推荐答案

您可以简单地使用 contract.vertices()函数.这将顶点组收缩为单个顶点,基本上与您想要的方式相同.例如.

You can simply use the contract.vertices() function. This contracts groups of vertices into a single vertex, essentially the same way you want it. E.g.

library(igraph) ## create example graph g1 <- graph.full(5) V(g1)$name <- 1:5 g2 <- graph.full(5) V(g2)$name <- 6:10 g3 <- graph.ring(5) V(g3)$name <- 11:15 g <- g1 %du% g2 %du% g3 + edge('1', '6') + edge('1', '11') ## Community structure fc <- fastgreedymunity(g) ## Create community graph, edge weights are the number of edges cg <- contract.vertices(g, membership(fc)) E(cg)$weight <- 1 cg2 <- simplify(cg, remove.loops=FALSE) ## Plot the community graph plot(cg2, edge.label=E(cg2)$weight, margin=.5, layout=layout.circle)

更多推荐

在igraph中生成社区图

本文发布于:2023-07-18 08:26:01,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1142827.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:社区   igraph

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!