@@ -710,6 +710,36 @@ int igraphmodule_PyObject_to_loops_t(PyObject *o, igraph_loops_t *result) {
710
710
TRANSLATE_ENUM_WITH (loops_tt );
711
711
}
712
712
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
+
713
743
/**
714
744
* \ingroup python_interface_conversion
715
745
* \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,
1962
1992
free (name );
1963
1993
return 1 ;
1964
1994
}
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
+ }
1966
2008
if (attr_type == ATTRIBUTE_TYPE_VERTEX ) {
1967
2009
if (igraphmodule_i_get_numeric_vertex_attr (& self -> g , name ,
1968
2010
igraph_vss_all (), result )) {
@@ -2157,7 +2199,19 @@ int igraphmodule_attrib_to_vector_bool_t(PyObject *o, igraphmodule_GraphObject *
2157
2199
free (name );
2158
2200
return 1 ;
2159
2201
}
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
+ }
2161
2215
if (attr_type == ATTRIBUTE_TYPE_VERTEX ) {
2162
2216
if (igraphmodule_i_get_boolean_vertex_attr (& self -> g , name ,
2163
2217
igraph_vss_all (), result )) {
@@ -2193,12 +2247,17 @@ int igraphmodule_attrib_to_vector_bool_t(PyObject *o, igraphmodule_GraphObject *
2193
2247
2194
2248
n = igraph_vector_size (dummy );
2195
2249
result = (igraph_vector_bool_t * )calloc (1 , sizeof (igraph_vector_bool_t ));
2196
- igraph_vector_bool_init (result , n );
2197
2250
if (result == 0 ) {
2198
2251
igraph_vector_destroy (dummy ); free (dummy );
2199
2252
PyErr_NoMemory ();
2200
2253
return 1 ;
2201
2254
}
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
+ }
2202
2261
for (i = 0 ; i < n ; i ++ ) {
2203
2262
VECTOR (* result )[i ] = (VECTOR (* dummy )[i ] != 0 &&
2204
2263
VECTOR (* dummy )[i ] == VECTOR (* dummy )[i ]);
0 commit comments