networkanalysis icon indicating copy to clipboard operation
networkanalysis copied to clipboard

Self-loops are not properly considered when using modularity

Open vtraag opened this issue 3 years ago • 0 comments

We ignore all self-loops upon reading a particular network. Although this works fine for CPM (as self-loops have no effect there) this is not entirely correct for modularity. In particular, the problem is that the nodeWeights are calculated using getTotalEdgeWeightPerNodeHelper, but this is called only after we have removed the self-loops. In other words, the nodeWeights reflect the degree without the self-loops.

https://github.com/CWTSLeiden/networkanalysis/blob/42fdd9e4d875455b9c992501123028f5e79a713b/src/main/java/nl/cwts/networkanalysis/Network.java#L1371

In addition, we do consider self-loops when calculating the "proper" resolution parameter:

https://github.com/CWTSLeiden/networkanalysis/blob/42fdd9e4d875455b9c992501123028f5e79a713b/src/main/java/nl/cwts/networkanalysis/run/RunNetworkClustering.java#L405

Both issues should be corrected in order to make modularity work correctly when self-loops are present in a network.

vtraag avatar Oct 12 '22 11:10 vtraag