Skip to content

Commit 6d52cb8

Browse files
authored
Fix possible crash in Leiden algorithm (#289)
1 parent 4190b95 commit 6d52cb8

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

src/_igraph/graphobject.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11763,7 +11763,7 @@ PyObject *igraphmodule_Graph_community_leiden(igraphmodule_GraphObject *self,
1176311763
long int n_iterations = 2;
1176411764
double resolution_parameter = 1.0;
1176511765
double beta = 0.01;
11766-
igraph_vector_t *edge_weights = NULL, *node_weights = NULL, *membership;
11766+
igraph_vector_t *edge_weights = NULL, *node_weights = NULL, *membership = NULL;
1176711767
igraph_bool_t start = 1;
1176811768
igraph_bool_t normalize_resolution = 0;
1176911769
igraph_integer_t nb_clusters = 0;
@@ -11859,7 +11859,7 @@ PyObject *igraphmodule_Graph_community_leiden(igraphmodule_GraphObject *self,
1185911859
free(node_weights);
1186011860
}
1186111861

11862-
if (!error) {
11862+
if (!error && membership != 0) {
1186311863
res = igraphmodule_vector_t_to_PyList(membership, IGRAPHMODULE_TYPE_INT);
1186411864
}
1186511865

0 commit comments

Comments
 (0)