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

temporal communities #56

Closed wmaclaren closed 3 years ago

wmaclaren commented 3 years ago

Hi, I've created a temporal network where each slice is a binary blocked adjacency matrix. Ideally then the algorithm should find as many communities as there are blocks. I'm not sure which are the actual partitions after I run the code below and have some problem exporting the output from leidenalg to for example numpy. The 'partitions' below contain as many objects as timepoints. When I take np.array(interslice_partition.membership).reshape([node, time]), the outcome does not make any sense given the input since I find many more communities than should be there. Appreciate any guidance on this.

 layers, interslice_layer, G_full = la.time_slices_to_layers(slices1,interslice_weight=0.1);
partitions = [la.CPMVertexPartition(H, node_sizes='node_size',
                                         weights='weight',
                                         resolution_parameter=gamma)
              for H in layers];

interslice_partition = \
              la.CPMVertexPartition(interslice_layer, resolution_parameter=0,
                                         node_sizes='node_size', weights='weight');
diff = optimiser.optimise_partition_multiplex(partitions + [interslice_partition]);
vtraag commented 3 years ago

The result of course depends on the resolution_parameter that you use. Note that you are using CPMVertexPartition, for which sensible resolution parameter values typically are in the order of the average (weighted) density of the network. If changing this does not work (try lower values in your case), let me know,