Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set the resolution parameter for Louvain modularity in igraph?

is there a way to set the resolution parameter when using the function cluster_louvain to detect communities in igraph for R? It makes a lot of difference for the result, as this parameter is related to the hierarchical dissimilarity between nodes. Thank you.

like image 384
Marco Avatar asked Mar 29 '17 17:03

Marco


1 Answers

The easiest way to do it is through the resolution package, available in this link https://github.com/analyxcompany/resolution

It is based on this paper http://arxiv.org/pdf/0812.1770.pdf

It pretty much has 2 functions cluster_resolution() and cluster_resolution_RandomOrderFULL(). In both you can state the resolution t and how many repetitions you want rep. And, you can just use the igraph object in the function.

cluster_resolution_RandomOrderFULL(g,t=0.5)
cluster_resolution_RandomOrderFULL(g,rep=20)

NOTE/EDIT: it will not accept signed networks though! I'm trying to either contact the owner of the code or costumize it myself to make it suitable for signed networks.

EDIT2: I was able to translate the function community_louvain.m from the Brain Connectivity Toolbox for Matlab to R.

Here is the github link for the signed_louvain()

you can pretty much just put for ex. signed_louvain(g, gamma = 1, mod = 'modularity') it works with igraph or matrix objects as input. If it has negative values, you have to choose mod = 'neg_sym' or 'neg_asym'.

like image 89
CAOC Avatar answered Nov 15 '22 03:11

CAOC