Skip to content

Commit 4fd6ea0

Browse files
committed
fix: do not try to use node_weights in community_leiden() when its allocation failed
1 parent 8d72bfc commit 4fd6ea0

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/_igraph/graphobject.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13840,15 +13840,16 @@ PyObject *igraphmodule_Graph_community_leiden(igraphmodule_GraphObject *self,
1384013840
igraphmodule_handle_igraph_error();
1384113841
error = -1;
1384213842
} else if (igraph_strength(
13843-
&self->g, node_weights, igraph_vss_all(),
13844-
igraph_is_directed(&self->g) ? IGRAPH_OUT : IGRAPH_ALL,
13845-
IGRAPH_NO_LOOPS, edge_weights
13846-
)) {
13843+
&self->g, node_weights, igraph_vss_all(),
13844+
igraph_is_directed(&self->g) ? IGRAPH_OUT : IGRAPH_ALL,
13845+
IGRAPH_NO_LOOPS, edge_weights)) {
1384713846
igraphmodule_handle_igraph_error();
1384813847
error = -1;
1384913848
}
1385013849
}
13851-
resolution /= igraph_vector_sum(node_weights);
13850+
if (!error) {
13851+
resolution /= igraph_vector_sum(node_weights);
13852+
}
1385213853
}
1385313854

1385413855
/* Run actual Leiden algorithm for several iterations. */

0 commit comments

Comments
 (0)