@@ -147,19 +147,19 @@ like to be able to set three different resolution parameters: one for within
147147each class :math: `\gamma _0 , \gamma _1 `, and one for the links between classes,
148148:math: `\gamma _{01 }`. Then the formulation would be
149149
150- .. math :: Q = \sum_{ij}
150+ .. math :: Q = \sum_{ij}
151151 [A_{ij}
152- - (\g amma_0\d elta(s_i,0) + \g amma_1\d elta(s_i,1)) \d elta(s_i,s_j)
153- - \g amma_{01}(1 - \d elta(s_i, s_j))
152+ - (\g amma_0\d elta(s_i,0) + \g amma_1\d elta(s_i,1)) \d elta(s_i,s_j)
153+ - \g amma_{01}(1 - \d elta(s_i, s_j))
154154 ]\d elta(\s igma_i, \s igma_j)
155155
156156where :math: `s_i` denotes the bipartite class of a node and :math: `\sigma _i`
157157the community of the node as elsewhere in the documentation. Rewriting as a sum
158158over communities gives a bit more insight
159159
160- .. math :: Q = \sum_c (e_c
160+ .. math :: Q = \sum_c (e_c
161161 - \g amma_{01} 2 n_c(0) n_c(1)
162- - \g amma_0 n^2_c(0)
162+ - \g amma_0 n^2_c(0)
163163 - \g amma_1 n^2_c(1))
164164
165165where :math: `n_c(0 )` is the number of nodes in community :math: `c` of class 0
@@ -188,7 +188,7 @@ layer has layer weight 1, we obtain the following:
188188 + ( \g amma_{01} - \g amma_1) n_c(1)^2
189189 ] \\
190190 &= \s um_c (e_c - \g amma_{01} 2 n_c(0) n_c(1)
191- - \g amma_{0} n_c(0)^2
191+ - \g amma_{0} n_c(0)^2
192192 - \g amma_{1} n_c(1)^2) \\
193193
194194Hence detecting communities with these three layers corresponds to detecting
@@ -199,15 +199,17 @@ corresponds to the CPM method. However, using a little additional trick, we can
199199also make this work for modularity. Essentially, modularity is nothing else
200200than CPM with the ``node_size `` set to the degree, and the resolution parameter
201201set to :math: `\gamma = \frac {1 }{2 m}`. In particular, in general (i.e. not
202- specifically for bipartite graph) if ``node_sizes=G.degree() `` we then obtain
202+ specifically for bipartite graph) if ``node_sizes=G.degree() `` we then obtain
203203
204204.. math :: Q = \sum_{ij} A_{ij} - \gamma k_i k_j
205205
206206In the case of bipartite graphs something similar is obtained, but then
207207correctly adapted (as long as the resolution parameter is also appropriately
208208rescaled). Note that this is only possible for modularity for undirected
209209graphs. Hence, we can also detect communities in bipartite networks using
210- modularity by using this little trick.
210+ modularity by using this little trick. The definition of modularity for
211+ bipartite graphs is identical to the formulation of bipartite modularity
212+ provided in [3 ]_.
211213
212214All of this has been implemented in the constructor
213215:func: `~leidenalg.CPMVertexPartition.Bipartite `. You can simply pass in a
@@ -225,7 +227,7 @@ An explicit example of this:
225227
226228>>> p_01, p_0, p_1 = la.CPMVertexPartition.Bipartite(G,
227229... resolution_parameter_01= 0.1 );
228- >>> diff = optimiser.optimise_partition_multiplex([p_01, p_0, p_1],
230+ >>> diff = optimiser.optimise_partition_multiplex([p_01, p_0, p_1],
229231... layer_weights= [1 , - 1 , - 1 ]);
230232
231233Slices to layers
@@ -309,13 +311,13 @@ types for different layers.
309311 :class: `~leidenalg.SignificanceVertexPartition `.
310312
311313.. testsetup ::
312-
314+
313315 gamma = 0.5;
314316
315- >>> partitions = [la.CPMVertexPartition(H, node_sizes = ' node_size' ,
316- ... weights= ' weight' , resolution_parameter= gamma)
317+ >>> partitions = [la.CPMVertexPartition(H, node_sizes = ' node_size' ,
318+ ... weights= ' weight' , resolution_parameter= gamma)
317319... for H in layers];
318- >>> interslice_partition = la.CPMVertexPartition(interslice_layer, resolution_parameter = 0 ,
320+ >>> interslice_partition = la.CPMVertexPartition(interslice_layer, resolution_parameter = 0 ,
319321... node_sizes= ' node_size' , weights= ' weight' );
320322
321323You can then simply optimise these partitions as before using
@@ -349,12 +351,12 @@ partitions in a slightly more convenient way using
349351>>> layers, interslice_layer, G_full = \
350352... la.time_slices_to_layers([G_1, G_2, G_3],
351353... interslice_weight= 0.1 );
352- >>> partitions = [la.CPMVertexPartition(H, node_sizes = ' node_size' ,
353- ... weights= ' weight' ,
354- ... resolution_parameter= gamma)
354+ >>> partitions = [la.CPMVertexPartition(H, node_sizes = ' node_size' ,
355+ ... weights= ' weight' ,
356+ ... resolution_parameter= gamma)
355357... for H in layers];
356358>>> interslice_partition = \
357- ... la.CPMVertexPartition(interslice_layer, resolution_parameter = 0 ,
359+ ... la.CPMVertexPartition(interslice_layer, resolution_parameter = 0 ,
358360... node_sizes= ' node_size' , weights= ' weight' );
359361>>> diff = optimiser.optimise_partition_multiplex(partitions + [interslice_partition]);
360362
@@ -371,3 +373,6 @@ References
371373 .. [2 ] Traag, V. A., & Bruggeman, J. (2009). Community detection in networks
372374 with positive and negative links. Physical Review E, 80(3), 036115.
373375 `10.1103/PhysRevE.80.036115 <http://doi.org/10.1103/PhysRevE.80.036115 >`_
376+ .. [3 ] Barber, M. J. (2007). Modularity and community detection in bipartite
377+ networks. Physical Review E, 76(6), 066102. `10.1103/PhysRevE.76.066102
378+ <https://doi.org/10.1103/PhysRevE.76.066102> `_
0 commit comments