# Python graph libraries

Python graph libraries store networks of nodes and edges and run algorithms such as shortest paths, centrality, and community detection on them. A compiled library stores the graph in native memory with integer node indices rather than as Python objects. These libraries let data scientists and AI agents analyze social networks, knowledge graphs, and dependency graphs.

## Popularity

| Library | Monthly downloads | Stars | Last release | License |
| --- | --- | --- | --- | --- |
| [NetworkX](#networkx) | 279.1M | 17.4K | Sep 2026 | BSD-3-Clause |
| [rustworkx](#rustworkx) | 7.5M | 1.8K | Jul 2026 | Apache-2.0 |
| [igraph](#igraph) | 4.3M | 1.5K | Oct 2025 | GPL-2.0 |
| [leidenalg](#leidenalg) | 1.8M | 803 | May 2026 | GPL-3.0-or-later |
| [python-louvain](#python-louvain) | 361.8K | 1.0K | Jan 2022 | BSD-3-Clause |
| [NetworKit](#networkit) | 191.7K | 886 | Nov 2026 | MIT |

Downloads: PyPI, last thirty days. Stars and releases: GitHub. Amber: no release in over a year.

[NetworkX](#networkx) has the most monthly downloads in this comparison, at 279.1M.

## Capabilities

| Library | Directed graph algorithms | Parallel edges |
| --- | --- | --- |
| [NetworkX](#networkx) | Yes | Yes |
| [rustworkx](#rustworkx) | Yes | Yes |
| [igraph](#igraph) | Yes | Yes |
| [leidenalg](#leidenalg) | Yes | Undocumented |
| [python-louvain](#python-louvain) | No | Undocumented |
| [NetworKit](#networkit) | Yes | No |

## Libraries

### NetworkX

[GitHub](https://github.com/networkx/networkx) · [PyPI](https://pypi.org/project/networkx) · [Docs](https://networkx.org/documentation/stable/tutorial.html)

Builds and analyzes graphs with Python objects as nodes.

- Downloads / mo: 279.1M
- Stars: 17.4K
- Last release: 3.7
- License: BSD-3-Clause
- Capabilities: [From the NetworkX docs](https://networkx.org/documentation/stable/tutorial.html)

**Strengths**

- **Uses meaningful node labels.** Use strings or other hashable Python objects directly as nodes.
- **Finds weighted and unweighted paths.** Use one interface for directed, undirected, and weighted shortest paths.

**Watch out for**

- **Parallel coverage depends on backend.** Unsupported nx-parallel functions fall back to NetworkX.
- **GraphML inputs must be trusted.** Only parse GraphML files from trusted sources.

```sh
pip install networkx
```

**GiulioRossetti/cdlib** (430 stars)

[GiulioRossetti/cdlib](https://github.com/GiulioRossetti/cdlib) 

```python
def girvan_newman(g_original: object, level: int) -> NodeClustering:
    """
    The Girvan–Newman algorithm detects communities by progressively removing edges from the original graph.
    The algorithm removes the "most valuable" edge, traditionally the edge with the highest betweenness centrality, at each step. As the graph breaks down into pieces, the tightly knit community structure is exposed and the result can be depicted as a dendrogram.


    **Supported Graph Types**

    ========== ======== ========
    Undirected Directed Weighted
    ========== ======== ========
    Yes        No       No
    ========== ======== ========

    :param g_original: a networkx/igraph object
    :param level: the level where to cut the dendrogram (-1 for highest modularity)
    :return: NodeClustering object

    :Example:

    >>> from cdlib import algorithms
    >>> import networkx as nx
    >>> G = nx.karate_club_graph()
    >>> com = algorithms.girvan_newman(G, level=3)

    :References:

    Girvan, Michelle, and Mark EJ Newman. `Community structure in social and biological networks. <https://www.ncbi.nlm.nih.gov/pmc/articles/PMC122977/>`_ Proceedings of the national academy of sciences 99.12 (2002): 7821-7826.
    """

    g = convert_graph_formats(g_original, nx.Graph)

    gn_hierarchy = nx.algorithms.community.girvan_newman(g)
    coms = []
    if level==-1:
        max_modularity = -float('inf')

        for current_coms in gn_hierarchy:
            mod = nx.algorithms.community.modularity(g, current_coms)
            if mod > max_modularity:
                max_modularity = mod
                coms = current_coms
    else:
        for _ in range(level):
            coms = next(gn_hierarchy)


    communities = []

    for c in coms:
        communities.append(list(c))

    return NodeClustering(
        communities, g_original, "Girvan Newman", method_parameters={"level": level}
    )

```

[cdlib/algorithms/crisp_partition.py](https://github.com/GiulioRossetti/cdlib/blob/cd3380b25633e544c4bfbba91c257fd033176fe1/cdlib/algorithms/crisp_partition.py#L165-L219) · [More projects using NetworkX →](https://dashboard.exa.ai/playground/search?q=Python%20projects%20that%20use%20networkx&filters=%7B%22type%22%3A%20%22auto%22%2C%20%22numResults%22%3A%2010%2C%20%22includeDomains%22%3A%20%5B%22github.com%22%5D%7D)

**Quickstart**

```python
import networkx as nx
G = nx.Graph()

G.add_node(1)

```

From [tutorial.html](https://networkx.org/documentation/stable/tutorial.html)

### rustworkx

[GitHub](https://github.com/Qiskit/rustworkx) · [PyPI](https://pypi.org/project/rustworkx) · [Docs](https://www.rustworkx.org/apiref/rustworkx.PyDiGraph.html)

Builds indexed graphs with arbitrary Python data on nodes and edges.

- Downloads / mo: 7.5M
- Stars: 1.8K
- Last release: 0.18.1
- License: Apache-2.0
- Capabilities: [From the rustworkx docs](https://www.rustworkx.org/apiref/rustworkx.PyDiGraph.html)

**Strengths**

- **Stores Python data on edges.** Attach arbitrary Python objects to nodes and edges.
- **Parallelizes all-pairs shortest paths.** Dijkstra all-pairs searches use a configurable thread pool.

**Watch out for**

- **Deleted node IDs get reused.** Refresh cached node references after deleting and adding nodes.

```sh
pip install rustworkx
```

**PennyLaneAI/pennylane** (3.5K stars)

[PennyLaneAI/pennylane](https://github.com/PennyLaneAI/pennylane) 

```python
def _construct_graph_from_queue(queue, all_wires):
    inds_for_objs = defaultdict(list)  # dict from wrappedobjs to all indices for the objs
    nodes_on_wires = defaultdict(list)  # wire to list of nodes
    mid_measure_nodes = {}  # MCMs to their corresponding nodes

    graph = rx.PyDiGraph(multigraph=False)

    for i, obj in enumerate(queue):
        inds_for_objs[_WrappedObj(obj)].append(i)
        obj_node = graph.add_node(i)
        if isinstance(obj, (MidMeasure, PauliMeasure)):
            mid_measure_nodes[obj] = obj_node
        for w in _get_wires(obj, all_wires):
            if w in nodes_on_wires:
                graph.add_edge(nodes_on_wires[w][-1], obj_node, "")
            nodes_on_wires[w].append(obj_node)
        if isinstance(obj, Conditional):
            for m in obj.meas_val.measurements:
                if not graph.has_edge(mid_measure_nodes[m], obj_node):
                    graph.add_edge(mid_measure_nodes[m], obj_node, "")

    return graph, inds_for_objs, nodes_on_wires

```

[pennylane/circuit_graph.py](https://github.com/PennyLaneAI/pennylane/blob/e39ecae2e0be64bb70e4c2e4ac9a41bb9c47dc8e/pennylane/circuit_graph.py#L82-L103) · [More projects using rustworkx →](https://dashboard.exa.ai/playground/search?q=Python%20projects%20that%20use%20rustworkx&filters=%7B%22type%22%3A%20%22auto%22%2C%20%22numResults%22%3A%2010%2C%20%22includeDomains%22%3A%20%5B%22github.com%22%5D%7D)

**Quickstart**

```python
import rustworkx as rx

G = rx.PyGraph()

G.add_node(1)

```

From [introduction.html](https://www.rustworkx.org/tutorial/introduction.html)

### igraph

[GitHub](https://github.com/igraph/python-igraph) · [PyPI](https://pypi.org/project/igraph) · [Docs](https://python.igraph.org/en/stable/tutorial.html)

Builds, analyzes, and exports graphs through indexed vertices.

- Downloads / mo: 4.3M
- Stars: 1.5K
- Last release: 1.0.0
- License: GPL-2.0
- Capabilities: [From the igraph docs](https://python.igraph.org/en/stable/tutorial.html)

**Strengths**

- **Includes Leiden community detection.** Find communities with the built-in Leiden algorithm.
- **Reads and writes graph files.** Exchange graphs with other tools through supported graph formats.

**Watch out for**

- **Vertex deletion changes later IDs.** Store stable labels separately when deleting vertices.

```sh
pip install igraph
```

**GiulioRossetti/cdlib** (430 stars)

[GiulioRossetti/cdlib](https://github.com/GiulioRossetti/cdlib) 

```python
def walktrap(g_original: object, weights: str = None) -> NodeClustering:
    """
    walktrap is an approach based on random walks.
    The general idea is that if you perform random walks on the graph, then the walks are more likely to stay within the same community because there are only a few edges that lead outside a given community. Walktrap runs short random walks and uses the results of these random walks to merge separate communities in a bottom-up manner.


    **Supported Graph Types**

    ========== ======== ========
    Undirected Directed Weighted
    ========== ======== ========
    Yes        No       Yes
    ========== ======== ========

    :param g_original: a networkx/igraph object
    :param weights: label used for the edge weights. Default, None.
    :return: NodeClusterint object

    :Example:

    >>> from cdlib import algorithms
    >>> import networkx as nx
    >>> G = nx.karate_club_graph()
    >>> coms = algorithms.walktrap(G)

    :References:

    Pons, Pascal, and Matthieu Latapy. `Computing communities in large networks using random walks. <http://jgaa.info/accepted/2006/PonsLatapy2006.10.2.pdf/>`_ J. Graph Algorithms Appl. 10.2 (2006): 191-218.
    """

    if ig is None:
        raise ModuleNotFoundError(
            "Optional dependency not satisfied: install igraph to use the selected feature."
        )

    g = convert_graph_formats(g_original, ig.Graph)
    coms = g.community_walktrap(weights=weights).as_clustering()
    communities = []

    for c in coms:
        communities.append([g.vs[x]["name"] for x in c])

    return NodeClustering(
        communities, g_original, "Walktrap", method_parameters={"weights": weights}
    )

```

[cdlib/algorithms/crisp_partition.py](https://github.com/GiulioRossetti/cdlib/blob/cd3380b25633e544c4bfbba91c257fd033176fe1/cdlib/algorithms/crisp_partition.py#L1225-L1269) · [More projects using igraph →](https://dashboard.exa.ai/playground/search?q=Python%20projects%20that%20use%20igraph&filters=%7B%22type%22%3A%20%22auto%22%2C%20%22numResults%22%3A%2010%2C%20%22includeDomains%22%3A%20%5B%22github.com%22%5D%7D)

**Quickstart**

```python
import igraph as ig
g = ig.Graph(n=10, edges=[[0, 1], [0, 5]])
print(g)

```

From [tutorial.html](https://python.igraph.org/en/stable/tutorial.html)

### leidenalg

[GitHub](https://github.com/vtraag/leidenalg) · [PyPI](https://pypi.org/project/leidenalg) · [Docs](https://leidenalg.readthedocs.io/en/stable/reference.html)

Detects communities in large networks with the Leiden algorithm.

- Downloads / mo: 1.8M
- Stars: 803
- Last release: 0.12.0
- License: GPL-3.0-or-later
- Capabilities: [From the leidenalg docs](https://leidenalg.readthedocs.io/en/stable/reference.html)

```sh
pip install leidenalg
```

**GiulioRossetti/cdlib** (430 stars)

[GiulioRossetti/cdlib](https://github.com/GiulioRossetti/cdlib) 

```python
def CPM_Bipartite(
    g_original: object,
    resolution_parameter_01: float,
    resolution_parameter_0: float = 0,
    resolution_parameter_1: float = 0,
    degree_as_node_size: bool = False,
    seed: int = 0,
) -> BiNodeClustering:
    """
    CPM_Bipartite is the extension of CPM to bipartite graphs


    **Supported Graph Types**

    ========== ======== ======== =========
    Undirected Directed Weighted Bipartite
    ========== ======== ======== =========
    Yes        No       No       Yes
    ========== ======== ======== =========

    :param g_original: a networkx/igraph object
    :param resolution_parameter_01: Resolution parameter for in between two classes.
    :param resolution_parameter_0: Resolution parameter for class 0.
    :param resolution_parameter_1: Resolution parameter for class 1.
    :param degree_as_node_size: If ``True`` use degree as node size instead of 1, to mimic modularity
    :param seed: the random seed to be used in CPM method to keep results/partitions replicable
    :return: BiNodeClustering object

    :Example:

    >>> from cdlib import algorithms
    >>> import networkx as nx
    >>> G = nx.algorithms.bipartite.generators.random_graph(100, 20, 0.5)
    >>> coms = algorithms.CPM_Bipartite(G, 0.5)

    :References:

    Barber, M. J. (2007). Modularity and community detection in bipartite networks. Physical Review E, 76(6), 066102. 10.1103/PhysRevE.76.066102

    .. note:: Reference implementation: https://leidenalg.readthedocs.io/en/stable/multiplex.html?highlight=bipartite#bipartite
    """
    global leidenalg
    if ig is None or leidenalg is None:
        try:
            import leidenalg
        except ModuleNotFoundError:
            raise ModuleNotFoundError(
                "Optional dependency not satisfied: install igraph and leidenalg to use the "
                "selected feature."
            )

    g = convert_graph_formats(g_original, ig.Graph)

    try:
        g.vs["name"]
    except:
        g.vs["name"] = [v.index for v in g.vs]

    seed = get_seed(seed)

    optimiser = leidenalg.Optimiser()
    leidenalg.Optimiser.set_rng_seed(self=optimiser, value=seed)

    p_01, p_0, p_1 = leidenalg.CPMVertexPartition.Bipartite(
        g,
        resolution_parameter_01=resolution_parameter_01,
        resolution_parameter_0=resolution_parameter_0,
        resolution_parameter_1=resolution_parameter_1,
        degree_as_node_size=degree_as_node_size,
    )
    optimiser.optimise_partition_multiplex([p_01, p_0, p_1], layer_weights=[1, -1, -1])

    coms = defaultdict(list)
    for n in g.vs:
        coms[p_01.membership[n.index]].append(n.index)

    return BiNodeClustering(
        list(coms.values()),
        [],
        g_original,
        "CPM_Bipartite",
        method_parameters={
            "resolution_parameter_01": resolution_parameter_01,
            "resolution_parameter_0": resolution_parameter_0,
            "resolution_parameter_1": resolution_parameter_1,
            "degree_as_node_size": degree_as_node_size,
            "seed": seed,
        },
    )

```

[cdlib/algorithms/bipartite_clustering.py](https://github.com/GiulioRossetti/cdlib/blob/cd3380b25633e544c4bfbba91c257fd033176fe1/cdlib/algorithms/bipartite_clustering.py#L111-L199) · [More projects using leidenalg →](https://dashboard.exa.ai/playground/search?q=leidenalg%20GitHub%20projects)

**Quickstart**

```python
import leidenalg
import igraph as ig

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

```

From [README.rst](https://raw.githubusercontent.com/vtraag/leidenalg/0.12.0/README.rst)

### python-louvain

[GitHub](https://github.com/taynaud/python-louvain) · [PyPI](https://pypi.org/project/python-louvain) · [Docs](https://python-louvain.readthedocs.io/en/latest/api.html)

Detects communities with the Louvain algorithm.

- Downloads / mo: 361.8K
- Stars: 1.0K
- Last release: 0.16
- License: BSD-3-Clause
- Capabilities: [From the python-louvain docs](https://python-louvain.readthedocs.io/en/latest/api.html)

```sh
pip install python-louvain
```

**benedekrozemberczki/karateclub** (2.3K stars)

[benedekrozemberczki/karateclub](https://github.com/benedekrozemberczki/karateclub) 

```python
def fit(self, graph: nx.classes.graph.Graph):
    """
    Fitting an Edge Motif clustering model.

    Arg types:
        * **graph** *(NetworkX graph)* - The graph to be clustered.
    """
    self._set_seed()
    graph = self._check_graph(graph)
    self._graph = graph
    self._calculate_motifs()
    self._extract_components()
    self._fill_blocks()
    self._partition = community.best_partition(self._graph, random_state=self.seed)

```

[karateclub/community_detection/non_overlapping/edmot.py](https://github.com/benedekrozemberczki/karateclub/blob/cb46a91df8dcbeb2570debcf6a9d0c518107a2de/karateclub/community_detection/non_overlapping/edmot.py#L78-L91) · [More projects using python-louvain →](https://dashboard.exa.ai/playground/search?q=python-louvain%20GitHub%20projects)

**Quickstart**

```python
import community as community_louvain
import networkx as nx
G = nx.erdos_renyi_graph(100, 0.01)
partion = community_louvain.best_partition(G)

```

From [api.html](https://python-louvain.readthedocs.io/en/latest/api.html)

### NetworKit

[GitHub](https://github.com/networkit/networkit) · [PyPI](https://pypi.org/project/networkit) · [Docs](https://networkit.github.io/dev-docs/notebooks/User-Guide.html)

Analyzes networks with parallel graph algorithms exposed to Python.

- Downloads / mo: 191.7K
- Stars: 886
- Last release: 11.3
- License: MIT
- Capabilities: [From the NetworKit docs](https://networkit.github.io/dev-docs/notebooks/User-Guide.html)

**Strengths**

- **Uses multiple CPU cores.** Run parallel graph algorithms through the Python API.
- **Generates clustered test graphs.** Create clustered random graphs and detect their communities.

**Watch out for**

- **Node labels need integer mappings.** Map string identifiers to integer node IDs before building graphs.

```sh
pip3 install networkit
```

**benedekrozemberczki/littleballoffur** (714 stars)

[benedekrozemberczki/littleballoffur](https://github.com/benedekrozemberczki/littleballoffur) 

```python
def get_pagerank(self, graph: NKGraph, alpha: float) -> np.array:
    """
    Given a graph return the PageRank vector.
    """
    pagerank = nk.centrality.PageRank(graph, alpha)
    pagerank.run()
    pagerank = np.array(pagerank.scores())
    pagerank = pagerank / pagerank.sum()
    return pagerank

```

[littleballoffur/backend.py](https://github.com/benedekrozemberczki/littleballoffur/blob/67b3f6ba624d94384339eb859417d73ebeca1b02/littleballoffur/backend.py#L86-L94) · [More projects using NetworKit →](https://dashboard.exa.ai/playground/search?q=Python%20projects%20that%20use%20networkit&filters=%7B%22type%22%3A%20%22auto%22%2C%20%22numResults%22%3A%2010%2C%20%22includeDomains%22%3A%20%5B%22github.com%22%5D%7D)

**Quickstart**

```python
import networkit as nk

G = nk.Graph(5)

G.addEdge(1, 3)

```

From [User-Guide.html](https://networkit.github.io/dev-docs/notebooks/GraphNotebook.html)

## FAQ

### Which Python graph library should I use?

[NetworkX](#networkx) suits most graph work, with any hashable Python object as a node. [rustworkx](#rustworkx) and [igraph](#igraph) suit larger graphs that need compiled algorithms. [NetworKit](#networkit) suits very large networks with parallel algorithms.

### What is NetworkX?

[NetworkX](#networkx) builds and analyzes graphs in pure Python with any hashable object as a node. It includes a broad set of graph algorithms and drawing helpers.

### NetworkX vs igraph: which should I use?

[NetworkX](#networkx) keeps nodes as Python objects and suits graphs that change often. [igraph](#igraph) identifies vertices by index and suits relatively static networks that need faster analysis.

### How do I detect communities in a graph in Python?

[leidenalg](#leidenalg) runs the Leiden algorithm and supports multiplex and temporal graph layers. [python-louvain](#python-louvain) runs the Louvain algorithm on an undirected NetworkX graph and returns a node-to-community dictionary.

## How this page was built

Data checked Nov 20, 2026.

Reproduce it with the Exa API:

```json
{
  "endpoint": "/search",
  "body": {
    "query": "Python graph libraries NetworkX igraph rustworkx NetworKit graph-tool shortest paths community detection parallel algorithms",
    "numResults": 5
  }
}
```

Docs: https://exa.ai/docs/reference/search
