vtraag / leidenalg

Implementation of the Leiden algorithm for various quality functions to be used with igraph in Python.
GNU General Public License v3.0
596 stars 78 forks source link

Adding/Removing an edge and re-run Leiden #57

Closed gebaltso closed 2 years ago

gebaltso commented 3 years ago

Hello again! I have a question: I have a network and run Leiden on it. After some calculations I may add or remove an edge from the network (only edge not node), and after that I want to re-run Leiden to see if there is any change in the partitioning (which should only be around the affected area). Is it possible to re-run Leiden in incremental way? Because one major problem is the different partitions I get every time I run the algorithm even when I give the same seed. Would the use of temporal help? In the manner that I use the initial graph and the changed one(that which has edge changes).

vtraag commented 2 years ago

Sorry about the very long delay. The easiest might be to simply supply the initial_membership argument in find_partition. More generally, you can always first create a new partition and then improve it further, see the docs for more details on that.

The alternative that you suggested is also a good one to see how stable the communities are with respect to the additional / removed edge. However, note that you will not necessarily keep the membership of the original graph fixed.

one major problem is the different partitions I get every time I run the algorithm even when I give the same seed.

This should not happen. If you use the same random seed, it should always return the same result. Could you provide a small reproducible example that shows that you get different results, even when using the same seed?

vtraag commented 2 years ago

I'm closing this for now. If you do still have an issue @gebaltso, feel free to re-open this issue (or open a new issue if it is a new problem of course).