@@ -13748,6 +13748,38 @@ PyObject *igraphmodule_Graph_community_leiden(igraphmodule_GraphObject *self,
1374813748 return error ? NULL : Py_BuildValue("Nd", res, (double) quality);
1374913749}
1375013750
13751+ /**
13752+ * Fluid communities
13753+ */
13754+ PyObject *igraphmodule_Graph_community_fluid_communities(igraphmodule_GraphObject *self,
13755+ PyObject *args, PyObject *kwds) {
13756+ static char *kwlist[] = {"no_of_communities", NULL};
13757+ Py_ssize_t no_of_communities;
13758+ igraph_vector_int_t membership;
13759+ PyObject *result;
13760+
13761+ // Parse the Python integer argument
13762+ if (!PyArg_ParseTupleAndKeywords(args, kwds, "n", kwlist, &no_of_communities)) {
13763+ return NULL;
13764+ }
13765+
13766+ if (igraph_vector_int_init(&membership, 0)) {
13767+ igraphmodule_handle_igraph_error();
13768+ return NULL;
13769+ }
13770+
13771+ if (igraph_community_fluid_communities(&self->g, no_of_communities, &membership)) {
13772+ igraphmodule_handle_igraph_error();
13773+ igraph_vector_int_destroy(&membership);
13774+ return NULL;
13775+ }
13776+
13777+ result = igraphmodule_vector_int_t_to_PyList(&membership);
13778+ igraph_vector_int_destroy(&membership);
13779+
13780+ return result;
13781+ }
13782+
1375113783/**********************************************************************
1375213784 * Random walks *
1375313785 **********************************************************************/
@@ -13895,42 +13927,6 @@ PyObject *igraphmodule_Graph_random_walk(igraphmodule_GraphObject * self,
1389513927 }
1389613928}
1389713929
13898- /**********************************************************************
13899- * Other methods *
13900- **********************************************************************/
13901-
13902- /**
13903- * Fluid communities
13904- */
13905- PyObject *igraphmodule_Graph_community_fluid_communities(igraphmodule_GraphObject *self,
13906- PyObject *args, PyObject *kwds) {
13907- static char *kwlist[] = {"no_of_communities", NULL};
13908- Py_ssize_t no_of_communities;
13909- igraph_vector_int_t membership;
13910- PyObject *result;
13911-
13912- // Parse the Python integer argument
13913- if (!PyArg_ParseTupleAndKeywords(args, kwds, "n", kwlist, &no_of_communities)) {
13914- return NULL;
13915- }
13916-
13917- if (igraph_vector_int_init(&membership, 0)) {
13918- igraphmodule_handle_igraph_error();
13919- return NULL;
13920- }
13921-
13922- if (igraph_community_fluid_communities(&self->g, no_of_communities, &membership)) {
13923- igraphmodule_handle_igraph_error();
13924- igraph_vector_int_destroy(&membership);
13925- return NULL;
13926- }
13927-
13928- result = igraphmodule_vector_int_t_to_PyList(&membership);
13929- igraph_vector_int_destroy(&membership);
13930-
13931- return result;
13932- }
13933-
1393413930/**********************************************************************
1393513931 * Special internal methods that you won't need to mess around with *
1393613932 **********************************************************************/
@@ -18435,28 +18431,25 @@ struct PyMethodDef igraphmodule_Graph_methods[] = {
1843518431 "\n"
1843618432 "@see: modularity()\n"
1843718433 },
18438- {"community_fluid_communities",
18439- (PyCFunction) igraphmodule_Graph_community_fluid_communities,
18440- METH_VARARGS | METH_KEYWORDS,
18441- "community_fluid_communities(no_of_communities)\n--\n\n"
18442- "Community detection based on fluids interacting on the graph.\n\n"
18443- "The algorithm is based on the simple idea of several fluids interacting\n"
18444- "in a non-homogeneous environment (the graph topology), expanding and\n"
18445- "contracting based on their interaction and density. Weighted graphs are\n"
18446- "not supported.\n\n"
18447- "This function implements the community detection method described in:\n"
18448- "Parés F, Gasulla DG, et. al. (2018) Fluid Communities: A Competitive,\n"
18449- "Scalable and Diverse Community Detection Algorithm. In: Complex Networks\n"
18450- "& Their Applications VI: Proceedings of Complex Networks 2017 (The Sixth\n"
18451- "International Conference on Complex Networks and Their Applications),\n"
18452- "Springer, vol 689, p 229. https://doi.org/10.1007/978-3-319-72150-7_19\n\n"
18453- "@param no_of_communities: The number of communities to be found. Must be\n"
18454- " greater than 0 and fewer than number of vertices in the graph.\n"
18455- "@return: a list with the community membership of each vertex.\n"
18456- "@note: The graph must be simple and connected. Edge directions will be\n"
18457- " ignored if the graph is directed.\n"
18458- "@note: Time complexity: O(|E|)\n"
18459- },
18434+ {"community_fluid_communities",(PyCFunction) igraphmodule_Graph_community_fluid_communities,METH_VARARGS | METH_KEYWORDS,
18435+ "community_fluid_communities(no_of_communities)\n--\n\n"
18436+ "Community detection based on fluids interacting on the graph.\n\n"
18437+ "The algorithm is based on the simple idea of several fluids interacting\n"
18438+ "in a non-homogeneous environment (the graph topology), expanding and\n"
18439+ "contracting based on their interaction and density. Weighted graphs are\n"
18440+ "not supported.\n\n"
18441+ "B{Reference}\n\n"
18442+ " - Parés F, Gasulla DG, et. al. (2018) Fluid Communities: A Competitive,\n"
18443+ " Scalable and Diverse Community Detection Algorithm. In: Complex Networks\n"
18444+ " & Their Applications VI: Proceedings of Complex Networks 2017 (The Sixth\n"
18445+ " International Conference on Complex Networks and Their Applications),\n"
18446+ " Springer, vol 689, p 229. https://doi.org/10.1007/978-3-319-72150-7_19\n\n"
18447+ "@param no_of_communities: The number of communities to be found. Must be\n"
18448+ " greater than 0 and fewer than number of vertices in the graph.\n"
18449+ "@return: a list with the community membership of each vertex.\n"
18450+ "@note: The graph must be simple and connected. Edge directions will be\n"
18451+ " ignored if the graph is directed.\n"
18452+ "@note: Time complexity: O(|E|)\n",
1846018453 {"community_infomap",
1846118454 (PyCFunction) igraphmodule_Graph_community_infomap,
1846218455 METH_VARARGS | METH_KEYWORDS,
@@ -18465,7 +18458,7 @@ struct PyMethodDef igraphmodule_Graph_methods[] = {
1846518458 "method of Martin Rosvall and Carl T. Bergstrom.\n\n"
1846618459 "See U{https://www.mapequation.org} for a visualization of the algorithm\n"
1846718460 "or one of the references provided below.\n"
18468- "B{References}\n "
18461+ "B{Reference}: "
1846918462 " - M. Rosvall and C. T. Bergstrom: I{Maps of information flow reveal\n"
1847018463 " community structure in complex networks}. PNAS 105, 1118 (2008).\n"
1847118464 " U{https://arxiv.org/abs/0707.0609}\n"
0 commit comments