R 中的网络模块化计算
网络模块化的方程式在其维基百科页面(以及知名书籍中)给出。我想看到它在某些代码中工作。我发现使用 模块化库 来实现这一点是可能的://igraph.sourceforge.net/" rel="nofollow">igraph 与 R 一起使用( R 统计计算基金会)。
我想看看代码中使用下面的示例(或类似的示例)来计算模块化。图书馆给出了示例,但这并不是我真正想要的。
让我们有一组顶点 V = {1, 2, 3, 4, 5} 和边 E = {(1,5), (2,3), (2,4), (2,5) (3 ,5)} 形成无向图。
将这些顶点分为两个社区:c1 = {2,3} 和 c2 = {1,4,5}。要计算的是这两个社区的模块化。
The equation for Network Modularity is given on its wikipedia page (and in reputable books). I want to see it working in some code. I have found this is possible using the modularity library for igraph used with R (The R Foundation for Statistical Computing).
I want to see the example below (or a similar one) used in the code to calculate the modularity. The library gives on example but it isn't really what I want.
Let us have a set of vertices V = {1, 2, 3, 4, 5} and edges E = {(1,5), (2,3), (2,4), (2,5) (3,5)} that form an undirected graph.
Divide these vertices into two communities: c1 = {2,3} and c2 = {1,4,5}. It is the modularity of these two communities that is to be computed.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这里有一些解释:
创建图形时使用的向量是图形的边列表。 (在早于 0.6 的 igraph 版本中,我们必须从数字中减去 1,因为 igraph 当时使用从零开始的顶点索引,但现在不再使用)。
隶属向量
membership
的第i元素给出了顶点i所属的社区的索引。Some explanation here:
The vector I use when creating the graph is the edge list of the graph. (In igraph versions older than 0.6, we had to subtract 1 from the numbers because igraph uses zero-based vertex indices at that time, but not any more).
The i-th element of the membership vector
membership
gives the index of the community to which vertex i belongs.