Registry / data / pymetis

pymetis

JSON →
library2025.2.2pypypi✓ verified 89d ago

PyMetis is a Python wrapper for METIS, a set of serial graph partitioning algorithms. It provides both low-level and high-level interfaces for partitioning graphs. Version 2025.2.2 supports Python >=3.10. The package is actively maintained with periodic releases.

pip install pymetis
INSTALL
IMPORT
SIG · PYMETIS
P
pymetis
datapythonv2025.2.2
Install
1.7s avg
Import
261ms
Disk
18MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.9–3.13
musl
3.9–3.13
Install & Compatibility
Where this runs
tested against v2025.2.2 · 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.10–3.95 runs
installs and imports cleanly · install 0.0s · import 0.228s · 22.5MB
glibc
py 3.10–3.95 runs
installs and imports cleanly · install 1.7s · import 0.190s · 19MB
18MB installed
● package 18MB
Code
Verified usage

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

pymetis
✓ import pymetis
Correct import.
pymetis.part_graph
✓ import pymetis part = pymetis.part_graph(nparts, adjacency=adjacency)
✗ from pymetis import part_graph
part_graph is a function in the pymetis module; direct import may work but less conventional.

Basic graph partitioning using pymetis.

import numpy as np import pymetis # Define adjacency list for a small graph # Each entry is a list of neighbor indices adjacency = [[1, 2], [0, 2], [0, 1, 3], [2]] nparts = 2 cut, parts = pymetis.part_graph(nparts, adjacency=adjacency) print(f"Edge cut: {cut}") print(f"Partition assignments: {parts}")
Debug
Known issues
gotchaMETIS requires that graph adjacency lists contain no duplicate edges and no self-loops. pymetis does not validate inputs; passing invalid graphs can cause silent errors or crashes.
fix
Preprocess your graph to remove duplicates and self-loops before calling pymetis.
affects: all
breakingIn v2025.2, the zero-copy mode was introduced. If you rely on adjacency being modified by the C code (e.g., reordering), note that zero-copy may change behavior. The option `zero_copy=True` can be passed to `part_graph` to disable copying.
fix
Use `zero_copy=False` if you need the old behavior of copying the adjacency list.
affects: >=2025.2
gotchaMETIS functions can segfault if the graph is too large or if memory is insufficient. pymetis does not provide graceful error handling for such cases.
fix
Ensure sufficient memory and consider using iterative partitioning for large graphs.
affects: all
Errors
Common errors & fixes
ImportError: No module named pymetis
pymetis is not installed or Python version is <3.10.
fix
Install pymetis with `pip install pymetis` or upgrade Python.
ValueError: adjacency must be a list of lists of integers
Adjacency list contains non-integer elements (e.g., floats) or is not a list of lists.
fix
Ensure adjacency is a list of lists of ints, e.g., `[[1,2],[0,2]]`.
pymetis.part_graph returns only one argument (unexpected)
Using older version where part_graph returned a single value; modern pymetis returns a tuple (cut, parts).
fix
Update code to unpack two values: cut, parts = pymetis.part_graph(...)
Upgrade
Version history
2025.2.2latest on PyPI · released Nov 6, 2025
Audit
Dependencies
numpyrequiredRequired for array-like inputs and handling of adjacency structures.
Agent activity
8 hits · last 30 days
node
6
OpenAI (training)
2
Resources
pymetis — pip install pymetis · libregistry