# pymetis
**Repository Path**: mirrors_inducer/pymetis
## Basic Information
- **Project Name**: pymetis
- **Description**: A Python wrapper around Metis, a graph partitioning package
- **Primary Language**: Unknown
- **License**: Apache-2.0
- **Default Branch**: main
- **Homepage**: None
- **GVP Project**: No
## Statistics
- **Stars**: 0
- **Forks**: 0
- **Created**: 2020-09-25
- **Last Updated**: 2026-11-04
## Categories & Tags
**Categories**: Uncategorized
**Tags**: None
## README
PyMetis: A Python Wrapper for METIS
===================================
.. image:: https://gitlab.tiker.net/inducer/pymetis/badges/main/pipeline.svg
:alt: Gitlab Build Status
:target: https://gitlab.tiker.net/inducer/pymetis/commits/main
.. image:: https://github.com/inducer/pymetis/actions/workflows/ci.yml/badge.svg
:alt: Github Build Status
:target: https://github.com/inducer/pymetis/actions/workflows/ci.yml
.. image:: https://badge.fury.io/py/PyMetis.svg
:alt: Python Package Index Release Page
:target: https://pypi.org/project/pymetis/
.. image:: https://zenodo.org/badge/2199177.svg
:alt: Zenodo DOI for latest release
:target: https://zenodo.org/badge/latestdoi/2199177
PyMetis is a `pybind11 `__-based
Python wrapper for the `METIS `__ graph
partitioning software by George Karypis, Vipin Kumar, and others.
It currently wraps version **5.2.1** of the METIS library.
Links
-----
* `Documentation `__ (read how things work)
* `Conda Forge `__ (download binary packages for Linux, macOS, Windows)
* `Python package index `__ (download releases)
* `C. Gohlke's Windows binaries `__ (download Windows binaries)
* `GitHub `__ (get latest source code, file bugs)
Installation
------------
The following line should do the job::
pip install pymetis
Quick Start
-----------
This graph, adapted from Figure 2 of the METIS
`manual `__ to
use zero-based indexing,
.. image:: https://raw.githubusercontent.com/inducer/pymetis/refs/heads/main/doc/_static/tiny_01.png
can be defined and partitioned into two graphs with
.. code:: python
import numpy as np
import pymetis
adjacency_list = [np.array([4, 2, 1]),
np.array([0, 2, 3]),
np.array([4, 3, 1, 0]),
np.array([1, 2, 5, 6]),
np.array([0, 2, 5]),
np.array([4, 3, 6]),
np.array([5, 3])]
n_cuts, membership = pymetis.part_graph(2, adjacency=adjacency_list)
# n_cuts = 3
# membership = [1, 1, 1, 0, 1, 0, 0]
nodes_part_0 = np.argwhere(np.array(membership) == 0).ravel() # [3, 5, 6]
nodes_part_1 = np.argwhere(np.array(membership) == 1).ravel() # [0, 1, 2, 4]
.. image:: https://raw.githubusercontent.com/inducer/pymetis/refs/heads/main/doc/_static/tiny_01_partitioned.png