Skip to content

Commit 2f87237

Browse files
committed
reformat for consistency
1 parent 1d7e7ff commit 2f87237

File tree

1 file changed

+90
-89
lines changed

1 file changed

+90
-89
lines changed

src/_igraph/graphobject.c

Lines changed: 90 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -13780,117 +13780,118 @@ PyObject *igraphmodule_Graph_community_fluid_communities(igraphmodule_GraphObjec
1378013780
*/
1378113781
PyObject *igraphmodule_Graph_community_voronoi(igraphmodule_GraphObject *self,
1378213782
PyObject *args, PyObject *kwds) {
13783-
static char *kwlist[] = {"lengths", "weights", "mode", "radius", NULL};
13784-
PyObject *lengths_o = Py_None, *weights_o = Py_None;
13785-
PyObject *mode_o = Py_None;
13786-
PyObject *radius_o = Py_None;
13787-
igraph_vector_t *lengths_v = NULL;
13788-
igraph_vector_t *weights_v = NULL;
13789-
igraph_vector_int_t membership_v, generators_v;
13790-
igraph_neimode_t mode = IGRAPH_OUT;
13791-
igraph_real_t radius = -1.0; /* negative means auto-optimize */
13792-
igraph_real_t modularity = IGRAPH_NAN;
13793-
PyObject *membership_o, *generators_o, *result_o;
13794-
13795-
if (!PyArg_ParseTupleAndKeywords(args, kwds, "|OOOO", kwlist,
13796-
&lengths_o, &weights_o, &mode_o, &radius_o))
13797-
return NULL;
13783+
static char *kwlist[] = {"lengths", "weights", "mode", "radius", NULL};
13784+
PyObject *lengths_o = Py_None, *weights_o = Py_None;
13785+
PyObject *mode_o = Py_None;
13786+
PyObject *radius_o = Py_None;
13787+
igraph_vector_t *lengths_v = NULL;
13788+
igraph_vector_t *weights_v = NULL;
13789+
igraph_vector_int_t membership_v, generators_v;
13790+
igraph_neimode_t mode = IGRAPH_OUT;
13791+
igraph_real_t radius = -1.0; /* negative means auto-optimize */
13792+
igraph_real_t modularity = IGRAPH_NAN;
13793+
PyObject *membership_o, *generators_o, *result_o;
1379813794

13799-
/* Handle mode parameter */
13800-
if (igraphmodule_PyObject_to_neimode_t(mode_o, &mode))
13801-
return NULL;
13795+
if (!PyArg_ParseTupleAndKeywords(args, kwds, "|OOOO", kwlist,
13796+
&lengths_o, &weights_o, &mode_o, &radius_o)) {
13797+
return NULL;
13798+
}
1380213799

13803-
/* Handle radius parameter */
13804-
if (radius_o != Py_None) {
13805-
if (igraphmodule_PyObject_to_real_t(radius_o, &radius))
13806-
return NULL;
13807-
}
13800+
/* Handle mode parameter */
13801+
if (igraphmodule_PyObject_to_neimode_t(mode_o, &mode)) {
13802+
return NULL;
13803+
}
1380813804

13809-
/* Handle lengths parameter */
13810-
if (igraphmodule_attrib_to_vector_t(lengths_o, self, &lengths_v, ATTRIBUTE_TYPE_EDGE)) {
13811-
return NULL;
13812-
}
13805+
/* Handle radius parameter */
13806+
if (radius_o != Py_None) {
13807+
if (igraphmodule_PyObject_to_real_t(radius_o, &radius)) {
13808+
return NULL;
13809+
}
13810+
}
1381313811

13814-
/* Handle weights parameter */
13815-
if (igraphmodule_attrib_to_vector_t(weights_o, self, &weights_v, ATTRIBUTE_TYPE_EDGE)) {
13816-
if (lengths_v != NULL) {
13817-
igraph_vector_destroy(lengths_v); free(lengths_v);
13818-
}
13819-
return NULL;
13820-
}
13812+
/* Handle lengths parameter */
13813+
if (igraphmodule_attrib_to_vector_t(lengths_o, self, &lengths_v, ATTRIBUTE_TYPE_EDGE)) {
13814+
return NULL;
13815+
}
1382113816

13822-
/* Initialize result vectors */
13823-
if (igraph_vector_int_init(&membership_v, 0)) {
13824-
if (lengths_v != NULL) {
13825-
igraph_vector_destroy(lengths_v); free(lengths_v);
13826-
}
13827-
if (weights_v != NULL) {
13828-
igraph_vector_destroy(weights_v); free(weights_v);
13829-
}
13830-
igraphmodule_handle_igraph_error();
13831-
return NULL;
13817+
/* Handle weights parameter */
13818+
if (igraphmodule_attrib_to_vector_t(weights_o, self, &weights_v, ATTRIBUTE_TYPE_EDGE)) {
13819+
if (lengths_v != NULL) {
13820+
igraph_vector_destroy(lengths_v); free(lengths_v);
1383213821
}
13822+
return NULL;
13823+
}
1383313824

13834-
if (igraph_vector_int_init(&generators_v, 0)) {
13835-
if (lengths_v != NULL) {
13836-
igraph_vector_destroy(lengths_v); free(lengths_v);
13837-
}
13838-
if (weights_v != NULL) {
13839-
igraph_vector_destroy(weights_v); free(weights_v);
13840-
}
13841-
igraph_vector_int_destroy(&membership_v);
13842-
igraphmodule_handle_igraph_error();
13843-
return NULL;
13825+
/* Initialize result vectors */
13826+
if (igraph_vector_int_init(&membership_v, 0)) {
13827+
if (lengths_v != NULL) {
13828+
igraph_vector_destroy(lengths_v); free(lengths_v);
1384413829
}
13845-
13846-
/* Call the C function - pass NULL for None parameters */
13847-
if (igraph_community_voronoi(&self->g, &membership_v, &generators_v,
13848-
&modularity,
13849-
lengths_v,
13850-
weights_v,
13851-
mode, radius)) {
13852-
13853-
if (lengths_v != NULL) {
13854-
igraph_vector_destroy(lengths_v); free(lengths_v);
13855-
}
13856-
if (weights_v != NULL) {
13857-
igraph_vector_destroy(weights_v); free(weights_v);
13858-
}
13859-
igraph_vector_int_destroy(&membership_v);
13860-
igraph_vector_int_destroy(&generators_v);
13861-
igraphmodule_handle_igraph_error();
13862-
return NULL;
13830+
if (weights_v != NULL) {
13831+
igraph_vector_destroy(weights_v); free(weights_v);
1386313832
}
13833+
igraphmodule_handle_igraph_error();
13834+
return NULL;
13835+
}
1386413836

13865-
/* Clean up input vectors */
13866-
13837+
if (igraph_vector_int_init(&generators_v, 0)) {
1386713838
if (lengths_v != NULL) {
1386813839
igraph_vector_destroy(lengths_v); free(lengths_v);
1386913840
}
1387013841
if (weights_v != NULL) {
1387113842
igraph_vector_destroy(weights_v); free(weights_v);
1387213843
}
13873-
13874-
/* Convert results to Python objects */
13875-
membership_o = igraphmodule_vector_int_t_to_PyList(&membership_v);
1387613844
igraph_vector_int_destroy(&membership_v);
13877-
if (!membership_o) {
13878-
igraph_vector_int_destroy(&generators_v);
13879-
return NULL;
13845+
igraphmodule_handle_igraph_error();
13846+
return NULL;
13847+
}
13848+
13849+
/* Call the C function - pass NULL for None parameters */
13850+
if (igraph_community_voronoi(&self->g, &membership_v, &generators_v,
13851+
&modularity,
13852+
lengths_v,
13853+
weights_v,
13854+
mode, radius)) {
13855+
13856+
if (lengths_v != NULL) {
13857+
igraph_vector_destroy(lengths_v); free(lengths_v);
13858+
}
13859+
if (weights_v != NULL) {
13860+
igraph_vector_destroy(weights_v); free(weights_v);
1388013861
}
13862+
igraph_vector_int_destroy(&membership_v);
13863+
igraph_vector_int_destroy(&generators_v);
13864+
igraphmodule_handle_igraph_error();
13865+
return NULL;
13866+
}
1388113867

13882-
generators_o = igraphmodule_vector_int_t_to_PyList(&generators_v);
13868+
/* Clean up input vectors */
13869+
if (lengths_v != NULL) {
13870+
igraph_vector_destroy(lengths_v); free(lengths_v);
13871+
}
13872+
if (weights_v != NULL) {
13873+
igraph_vector_destroy(weights_v); free(weights_v);
13874+
}
13875+
13876+
/* Convert results to Python objects */
13877+
membership_o = igraphmodule_vector_int_t_to_PyList(&membership_v);
13878+
igraph_vector_int_destroy(&membership_v);
13879+
if (!membership_o) {
1388313880
igraph_vector_int_destroy(&generators_v);
13884-
if (!generators_o) {
13885-
Py_DECREF(membership_o);
13886-
return NULL;
13887-
}
13881+
return NULL;
13882+
}
1388813883

13889-
/* Return tuple with membership, generators, and modularity */
13890-
result_o = Py_BuildValue("(NNd)", membership_o, generators_o, modularity);
13891-
13884+
generators_o = igraphmodule_vector_int_t_to_PyList(&generators_v);
13885+
igraph_vector_int_destroy(&generators_v);
13886+
if (!generators_o) {
13887+
Py_DECREF(membership_o);
13888+
return NULL;
13889+
}
1389213890

13893-
return result_o;
13891+
/* Return tuple with membership, generators, and modularity */
13892+
result_o = Py_BuildValue("(NNd)", membership_o, generators_o, modularity);
13893+
13894+
return result_o;
1389413895
}
1389513896

1389613897
/**********************************************************************

0 commit comments

Comments
 (0)