Skip to main content

A Graph Partitioning Package

Project description

Gitlab Build Status Github Build Status Python Package Index Release Page

PyMetis is a Python wrapper for the Metis graph partititioning software by George Karypis, Vipin Kumar and others. It includes version 5.1.0 of Metis and wraps it using the Pybind11 wrapper generator library. So far, it only wraps the most basic graph partitioning functionality (which is enough for my current use), but extending it in case you need more should be quite straightforward. Using PyMetis to partition your meshes is really easy–essentially all you need to pass into PyMetis is an adjacency list for the graph and the number of parts you would like.

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,

doc/_static/tiny_01.png

can be defined and partitioned into two graphs with

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]
doc/_static/tiny_01_partitioned.png

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

PyMetis-2022.1.tar.gz (338.5 kB view details)

Uploaded Source

File details

Details for the file PyMetis-2022.1.tar.gz.

File metadata

  • Download URL: PyMetis-2022.1.tar.gz
  • Upload date:
  • Size: 338.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.5

File hashes

Hashes for PyMetis-2022.1.tar.gz
Algorithm Hash digest
SHA256 f849e2cb3e49da8e5c82a3e76830fe04175ba2d31bc436898f8dedfe9d6dde9b
MD5 e6359f9c57dce9bbd53f47fe0f281172
BLAKE2b-256 2a58ec4eddef8fd529b160c35e8dbf36851b8f60c2132a173e4017a6e722354e

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page