Closed judekurn closed 6 years ago
@judekurn I am also using louvain method
for community detection and when I saw this issue I tried to reproduce communities after restarting kernel and It worked fine for me. Every time same communities with same nodes.
Please have a look at my louvain ipython notebook
You will also find a copy of karate_club
data as plain .txt
format in the same directory.
I hope this helps :+1:
@judekurn On another note. If you are using networkx
package for creating graphs from edgelist
file with nx.read_edgelist
please consider putting the parameter nodetype
as int
that way it will give you consistent graph thus a consistent outcome on community detection.
I removed nodetype
form nx.read_edgelist
and I was finally see what you were facing. The communities were having different nodes.
Thank you for your replies, they are very helpful. I am using nx.from_pandas_edgelist
method and the nodes are in str
format. As you suggested, I retraced my steps back to networkx and found the culprit: Giant = max(nx.connected_component_subgraphs(G), key=len)
. I use this because I want to apply the Louvain method on the 'giant' connected graph only. When I remove this code, everything works the way it should be. Again, thanks Dalwar for your help.
How can I reproduce the same partitions everytime I run best_partition?
I use best_partition to produce community clusters for my research and wrote an entire chapter on the result. But when I restart the notebook, I got a different number of partitions with different memberships. That means, I cannot 'reproduce' the result I have written and my entire chapter is no longer reproducible. How can I recreate the partitions which I found previously? Btw, this problem happens on a graph with 131 nodes, but works fine (i.e. reproducible) for a graph with 51 nodes. Thanks.