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

find_partition_temporal broken? #60

Closed kauttoj closed 3 years ago

kauttoj commented 3 years ago

I'm trying to partition a temporal graph, but the example given in the documentation is not working. When running this example

import igraph as ig
import leidenalg as la

n = 100
G_1 = ig.Graph.Lattice([n], 1)
G_1.vs['id'] = list(range(n))
G_2 = ig.Graph.Lattice([n], 1)
G_2.vs['id'] = list(range(n))
membership, improvement = la.find_partition_temporal([G_1, G_2],la.ModularityVertexPartition,interslice_weight=1)

I get the following error:

  File "C:\Anaconda3\lib\site-packages\leidenalg\functions.py", line 283, in find_partition_temporal
    partitions.append(partition_type(**arg_dict))
  File "C:\Anaconda3\lib\site-packages\leidenalg\VertexPartition.py", line 462, in __init__
    initial_membership, weights, node_sizes)
BaseException: Could not construct partition: Node size vector not the same size as the number of nodes.

I'm running versions 0.8.3 (leidenalg) and 0.9.0 (igraph) with Python 3.7.3 in Windows 10. I tried clean install of both.

EDIT: I noticed that if I just leave out variable "node_sizes" (which is typically redundant anyway) for the C call in VertexPartition.py line 461 the code runs fine, i.e., self._partition = _c_leiden._new_ModularityVertexPartition(pygraph_t, initial_membership, weights)

However, maybe there are some bad effects of this...?

jnash22 commented 3 years ago

I am having the same problem as above

vtraag commented 3 years ago

I'll take a look shortly!

vtraag commented 3 years ago

This is now solved in the master branch and will be included in the next release. Thanks for reporting the bug!

jnash22 commented 3 years ago

Thank you so much, Also GREAT Package!