简体   繁体   English

python 中的模块化最大化和 GenLouvain 实现

[英]Modularity maximization and GenLouvain implementation in python

I have a temporal multilayer.network that I want to find communities by using modularity maximization.我有一个时间 multilayer.network,我想通过使用模块化最大化来找到社区。

I was wondering if there is an equivalent version of Matlab GenLouvain in Python for maximizing modularity in community detection?我想知道 Python 中是否有 Matlab GenLouvain 的等效版本,用于最大化社区检测中的模块化?

Preliminary search yielded this library, but the corresponding GitHub repository is gone.初步搜索到这个库,但是对应的GitHub库没有了。

https://pypi.org/project/louvain/ https://pypi.org/project/louvain/

There are several other algorithms, such as Leiden algorithm ( https://www.nature.com/articles/s41598-019-41695-z ) for maximizing modularity with python implementation ( https://github.com/vtraag/leidenalg ) but I am trying to explore my options at the moment and run different solvers on the supra-modularity matrix I have.还有其他几种算法,例如 Leiden 算法 ( https://www.nature.com/articles/s41598-019-41695-z ),用于通过 python 实现 ( https://github.com/vtraag/leidenalg ) 最大化模块化但我现在正在尝试探索我的选择,并在我拥有的超模块化矩阵上运行不同的求解器。 So, I want to start with the good old GenLouvain and then compare different solvers with python implementation.所以,我想从好的旧 GenLouvain 开始,然后比较不同的求解器与 python 实现。

Does anyone have any suggestions?有没有人有什么建议?

i currently use CPMVertexPartion from leidenalg to analyse my networks.我目前使用来自 leidenalg 的 CPMVertexPartion 来分析我的网络。 by varying the resolution parameter i can find maximum modularity Q. my network is dense, beta approx >10, and modularity can improve up to 0.5通过改变分辨率参数,我可以找到最大的模块化 Q。我的网络是密集的,beta 大约 >10,并且模块化可以提高到 0.5

It's been a while I posted this question but as given above I found out the leidenalg is the best implementation in Python for Multilayer Modularity Maximization(MMM) with the improvement of intermediate refinement step, handling arbitrarily disconnected communities appropriately.我发布这个问题已经有一段时间了,但如上所述,我发现leidenalg是 Python 中用于多层模块化最大化(MMM)的最佳实现,其中改进了中间细化步骤,适当地处理任意断开的社区。

Here's a piece of code I use to implement MMM with the configuration null model.这是我使用配置 null model 实现 MMM 的一段代码。

def leiden(self, G, interslice, resolution):
    ## G: the appropriate igraph as explained in the documentation
    ## interslice: float, interlayer edge weights for the diagonal coupling of consecutive layers
    ## resolution: float, spatial resolution parameter
    
    layers, interslice_layer, G_full = la.time_slices_to_layers(G, interslice_weight = interslice)
    
    partitions = [la.RBConfigurationVertexPartition(H, 
                                        weights = 'weight', 
                                        resolution_parameter = resolution) for H in layers]

    ## resolution parameter below has to be 0 to recover the original multilayer modularity equation
    interslice_partition = la.RBConfigurationVertexPartition(interslice_layer, 
                                                             weights = 'weight',
                                                             resolution_parameter = 0)
                                                 
    optimiser = la.Optimiser()
    
    diff = optimiser.optimise_partition_multiplex(partitions + [interslice_partition])

    return(partitions, interslice_partition)

Having said that, MMM is not the greatest approach to perform dynamic community detection.话虽如此,MMM 并不是执行动态社区检测的最佳方法。 There are more temporal community detection tools in the literature that is utilizing random walks , stochastic block models , tensor factorization methods one should check.文献中有更多的时间社区检测工具正在利用随机游走随机块模型张量分解方法,应该检查一下。

There is now a Python reimplementation of GenLouvain called PyGenStability available here .现在有一个 Python 的 GenLouvain 重新实现,称为 PyGenStability,可在此处获得。 It optimizes Markov Stability (a generalization of Modularity) with the Louvain or Leiden algorithms.它使用 Louvain 或 Leiden 算法优化马尔可夫稳定性(模块化的概括)。

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

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