我发布这个问题已经有一段时间了,但如上所述,我发现leidenalg是 Python 中用于多层模块化最大化(MMM)的最佳实现,它改进了中间细化步骤,适当地处理了任意断开的社区。
这是我用来实现带有配置空模型的 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)
话虽如此,MMM 并不是执行动态社区检测的最佳方法。文献中有更多的时间社区检测工具正在利用随机游走、随机块模型、张量分解方法,应该检查一下。