Closed aigora-de closed 1 year ago
Hi Vincent,
Sorry for not responding here sooner, but following our chat the solution became clear!
In my original post, case 3 fixed nodes already allocated to a community in the first run, leaving new nodes free to be partitioned as appropriate. (Obvious in hindsight, but) the solution was to leave new nodes free (as before), and additionally "unfix" old nodes iff they now have a relationship with one or more new nodes.
Since new nodes and their relationships are typically a very small proportion of the total graph, this solution is working well.
Again, many thanks for taking the time to consider my request for help.
Great to see that the proposed solution works well for your case!
Hi Vincent, not so much an issue as a request for help or advice about the correct use of leidenalg.
The example python code pasted below shows what I'm trying to do; I have a graph
g
which I do an initial partitioning from scratch. From time to time, new nodes and edges are added (show here asg_1
). I want to update the clustering using the new nodes and edges, but I'd like to preserve (most of) the original partitioning. I'm using leidenalg.ModularityVertexPartition.In the first place, I'm setting the RNG seed to 42 and you can see in my example that I get deterministic outputs for the same input (graph
g
).I then update
g
tog_1
with some new nodes and edges and try three cases:For my use case, I'd like the community ID to persist across updates and I only want to update the communities / nodes that have changed, or been added. Otherwise, I may as well do a completely new partitioning of the graph after each update.
In my example code, the function
check_communities()
prints a mapping of common and changed ocmmunities. I could use this to update the changed communities with their new IDs, but this is inefficient for my real world graphs which have hundreds of thousands of nodes.There isn't much difference between case 1 and case 2 above (without and with
initial_membership
respectively), which begs the question, 'why provide initial_membership if it's mostly ignored?'Case 3 does much better at preserving the community IDs, but at the expense of also preserving the singletons. I suppose I could fix communities of a certain minimum soze, but what arbitrary size?
In conclusion, I think I must be approaching this in the wrong way, as I can't believe others haven't had this problem and solved it. Should I be using a layered graph?
Many thanks for any help or advice you can offer.
Best wishes
Dave