Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiplex/Temporal modularity score #193

Open
ulgenklc opened this issue Dec 5, 2024 · 0 comments
Open

Multiplex/Temporal modularity score #193

ulgenklc opened this issue Dec 5, 2024 · 0 comments

Comments

@ulgenklc
Copy link

ulgenklc commented Dec 5, 2024

Hello Vincent

I have been using leidenalg for years, and I would like to thank you for your work.

My question is if there is a helper function within leidenalg or igraph that calculates the multilayer modularity score for a given quality function and VertexPartition, similar to G.modularity() in igraph?

In particular, for a given list of upper triangular np.arrays of adjacency matrices (list_adjacency):

length = len(list_adjacency)
size = list_adjacency[0].shape[0]
Gs = []
for l in range(length):
  conn_indices = np.where(list_adjacency[l])
  weights = list_adjacency[l][conn_indices] # get the weights corresponding to these indices
  edges = zip(*conn_indices) # a sequence of (i, j) tuples, each corresponding to an edge from i -> j
  G = ig.Graph(n = size, edges=edges, directed=False)# initialize the graph from the edge sequence
  G.vs['id'] = list(range(list_adjacency[l].shape[0]))
  G.vs['node_size'] = 0
  G.es['weight'] = weights #assign node names and weights to be attributes of the vertices and edgesrespectively
  Gs.append(G)

I'm trying to compute the Multilayer Modularity score (or whatever quality function is being used) for the interslice_partition below:

layers, interslice_layer, G_full = time_slices_to_layers(Gs)
partitions = [la.RBConfigurationVertexPartition(H, weights = 'weight', resolution_parameter = 0.98) for H in layers]
interslice_partition = la.RBConfigurationVertexPartition(interslice_layer, weights = 'weight', resolution_parameter = 0)
optimiser = la.Optimiser()
diff = optimiser.optimise_partition_multiplex(partitions + [interslice_partition], n_iterations = 10)

Something like:

G_full.multiplex_modularity(interslice_partition._membership, weights='weight', resolution=0.98, directed=False, VertexPart = la.RBConfigurationVertexPartition)

Note that last argument VertexPart would indicate the quality function that is used, which is different from G.modularity().

Thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant