简体   繁体   English

R:具有(负)权重的有向图上的社区检测

[英]R: community detection on directed graph with (negative) weights

I am analysing a directed, weighted network with R igraph.我正在使用 R igraph 分析有向加权网络。 The network is based on a correlation matrix, ie weights go from -1 to +1.该网络基于相关矩阵,即权重从 -1 到 +1。 This network is clearly undirected, but I am also interested in more general cases.这个网络显然是无向的,但我也对更一般的情况感兴趣。

Based on this network I would like to perform a community detection to group "similar" nodes together.基于此网络,我想执行社区检测以将“相似”节点组合在一起。 I know there is a whole bunch of community detection methods in R igraph.我知道 R igraph 中有一大堆社区检测方法。 See for example here or here .例如,请参见此处此处

But none of these cases deals with negative weights.但是这些案例都没有处理负权重。

Is there an implementation in igraph (or in some other R package) which can deal with directed networks which have negative weights? igraph(或其他一些 R 包)中是否有可以处理具有负权重的有向网络的实现? Any hints are very appreciated.任何提示都非常感谢。

Not 100 % sure, if it violates any assumptions, but as a workaround I set all negative edge weights to zero before calculating Louvain community detection with igraph in R. At least, they are never included in community relationships.不是 100% 确定,如果它违反任何假设,但作为一种解决方法,我在使用 R 中的igraph计算Louvain 社区检测之前将所有负边缘权重设置为零。至少,它们从未包含在社区关系中。

E(g)$width <- ifelse(E(g)$width < 0, 0, E(g)$width)
g.louv <- cluster_louvain(g, weights = E(g)$width)

Note: this applies only to undirected graphs (I overlooked this detail of the question, sorry)注意:这仅适用于无向图(我忽略了问题的这个细节,抱歉)

Addressing a more general issue.解决一个更普遍的问题。 Using graphs and community detection to learn about groups of variables that have higher correlations with variables within the community rather than outside of the community seems rather exotic to me.使用图表和社区检测来了解与社区内而不是社区外的变量具有更高相关性的变量组对我来说似乎很奇怪。 Analyzing correlation matrices for groups of strongly correlated variables is a well known problem in statistics since 70+ years.自 70 多年来,分析强相关变量组的相关矩阵是统计学中的一个众所周知的问题。 Why don't you use PCA (eigenvalue decomposition) or SVD or MDS or some column clustering?为什么不使用 PCA(特征值分解)或 SVD 或 MDS 或某些列聚类? All can be easily performed in R.所有这些都可以在 R 中轻松执行。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM