vtraag/leidenalg

find_partition_multiplex

elisabettabiondi opened this issue · 4 comments

Thank you, @vtraag. Since I am not able to reopen the issue, I open a new one here.
A simple question:
Once I run:

optimiser = la.Optimiser()
diff = optimiser.optimise_partition_multiplex([part_pos, part_neg], layer_weights=[1, -1])

how do I get the vertices belonging to each partition?

Hi @elisabettabiondi, you are calling find_partition_multiplex which is expecting to be passed igraph.Graphs, not leidenalg.VertexPartitions. If you look at the example in the documentation at https://leidenalg.readthedocs.io/en/stable/multiplex.html#negative-links, you can see that it uses optimise_partition_multiplex, not find_partition_multiplex.

This should solve your problem. If it doesn't, feel free to re-open the issue!

Originally posted by @vtraag in #179 (comment)

Since I am not able to reopen the issue, I open a new one here.

Sorry, my bad. Indeed, you can't re-open it, but I could after commenting. Anyway, doesn't matter, we can continue the discussion here.

Once I run:

optimiser = la.Optimiser()
diff = optimiser.optimise_partition_multiplex([part_pos, part_neg], layer_weights=[1, -1])

You can retrieve the membership from part_pos and part_neg (both contain the same partitioning information). These are objects that are derived from igraph.VertexClustering, see that documentation for more information.

Perfect, thank you!
Is there a way to force the partition to be of length 2?

I found the answer by myself in this previous issue:
#89 (comment)

Great you found the answer!

One additional tip by the way, as explained in the documentation on optimise_partition_multiplex, it might be better to set consider_comms to leidenalg.ALL_COMMS when dealing with negative links.