Do graph_tool have Communities Louvain algorithm implementation in?

222 Views Asked by At

I'm working on code translating from Networkx to Igraph. This code use community detection based on Louvain Community detection algorithm. I din't find it on graph_tool documentation, do someone know if it exist? I readed the documentation of graph tool library.

1

There are 1 best solutions below

0
Tiago Peixoto On BEST ANSWER

This is covered in the FAQ: https://graph-tool.skewed.de/static/doc/faq.html#is-it-possible-to-perform-modularity-maximization-with-graph-tool

I quote the text below:

Is it possible to perform modularity maximization with graph-tool?

It is in fact possible to perform modularity maximization with graph-tool. For that you need to use the ModularityState object instead of BlockState, as documented in the section Inferring modular network structure, e.g.

g = gt.collection.data["football"]

state = gt.minimize_blockmodel_dl(g, state=gt.ModularityState)

However, please note the following admonition:

Danger: Using modularity maximization is almost always a terrible idea.

Modularity maximization is a substantially inferior method to the inference-based ones that are implemented in graph-tool, since it does not possess any kind of statistical regularization. Among many other problems, the method tends to massively overfit empirical data.

For a more detailed explanation see “Modularity maximization considered harmful”, as well as [peixoto-descriptive-2021].

Do not use this approach in the analysis of networks without understanding the consequences. This algorithm is included only for comparison purposes. In general, the inference-based approaches based on BlockState, NestedBlockState, and PPBlockState should be universally preferred.