{"id":13688717,"url":"https://github.com/vtraag/leidenalg","last_synced_at":"2025-05-14T08:05:19.978Z","repository":{"id":40606705,"uuid":"146722095","full_name":"vtraag/leidenalg","owner":"vtraag","description":"Implementation of the Leiden algorithm for various quality functions to be used with igraph in Python.","archived":false,"fork":false,"pushed_at":"2024-10-14T07:10:00.000Z","size":2938,"stargazers_count":648,"open_issues_count":17,"forks_count":83,"subscribers_count":12,"default_branch":"main","last_synced_at":"2025-04-11T02:51:42.717Z","etag":null,"topics":["clustering-algorithm","community-detection"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/vtraag.png","metadata":{"files":{"readme":"README.rst","changelog":"CHANGELOG","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-08-30T08:47:51.000Z","updated_at":"2025-04-06T03:25:31.000Z","dependencies_parsed_at":"2024-05-28T12:55:26.887Z","dependency_job_id":"c8c4aafa-8936-41bc-a9b6-b8dc9c103da6","html_url":"https://github.com/vtraag/leidenalg","commit_stats":{"total_commits":661,"total_committers":9,"mean_commits":73.44444444444444,"dds":"0.10590015128593044","last_synced_commit":"c2851d9fb10cfcdb6841cfeb419846d1aa0e4f35"},"previous_names":[],"tags_count":41,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vtraag%2Fleidenalg","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vtraag%2Fleidenalg/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vtraag%2Fleidenalg/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vtraag%2Fleidenalg/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vtraag","download_url":"https://codeload.github.com/vtraag/leidenalg/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254101588,"owners_count":22014907,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["clustering-algorithm","community-detection"],"created_at":"2024-08-02T15:01:20.883Z","updated_at":"2025-05-14T08:05:19.930Z","avatar_url":"https://github.com/vtraag.png","language":"Python","funding_links":[],"categories":["Python","其他_生物医药","Cyclic Patterns"],"sub_categories":["网络服务_其他"],"readme":"leidenalg\n==============\n\nThis package implements the Leiden algorithm in ``C++`` and exposes it to\n``python``.  It relies on ``(python-)igraph`` for it to function. Besides the\nrelative flexibility of the implementation, it also scales well, and can be run\non graphs of millions of nodes (as long as they can fit in memory). The core\nfunction is ``find_partition`` which finds the optimal partition using the\nLeiden algorithm [1]_, which is an extension of the Louvain algorithm [2]_ for a\nnumber of different methods. The methods currently implemented are (1)\nmodularity [3]_, (2) Reichardt and Bornholdt's model using the configuration\nnull model and the Erdös-Rényi null model [4]_, (3) the Constant Potts model\n(CPM) [5]_, (4) Significance [6]_, and finally (5) Surprise [7]_. In addition,\nit supports multiplex partition optimisation allowing community detection on for\nexample negative links [8]_ or multiple time slices [9]_. There is the\npossibility of only partially optimising a partition, so that some community\nassignments remain fixed [10]_. It also provides some support for community\ndetection on bipartite graphs. See the `documentation\n\u003chttp://leidenalg.readthedocs.io/en/latest/\u003e`_ for more information.\n\n\n.. image:: https://readthedocs.org/projects/leidenalg/badge\n                :target: http://leidenalg.readthedocs.io/en/latest/\n                :alt: Leiden documentation status\n\n.. image:: https://github.com/vtraag/leidenalg/actions/workflows/build.yml/badge.svg?branch=master\n                :target: https://github.com/vtraag/leidenalg/actions/workflows/build.yml\n                :alt: Leiden build status (GitHub Actions)\n\n.. image:: https://zenodo.org/badge/146722095.svg\n                :target: https://zenodo.org/badge/latestdoi/146722095\n                :alt: DOI\n\n.. image:: https://anaconda.org/conda-forge/leidenalg/badges/version.svg\n                :target: https://anaconda.org/conda-forge/leidenalg\n                :alt: Anaconda (conda-forge)\n\nInstallation\n------------\n\nIn short: ``pip install leidenalg``. All major platforms are supported on\nPython\u003e=3.6, earlier versions of Python are no longer supported. Alternatively,\nyou can install from Anaconda (channel ``conda-forge``).\n\nFor Unix like systems it is possible to install from source. For Windows this is\nmore complicated, and you are recommended to use the binary wheels. This Python\ninterface depends on the C++ package ``libleidenalg`` which in turn depends on\n``igraph``. You will need to build these packages yourself before you are able\nto build this Python interface.\n\nMake sure you have all necessary tools for compilation. In Ubuntu this can be\ninstalled using ``sudo apt-get install build-essential autoconf automake flex\nbison``, please refer to the documentation for your specific system.  Make sure\nthat not only ``gcc`` is installed, but also ``g++``, as the ``leidenalg``\npackage is programmed in ``C++``. Note that there are build scripts included in\nthe ``scripts/`` directory. These are also used to build the binary wheels.\n\n1. Compile (and install) the C core of ``igraph`` (version \u003e= 0.10). You can use\n   the file ``build_igraph.sh`` (on Unix-like systems) or ``build_igraph.bat``\n   (on Windows) in the ``scripts/`` directory to do this. For more details, see\n   https://igraph.org/c/doc/igraph-Installation.html.\n2. Compile (and install) the C core of ``libleidenalg`` (version \u003e= 0.10). You\n   can use the file ``build_libleidenalg.sh`` (on Unix-like systems) or\n   ``build_libleidenalg.bat`` (on Windows) in the ``scripts/`` directory to do\n   this. For more details, see https://github.com/vtraag/libleidenalg.\n3. Build the Python interface using ``python setup.py build`` and ``python\n   setup.py install``, or use ``pip install .``\n\nYou can check if all went well by running a variety of tests using ``python -m\nunittest``.\n\nTroubleshooting\n---------------\n\nIn case of any problems, best to start over with a clean environment. Make sure\nyou remove the ``igraph`` and ``leidenalg`` package completely. Then, do a\ncomplete reinstall starting from ``pip install leidenalg``. In case you\ninstalled from source, and built the C libraries of ``igraph`` and\n``libleidenalg`` yourself, remove them completely and rebuild and reinstall\nthem.\n\nUsage\n-----\n\nThis is the Python interface for the C++ package ``libleidenalg``. There are no\nplans at the moment for developing an R interface to the package. However, there\nhave been various efforts to port the package to R. These typically do not offer\nall available functionality or have some other limitations, but nonetheless may\nbe very useful. The available ports are:\n\n- https://github.com/cole-trapnell-lab/leidenbase\n- https://github.com/TomKellyGenetics/leiden\n- https://github.com/kharchenkolab/leidenAlg\n\nPlease refer to the documentation for more details\non function calls and parameters.\n\nThis implementation is made for flexibility, but ``igraph`` nowadays also\nincludes an implementation of the Leiden algorithm internally. That\nimplementation is less flexible: the implementation only works on undirected\ngraphs, and only CPM and modularity are supported. It is likely to be\nsubstantially faster though.\n\nJust to get you started, below the essential parts.\nTo start, make sure to import the packages:\n\n\u003e\u003e\u003e import leidenalg\n\u003e\u003e\u003e import igraph as ig\n\nWe'll create a random graph for testing purposes:\n\n\u003e\u003e\u003e G = ig.Graph.Erdos_Renyi(100, 0.1);\n\nFor simply finding a partition use:\n\n\u003e\u003e\u003e part = leidenalg.find_partition(G, leidenalg.ModularityVertexPartition);\n\nContribute\n----------\n\nSource code: https://github.com/vtraag/leidenalg\n\nIssue tracking: https://github.com/vtraag/leidenalg/issues\n\nSee the documentation on `Implementation` for more details on how to\ncontribute new methods.\n\nReferences\n----------\n\nPlease cite the references appropriately in case they are used.\n\n.. [1] Traag, V.A., Waltman. L., Van Eck, N.-J. (2018). From Louvain to\n       Leiden: guaranteeing well-connected communities. Scientific reports, 9(1), 5233.\n       `10.1038/s41598-019-41695-z \u003chttp://dx.doi.org/10.1038/s41598-019-41695-z\u003e`_\n\n.. [2] Blondel, V. D., Guillaume, J.-L., Lambiotte, R., \u0026 Lefebvre, E. (2008).\n       Fast unfolding of communities in large networks. Journal of Statistical\n       Mechanics: Theory and Experiment, 10008(10), 6.\n       `10.1088/1742-5468/2008/10/P10008 \u003chttp://doi.org/10.1088/1742-5468/2008/10/P10008\u003e`_\n\n.. [3] Newman, M. E. J., \u0026 Girvan, M. (2004). Finding and evaluating community\n       structure in networks. Physical Review E, 69(2), 026113.\n       `10.1103/PhysRevE.69.026113 \u003chttp://doi.org/10.1103/PhysRevE.69.026113\u003e`_\n\n.. [4] Reichardt, J., \u0026 Bornholdt, S. (2006). Statistical mechanics of\n       community detection. Physical Review E, 74(1), 016110.\n       `10.1103/PhysRevE.74.016110 \u003chttp://doi.org/10.1103/PhysRevE.74.016110\u003e`_\n\n.. [5] Traag, V. A., Van Dooren, P., \u0026 Nesterov, Y. (2011). Narrow scope for\n       resolution-limit-free community detection. Physical Review E, 84(1),\n       016114.  `10.1103/PhysRevE.84.016114\n       \u003chttp://doi.org/10.1103/PhysRevE.84.016114\u003e`_\n\n.. [6] Traag, V. A., Krings, G., \u0026 Van Dooren, P. (2013). Significant scales in\n       community structure. Scientific Reports, 3, 2930.  `10.1038/srep02930\n       \u003chttp://doi.org/10.1038/srep02930\u003e`_\n\n.. [7] Traag, V. A., Aldecoa, R., \u0026 Delvenne, J.-C. (2015). Detecting\n       communities using asymptotical surprise. Physical Review E, 92(2),\n       022816.  `10.1103/PhysRevE.92.022816\n       \u003chttp://doi.org/10.1103/PhysRevE.92.022816\u003e`_\n\n.. [8] Traag, V. A., \u0026 Bruggeman, J. (2009). Community detection in networks\n       with positive and negative links. Physical Review E, 80(3), 036115.\n       `10.1103/PhysRevE.80.036115\n       \u003chttp://doi.org/10.1103/PhysRevE.80.036115\u003e`_\n\n.. [9] Mucha, P. J., Richardson, T., Macon, K., Porter, M. A., \u0026 Onnela, J.-P.\n       (2010). Community structure in time-dependent, multiscale, and multiplex\n       networks. Science, 328(5980), 876–8. `10.1126/science.1184819\n       \u003chttp://doi.org/10.1126/science.1184819\u003e`_\n\n.. [10] Zanini, F., Berghuis, B. A., Jones, R. C., Robilant, B. N. di,\n        Nong, R. Y., Norton, J., Clarke, Michael F., Quake, S. R. (2019).\n        northstar: leveraging cell atlases to identify healthy and neoplastic\n        cells in transcriptomes from human tumors. BioRxiv, 820928.\n        `10.1101/820928 \u003chttps://doi.org/10.1101/820928\u003e`_\n\nLicence\n-------\n\nCopyright (C) 2020 V.A. Traag\n\nThis program is free software: you can redistribute it and/or modify it under\nthe terms of the GNU General Public License as published by the Free Software\nFoundation, either version 3 of the License, or (at your option) any later\nversion.\n\nThis program is distributed in the hope that it will be useful, but WITHOUT ANY\nWARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A\nPARTICULAR PURPOSE.  See the GNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License along with\nthis program. If not, see http://www.gnu.org/licenses/.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvtraag%2Fleidenalg","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvtraag%2Fleidenalg","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvtraag%2Fleidenalg/lists"}