Skip to content

Commit

Permalink
fix: remove loops=... argument for is_bigraphical(), fixes #730
Browse files Browse the repository at this point in the history
  • Loading branch information
ntamas committed Nov 2, 2023
1 parent ab976c5 commit 68579a6
Showing 1 changed file with 19 additions and 12 deletions.
31 changes: 19 additions & 12 deletions src/_igraph/igraphmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -536,21 +536,29 @@ static PyObject* igraphmodule_i_is_graphical_or_bigraphical(
PyObject *self, PyObject *args, PyObject *kwds, igraph_bool_t is_bigraphical
) {
static char* kwlist_graphical[] = { "out_deg", "in_deg", "loops", "multiple", NULL };
static char* kwlist_bigraphical[] = { "degrees1", "degrees2", "loops", "multiple", NULL };
static char* kwlist_bigraphical[] = { "degrees1", "degrees2", "multiple", NULL };
PyObject *out_deg_o = 0, *in_deg_o = 0;
PyObject *loops = Py_False, *multiple = Py_False;
igraph_vector_int_t out_deg, in_deg;
igraph_bool_t is_directed, result;
int allowed_edge_types;
igraph_error_t retval;

if (!PyArg_ParseTupleAndKeywords(
args, kwds,
is_bigraphical ? "OO|OO" : "O|OOO",
is_bigraphical ? kwlist_bigraphical : kwlist_graphical,
&out_deg_o, &in_deg_o, &loops, &multiple
))
return NULL;
if (is_bigraphical) {
if (!PyArg_ParseTupleAndKeywords(
args, kwds, "OO|O", kwlist_bigraphical,
&out_deg_o, &in_deg_o, &multiple
)) {
return NULL;
}
} else {
if (!PyArg_ParseTupleAndKeywords(
args, kwds, "O|OOO", kwlist_graphical,
&out_deg_o, &in_deg_o, &loops, &multiple
)) {
return NULL;
}
}

is_directed = (in_deg_o != 0 && in_deg_o != Py_None) || is_bigraphical;

Expand Down Expand Up @@ -820,17 +828,16 @@ static PyMethodDef igraphmodule_methods[] =
},
{"is_bigraphical", (PyCFunction)igraphmodule_is_bigraphical,
METH_VARARGS | METH_KEYWORDS,
"is_bigraphical(degrees1, degrees2, loops=False, multiple=False)\n--\n\n"
"is_bigraphical(degrees1, degrees2, multiple=False)\n--\n\n"
"Returns whether two sequences of integers can be the degree sequences of a\n"
"bipartite graph.\n\n"
"The bipartite graph may or may not have multiple and loop edges, depending\n"
"The bipartite graph may or may not have multiple edges, depending\n"
"on the allowed edge types in the remaining arguments.\n\n"
"@param degrees1: the list of degrees in the first partition.\n"
"@param degrees2: the list of degrees in the second partition.\n"
"@param loops: whether loop edges are allowed.\n"
"@param multiple: whether multiple edges are allowed.\n"
"@return: C{True} if there exists some bipartite graph that can realize the\n"
" given degree sequences with the given edge types, C{False} otherwise.\n"
" given degree sequences with or without multiple edges, C{False} otherwise.\n"
},
{"is_graphical", (PyCFunction)igraphmodule_is_graphical,
METH_VARARGS | METH_KEYWORDS,
Expand Down

0 comments on commit 68579a6

Please sign in to comment.