skillfed

leidenalg

Leiden is a general algorithm for methods of community detection in large networks.

leidenalg v0.12.0 771.8K downloads/30d#5,100 on PyPI
Copyleft license GPL-3.0-or-later Active released

What it is and what it does

leidenalg is a Python interface to a C++ implementation of the Leiden algorithm, a community detection method for partitioning large networks into cohesive groups. It extends the Louvain algorithm with improvements to guarantee well-connected communities and supports multiple optimization objectives: modularity, Reichardt-Bornholdt models, Constant Potts Model (CPM), Significance, and Surprise. The package can handle graphs with millions of nodes (memory-permitting) and includes support for multiplex networks (e.g., temporal or multi-layer graphs) and bipartite graphs, with the option to fix some community assignments during optimization.

The package depends on igraph for graph representation and manipulation. It is designed for research and scientific computing, where flexibility in community detection methods is valued. Prebuilt wheels are available for Python 3.9+ on Windows, macOS, and Linux, though source builds require C++ compilation tools and igraph's C core library.

Use it for:

  • Detect communities in social networks or collaboration graphs to identify groups of closely connected entities.
  • Analyze temporal networks by applying Leiden to multiple time slices to track community evolution.
  • Optimize modularity or other quality metrics on large graphs to find the best partition into communities.
  • Perform community detection on multiplex networks with positive and negative links or multiple relationship types.
  • Identify clusters in bipartite graphs such as author-paper or user-item networks.

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

Implements the Leiden community detection algorithm for graphs, exposing a C++ implementation to Python via igraph for partitioning networks into communities using multiple optimization methods.

Yes, if you need flexible community detection on large graphs and can accept GPL-3.0-or-later licensing. The active maintenance, prebuilt wheels for modern Python, and lack of known vulnerabilities make it reliable. Medium install friction is manageable via wheels on major platforms. Not suitable for proprietary closed-source applications without license negotiation.

Install

leidenalg on PyPI

pip

pip install leidenalg

uv

uv add leidenalg

poetry

poetry add leidenalg

Installing leidenalg

Before you install

Medium install friction due to compiled C++ dependencies. Prebuilt wheels are available for modern Python versions (3.9+) on major platforms, reducing friction significantly. Maintenance is active with a recent release.

License in practice

GPL-3.0-or-later copyleft license means any derivative work or linked application must also be open-source under compatible terms. Suitable for research and open-source projects; commercial use requires careful licensing review.

Quickstart

pip install leidenalg

import leidenalg
import igraph as ig

G = ig.Graph.Erdos_Renyi(100, 0.1)
part = leidenalg.find_partition(G, leidenalg.ModularityVertexPartition)

Requires igraph as a runtime dependency. On Windows, binary wheels are recommended; on Unix-like systems, C++ compilation tools and igraph C core (version >= 1.0.0) may be needed if building from source.

Verify before relying

  • Whether the package supports directed graphs or only undirected (description mentions igraph's internal implementation is undirected-only, but leidenalg's flexibility is unclear).
  • Performance characteristics and scalability limits for graphs with millions of nodes on typical hardware.

Package facts

License GPL-3.0-or-later (copyleft)
Python support supports the current Python release (>=3.7)
Install friction medium — platform-specific wheel
Runtime dependencies 1 — igraph
Maintenance actively maintained — 82 days since the last release
First released
Downloads 771,839/month — #5,100 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: leidenalg-0.12.0-cp38-abi3-macosx_10_9_x86_64.whl; leidenalg-0.12.0-cp38-abi3-macosx_11_0_arm64.whl; leidenalg-0.12.0-cp38-abi3-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl; leidenalg-0.12.0-cp38-abi3-manylinux_2_26_i686.manylinux_2_28_i686.whl; leidenalg-0.12.0-cp38-abi3-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl; leidenalg-0.12.0-cp38-abi3-musllinux_1_2_i686.whl; leidenalg-0.12.0-cp38-abi3-musllinux_1_2_x86_64.whl; leidenalg-0.12.0-cp38-abi3-win32.whl; leidenalg-0.12.0-cp38-abi3-win_amd64.whl; leidenalg-0.12.0-pp311-pypy311_pp73-macosx_10_15_x86_64.whl; leidenalg-0.12.0-pp311-pypy311_pp73-macosx_11_0_arm64.whl; leidenalg-0.12.0-pp311-pypy311_pp73-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl; leidenalg-0.12.0-pp311-pypy311_pp73-manylinux_2_26_i686.manylinux_2_28_i686.whl; leidenalg-0.12.0-pp311-pypy311_pp73-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl

Keywords: graph, network, community detection, clustering

Development Status :: 4 - BetaEnvironment :: ConsoleIntended Audience :: DevelopersIntended Audience :: End Users/DesktopIntended Audience :: Science/ResearchOperating System :: MacOS :: MacOS XOperating System :: Microsoft :: WindowsOperating System :: POSIXProgramming Language :: C++Programming Language :: PythonTopic :: Scientific/Engineering :: Information AnalysisTopic :: Scientific/Engineering :: MathematicsTopic :: Sociology

Tags

community detection algorithmgraph clustering leidennetwork partition optimizationmodularity optimizationgraph community structurenetwork analysis clusteringleiden algorithm python
graph-algorithmsnetwork-analysiscommunity-detection

More Information Analysis packages

Further reading