taynaud / python-louvain

Louvain Community Detection
BSD 3-Clause "New" or "Revised" License
965 stars 200 forks source link

miscalculation the local modularity gain #51

Closed datazhen closed 2 years ago

datazhen commented 5 years ago

Hi, I derived a formula which is the gain in modularity when removing a node i from its community : WechatIMG386

but it looks a little different followed in community_louvain.__one_level() module:

remove_cost = - resolution * neigh_communities.get(com_node,0) + \ (status.degrees.get(com_node, 0.) - status.gdegrees.get(node, 0.)) * degc_totw

should we change status.gdegrees.get(node, 0.) to status.gdegrees.get(node, 0.)/2?

taynaud commented 3 years ago

I think that this /2 is already applied in degc_totw ?