Skip to content

Commit 1c423c6

Browse files
committed
chore: updated vendored igraph
1 parent 1c709fd commit 1c423c6

12 files changed

+423
-267
lines changed

src/_igraph/attributes.c

+107-72
Large diffs are not rendered by default.

src/_igraph/convert.c

+62-3
Original file line numberDiff line numberDiff line change
@@ -710,6 +710,36 @@ int igraphmodule_PyObject_to_loops_t(PyObject *o, igraph_loops_t *result) {
710710
TRANSLATE_ENUM_WITH(loops_tt);
711711
}
712712

713+
/**
714+
* \brief Converts a Python object to an igraph \c igraph_lpa_variant_t
715+
*/
716+
int igraphmodule_PyObject_to_lpa_variant_t(PyObject *o, igraph_lpa_variant_t *result) {
717+
static igraphmodule_enum_translation_table_entry_t lpa_variant_tt[] = {
718+
{"dominance", IGRAPH_LPA_DOMINANCE},
719+
{"retention", IGRAPH_LPA_RETENTION},
720+
{"fast", IGRAPH_LPA_FAST},
721+
{0,0}
722+
};
723+
724+
TRANSLATE_ENUM_WITH(lpa_variant_tt);
725+
}
726+
727+
/**
728+
* \brief Converts a Python object to an igraph \c igraph_mst_algorithm_t
729+
*/
730+
int igraphmodule_PyObject_to_mst_algorithm_t(PyObject *o, igraph_mst_algorithm_t *result) {
731+
static igraphmodule_enum_translation_table_entry_t mst_algorithm_tt[] = {
732+
{"auto", IGRAPH_MST_AUTOMATIC},
733+
{"automatic", IGRAPH_MST_AUTOMATIC},
734+
{"unweighted", IGRAPH_MST_UNWEIGHTED},
735+
{"prim", IGRAPH_MST_PRIM},
736+
{"kruskal", IGRAPH_MST_KRUSKAL},
737+
{0,0}
738+
};
739+
740+
TRANSLATE_ENUM_WITH(mst_algorithm_tt);
741+
}
742+
713743
/**
714744
* \ingroup python_interface_conversion
715745
* \brief Converts a Python object to an igraph \c igraph_random_walk_stuck_t
@@ -1962,7 +1992,19 @@ int igraphmodule_attrib_to_vector_t(PyObject *o, igraphmodule_GraphObject *self,
19621992
free(name);
19631993
return 1;
19641994
}
1965-
igraph_vector_init(result, n);
1995+
if (igraph_vector_init(result, 0)) {
1996+
igraphmodule_handle_igraph_error();
1997+
free(name);
1998+
free(result);
1999+
return 1;
2000+
}
2001+
if (igraph_vector_reserve(result, n)) {
2002+
igraphmodule_handle_igraph_error();
2003+
igraph_vector_destroy(result);
2004+
free(name);
2005+
free(result);
2006+
return 1;
2007+
}
19662008
if (attr_type == ATTRIBUTE_TYPE_VERTEX) {
19672009
if (igraphmodule_i_get_numeric_vertex_attr(&self->g, name,
19682010
igraph_vss_all(), result)) {
@@ -2157,7 +2199,19 @@ int igraphmodule_attrib_to_vector_bool_t(PyObject *o, igraphmodule_GraphObject *
21572199
free(name);
21582200
return 1;
21592201
}
2160-
igraph_vector_bool_init(result, n);
2202+
if (igraph_vector_bool_init(result, 0)) {
2203+
igraphmodule_handle_igraph_error();
2204+
free(name);
2205+
free(result);
2206+
return 1;
2207+
}
2208+
if (igraph_vector_bool_reserve(result, n)) {
2209+
igraph_vector_bool_destroy(result);
2210+
igraphmodule_handle_igraph_error();
2211+
free(name);
2212+
free(result);
2213+
return 1;
2214+
}
21612215
if (attr_type == ATTRIBUTE_TYPE_VERTEX) {
21622216
if (igraphmodule_i_get_boolean_vertex_attr(&self->g, name,
21632217
igraph_vss_all(), result)) {
@@ -2193,12 +2247,17 @@ int igraphmodule_attrib_to_vector_bool_t(PyObject *o, igraphmodule_GraphObject *
21932247

21942248
n = igraph_vector_size(dummy);
21952249
result = (igraph_vector_bool_t*)calloc(1, sizeof(igraph_vector_bool_t));
2196-
igraph_vector_bool_init(result, n);
21972250
if (result == 0) {
21982251
igraph_vector_destroy(dummy); free(dummy);
21992252
PyErr_NoMemory();
22002253
return 1;
22012254
}
2255+
if (igraph_vector_bool_init(result, n)) {
2256+
igraphmodule_handle_igraph_error();
2257+
igraph_vector_destroy(dummy); free(dummy);
2258+
igraph_vector_bool_destroy(result); free(result);
2259+
return 1;
2260+
}
22022261
for (i = 0; i < n; i++) {
22032262
VECTOR(*result)[i] = (VECTOR(*dummy)[i] != 0 &&
22042263
VECTOR(*dummy)[i] == VECTOR(*dummy)[i]);

src/_igraph/convert.h

+2
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,9 @@ int igraphmodule_PyObject_to_fvs_algorithm_t(PyObject *o, igraph_fvs_algorithm_t
7676
int igraphmodule_PyObject_to_get_adjacency_t(PyObject *o, igraph_get_adjacency_t *result);
7777
int igraphmodule_PyObject_to_laplacian_normalization_t(PyObject *o, igraph_laplacian_normalization_t *result);
7878
int igraphmodule_PyObject_to_layout_grid_t(PyObject *o, igraph_layout_grid_t *result);
79+
int igraphmodule_PyObject_to_lpa_variant_t(PyObject *o, igraph_lpa_variant_t *result);
7980
int igraphmodule_PyObject_to_loops_t(PyObject *o, igraph_loops_t *result);
81+
int igraphmodule_PyObject_to_mst_algorithm_t(PyObject *o, igraph_mst_algorithm_t *result);
8082
int igraphmodule_PyObject_to_neimode_t(PyObject *o, igraph_neimode_t *result);
8183
int igraphmodule_PyObject_to_pagerank_algo_t(PyObject *o, igraph_pagerank_algo_t *result);
8284
int igraphmodule_PyObject_to_edge_type_sw_t(PyObject *o, igraph_edge_type_sw_t *result);

0 commit comments

Comments
 (0)