Hi @vtraag, thanks for responding.
Sorry for the lack of information provided, but previously I had to trim some content (i.e., image) due to the new member requirement.
Actually, I desire to reproduce the figure in the slice to layers example (describe in leidenalg-multiplex section), as shown below
Here.the node interaction for each of the 3 time slices are maintained and were map using the numpy array (A1
,A2
,A3
-in the code provided above)
Given that I would like to reproduce the above figure, I assume we need to time_slices_to_layers
rather than directly used find_partition_temporal
as you suggested. Hence, I change the code into
gamma=0
optimiser = la.Optimiser()
layers, interslice, G = la.time_slices_to_layers ( [G_1, G_2, G_3], interslice_weight=1)
partitions = [la.CPMVertexPartition(H, node_sizes='node_size',weights='weight',
resolution_parameter=gamma) for H in layers];
interslice_partition = la.CPMVertexPartition(interslice, resolution_parameter=gamma,
node_sizes='node_size', weights='weight');
diff = optimiser.optimise_partition_multiplex(partitions + [interslice_partition]);
ig.plot(diff,vertex_label = G.vs['id'])
However, ig.plot(diff,vertex_label = G.vs['id'])
or ig.plot(diff)
return a white blank figure.
The full code are provided below.
p.s. I cannot hide my excitement as the author himself reply this OP
import leidenalg as la
import igraph as ig
import numpy as np
A1 = np.array ( [[0., 0., 0., 0., 0,0,0],[5., 0., 0., 0., 0,0,0],[1., 0., 0., 0., 0,0,0],
[0., 1., 2., 0., 0,0,0],[0., 0., 0., 1., 0,0,0], [0., 0., 0., 1., 0,0,0],
[0., 0., 0., 0., 1,1,0]] )
A2 = np.array ( [[0., 0., 0., 0., 0,0,0],[5., 0., 0., 0., 0,0,0], [1., 0., 0., 0., 0,0,0],
[0., 1., 2., 0., 0,0,0], [0., 0., 0., 1., 0,0,0],[0., 0., 1., 1., 0,0,0],
[0., 0., 0., 0., 1,1,0]] )
A3 = np.array ( [[0., 0., 0., 0., 0,0,0], [0., 0., 0., 0., 0,0,0],[0., 0., 0., 0., 0,0,0],
[0., 1., 2., 0., 0,0,0],[0., 0., 0., 1., 0,0,0],[0., 0., 0., 1., 0,0,0],
[0., 0., 0., 0., 1,1,0]] )
G_1 = ig.Graph.Weighted_Adjacency ( A1.tolist () )
G_2 = ig.Graph.Weighted_Adjacency ( A2.tolist () )
G_3 = ig.Graph.Weighted_Adjacency ( A3.tolist () )
G_1.vs ['id'] = ['A','B','C','D','E','F','G']
G_2.vs ['id'] = ['A','B','C','D','E','F','G']
G_3.vs ['id'] = ['A','B','C','D','E','F','G']
gamma=0
optimiser = la.Optimiser()
layers, interslice, G = la.time_slices_to_layers ( [G_1, G_2, G_3], interslice_weight=1)
partitions = [la.CPMVertexPartition(H, node_sizes='node_size',weights='weight',
resolution_parameter=gamma) for H in layers];
interslice_partition = la.CPMVertexPartition(interslice, resolution_parameter=gamma,
node_sizes='node_size', weights='weight');
diff = optimiser.optimise_partition_multiplex(partitions + [interslice_partition]);
ig.plot(diff,vertex_label = G.vs['id'])