Skip to content

Commit

Permalink
Merge pull request #129 from bfarahdel/find_partition_multiplex_layer…
Browse files Browse the repository at this point in the history
…_weights

Layer weights parameter for the find_partition_multiplex function
  • Loading branch information
vtraag committed Jun 30, 2023
2 parents f7cd826 + f837898 commit 25e4f58
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/leidenalg/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def find_partition(graph, partition_type, initial_membership=None, weights=None,

return partition

def find_partition_multiplex(graphs, partition_type, n_iterations=2, max_comm_size=0, seed=None, **kwargs):
def find_partition_multiplex(graphs, partition_type, layer_weights=None, n_iterations=2, max_comm_size=0, seed=None, **kwargs):
""" Detect communities for multiplex graphs.
Each graph should be defined on the same set of vertices, only the edges may
Expand All @@ -108,6 +108,10 @@ def find_partition_multiplex(graphs, partition_type, n_iterations=2, max_comm_si
partition_type : type of :class:`MutableVertexPartition`
The type of partition to use for optimisation (identical for all graphs).
layer_weights : list of double
List containing weights of each layer. If None (the default), then all
layers are weighted with 1.
n_iterations : int
Number of iterations to run the Leiden algorithm. By default, 2 iterations
are run. If the number of iterations is negative, the Leiden algorithm is
Expand Down Expand Up @@ -153,9 +157,11 @@ def find_partition_multiplex(graphs, partition_type, n_iterations=2, max_comm_si
>>> membership, improvement = la.find_partition_multiplex([G_1, G_2],
... la.ModularityVertexPartition)
"""
n_layers = len(graphs)
partitions = []
layer_weights = [1]*n_layers
if layer_weights is None:
n_layers = len(graphs)
layer_weights = [1]*n_layers

partitions = []
for graph in graphs:
partitions.append(partition_type(graph, **kwargs))
optimiser = Optimiser()
Expand Down

0 comments on commit 25e4f58

Please # to comment.