Closed kalthwaini closed 1 year ago
Your example is incomplete, so it is hard to tell what issue you're really having.
In any case, the functionality definitely appears to work.
>>> import leidenalg as la
>>> import igraph as ig
>>>
>>> G = ig.Graph.Famous("Zachary")
>>> optimiser = la.Optimiser()
>>>
>>> optimiser.set_rng_seed(0)
>>> part = la.ModularityVertexPartition(G)
>>> optimiser.optimise_partition(part)
0.4695923734385273
>>>
>>> part.membership
[1, 1, 1, 1, 3, ...]
>>>
>>> G.es['weights'] = [100] + [1] * (G.ecount() - 1)
>>> print(G.es['weights'])
[100, 1, 1, 1, 1, ...]
>>>
>>> optimiser.set_rng_seed(0)
>>> part = la.ModularityVertexPartition(G, weights='weights')
>>> optimiser.optimise_partition(part)
0.5940662006447701
>>>
>>> part.membership # partition membership has changed
[3, 3, 1, 1, 2, ...]
I'm experimenting the leidenalg community detection and have noticed that weights is not affecting the results? also i have inverted weights to double check and still, weights not doing a noticeable impact on the results. my cods:
optimiser = la.Optimiser() optimiser.set_rng_seed(0) partitions = la.ModularityVertexPartition(g, weights='weights')
diff = 1 _ = datetime.datetime.now().timestamp()
while diff > 0 and (datetime.datetime.now().timestamp() - _) < 30: diff = optimiser.optimise_partition(partitions)
My question is: am I missing something?