Assume there are 3 time slices (i.e., G_1
, G_2
, G_3
) that converted to layers
via time_slices_to_layers
. These layers and inter slices were then subject to find_partition
to get their communities
. However, plotting these partition does not result the expected output.
However, plotting the partition result give a incorrect intraslice link
connection.
May I know how to fix this issue.
I suspect this is due to wrongly assign the vertex_label
ig.plot(partition,vertex_label = ['A','B','C','D','E','F','G'])
or it can be related to other configuration ?
The complete code to reproduce the above graph
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']
G_layers, G_interslice, G = la.time_slices_to_layers ( [G_1, G_2, G_3], interslice_weight=1,
slice_attr='slice', vertex_id_attr='id',
edge_type_attr='type', weight_attr='weight' )
partition = la.find_partition(G, la.CPMVertexPartition,resolution_parameter = 0.05);
ig.plot(partition,vertex_label = ['A','B','C','D','E','F','G'])
P.S., Similar post has been published at SO: python - igraph plot for multiple layers partition does not return expected output - Stack Overflow