Search code examples
networkxpartitionmodularityweighted

networkx calculate a a good partition and modularity of it


I am looking for a method in networkx that does the same as this one, except that it does consider edge weights: https://networkx.github.io/documentation/latest/reference/algorithms/generated/networkx.algorithms.community.modularity_max.greedy_modularity_communities.html

greedy_modularity_communities:

Find communities in graph using Clauset-Newman-Moore greedy modularity maximization. This method currently supports the Graph class and does not consider edge weights.

Does it exist? I can't find it. Thanks for reading.


Solution

  • Does it have to be Networkx? The iGraph package offers significantly more functionality for community detection, including an implementation of weighted fastgreedy. You can save your graph file in Networkx as .gml, which would make it easily transferable to iGraph.

    If you go to this page, you'll see a full list of the detection algorithms this package offers, each starting with the tag 'community_'. The page will also provide tutorials on how to implement these algorithms.

    I don't think Networkx offers this functioning directly, however there is an add-on package called python-louvain which might provide what you're looking for.