Registry / data / igraph

igraph

JSON →
library1.0.0pypypi✓ verified 23d ago

igraph is a high-performance Python library for creating, manipulating, and analyzing graphs (networks). It provides a Python interface to the igraph C core library, designed for speed and efficiency in complex network research and analysis. The current version is 1.0.0, with regular bugfix releases for its C core and Python interface.

pip install igraph
INSTALL
IMPORT
SIG · IGRAPH
I
igraph
datapythonv1.0.0
Install
2.4s avg
Import
413ms
Disk
36MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v1.0.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.910 runs
installs and imports cleanly · install 0.0s · import 0.422s · 38MB
glibc
py 3.103.910 runs
installs and imports cleanly · install 2.4s · import 0.403s · 37MB
36MB installed
● package 36MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

igraph
import igraph as ig
from igraph import *
Wildcard imports are generally discouraged in Python and can lead to namespace pollution.
Graph
from igraph import Graph
from igraph.Graph import Graph
The Graph class is directly available from the top-level igraph package.

This quickstart demonstrates how to create a directed graph, add vertices and edges with attributes, customize vertex and edge appearance, plot the graph using Matplotlib, and find a shortest path. It highlights common operations for graph construction and visualization.

import igraph as ig import matplotlib.pyplot as plt # Construct a directed graph with 5 vertices g = ig.Graph(directed=True) g.add_vertices(5) # Set vertex attributes g.vs['name'] = ['Alice', 'Bob', 'Charlie', 'David', 'Eve'] g.vs['gender'] = ['F', 'M', 'M', 'M', 'F'] # Add edges with attributes edges = [(0, 1), (1, 3), (4, 2), (3, 4), (2, 0)] g.add_edges(edges) g.es['weight'] = [1, 2, 1, 3, 2] # Example edge attribute # Plot the graph fig, ax = plt.subplots(figsize=(6,6)) custom_colors = ['#FFC0CB' if g.vs[v_id]['gender'] == 'F' else '#87CEEB' for v_id in range(g.vcount())] ig.plot( g, target=ax, layout='circle', vertex_size=30, vertex_color=custom_colors, vertex_label=g.vs['name'], edge_width=[edge['weight'] for edge in g.es], edge_color='gray' ) plt.title('Sample Social Network') plt.show() # Find shortest path (example) shortest_path = g.get_shortest_paths(0, to=4) print(f"Shortest path from Alice to Eve: {shortest_path}")
Debug
Known issues
breakingThe package `python-igraph` is deprecated. Users should now install and import `igraph` directly. The `python-igraph` package (version 1.0.0) acts as a stub that installs `igraph`.
fix
Change your `pip install python-igraph` to `pip install igraph` and update import statements from `import python_igraph as ig` (if used) to `import igraph as ig`.
affects: python-igraph (all versions >0.9.8) / igraph (all versions)
breakingigraph (Python interface) version 0.8.x was the last to officially support Python 2.7. Current versions of `igraph` (since 1.0.0) require Python 3.9 or higher.
fix
Upgrade your Python environment to Python 3.9 or newer.
affects: igraph < 0.9.0 (Python 2.7 support), igraph >= 1.0.0 (Python >=3.9 required)
gotchaPlotting functionality requires additional dependencies (e.g., `matplotlib`, `cairocffi`). Without them, `igraph.plot()` will raise an error indicating plotting is not available. `cairocffi` is recommended over `pycairo` for better compatibility and quality.
fix
Install plotting dependencies: `pip install 'igraph[plotting]'` or `pip install matplotlib cairocffi`.
affects: all versions
breakingThe C core of igraph, which the Python interface wraps, introduced several API-breaking changes in its 1.0.0 release for greater consistency. Specific changes include renaming `Graph.Incidence()` to `Graph.Biadjacency()` and `Graph.get_incidence()` to `Graph.get_biadjacency()`. Similarly, `Graph.are_connected()` was renamed to `Graph.are_adjacent()`.
fix
Consult the `igraph` documentation for the 1.0.0 C core (and corresponding Python interface) for updated function names. Deprecated names might still work with warnings in intermediate versions but will be removed.
affects: igraph >= 1.0.0
gotchaIn `igraph` versions 0.11 and later, adding vertices with integer names will issue a deprecation warning and will be prevented in future versions. Vertex names are generally expected to be strings.
fix
Use string values for vertex names (e.g., `g.vs['name'] = ['0', '1']` instead of `g.vs['name'] = [0, 1]`) to ensure future compatibility. Integer IDs are internally managed by `igraph`.
affects: igraph >= 0.11.0
gotchaWhen installing from source, especially on Linux or with specific Python distributions like Anaconda, conflicts with external libraries (e.g., `libgfortran.so.4`) can occur. Active Anaconda environments are known to cause issues during compilation and usage.
fix
It is recommended to use pre-compiled wheels (`pip install igraph`). If compiling from source, ensure no Anaconda environments are active (`conda deactivate`) and that Anaconda's `bin` directory is not in your `PATH`.
affects: all versions (source installation)
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'igraph'
The igraph library's Python interface (packaged as `python-igraph`) is not installed in the current Python environment, or the environment where it's installed is not active.
fix
Install the correct package using pip: `pip install python-igraph` or with conda: `conda install -c conda-forge python-igraph`.
DLL import errors while trying to import igraph
On Windows, the igraph library (specifically its C core) often depends on the Visual C++ Redistributable library, which might be missing from your system.
fix
Download and install the appropriate Visual C++ Redistributable for Visual Studio for your system architecture (32-bit or 64-bit) from Microsoft's official website.
Errors about something called Cairo (for plotting)
igraph uses the Cairo graphics library for plotting by default. If Cairo and its Python bindings (PyCairo) are not installed, any attempt to use igraph's plotting functions will result in an error.
fix
Install Cairo headers using your system's package manager (e.g., `brew install cairo` on macOS, `sudo apt-get install libcairo2-dev` on Debian/Ubuntu) and then install PyCairo: `pip install pycairo`. Alternatively, for igraph versions 0.9.0 and later, you can switch to the matplotlib backend: `igraph.plot_surface(backend='matplotlib')`.
AttributeError: 'module' object has no attribute 'Graph'
This error often occurs when a different `igraph` package from PyPI (which is not the official Python interface for the C igraph library) has been installed, or when there's a conflict between installed `igraph` versions, leading to the incorrect module being imported.
fix
Ensure you have `python-igraph` installed (`pip install python-igraph`) and not `igraph`. If `igraph` was mistakenly installed, uninstall it first: `pip uninstall igraph`. Then, import as `import igraph as ig` and use `ig.Graph()`.
Upgrade
Version history
1.0.0latest on PyPI · released Oct 23, 2025
Audit
Dependencies
matplotliboptionalFor basic graph plotting functionality.
cairocffioptionalRecommended for high-quality static plots, especially in Jupyter notebooks. Alternative to pycairo.
plotlyoptionalFor experimental interactive plotting functionality.
Agent activity
11 hits · last 30 days
node
10
Resources
igraph — pip install igraph · libregistry