{"id":21767,"library":"pymetis","title":"PyMetis","description":"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.","status":"active","version":"2025.2.2","language":"python","source_language":"en","source_url":"https://github.com/inducer/pymetis","tags":["graph partitioning","METIS","combinatorial optimization"],"install":[{"cmd":"pip install pymetis","lang":"bash","label":"Install from PyPI"}],"dependencies":[{"reason":"Required for array-like inputs and handling of adjacency structures.","package":"numpy","optional":false}],"imports":[{"note":"Correct import.","wrong":null,"symbol":"pymetis","correct":"import pymetis"},{"note":"part_graph is a function in the pymetis module; direct import may work but less conventional.","wrong":"from pymetis import part_graph","symbol":"pymetis.part_graph","correct":"import pymetis\npart = pymetis.part_graph(nparts, adjacency=adjacency)"}],"quickstart":{"code":"import numpy as np\nimport pymetis\n\n# Define adjacency list for a small graph\n# Each entry is a list of neighbor indices\nadjacency = [[1, 2], [0, 2], [0, 1, 3], [2]]\nnparts = 2\n\ncut, parts = pymetis.part_graph(nparts, adjacency=adjacency)\nprint(f\"Edge cut: {cut}\")\nprint(f\"Partition assignments: {parts}\")","lang":"python","description":"Basic graph partitioning using pymetis."},"warnings":[{"fix":"Preprocess your graph to remove duplicates and self-loops before calling pymetis.","message":"METIS 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.","severity":"gotcha","affected_versions":"all"},{"fix":"Use `zero_copy=False` if you need the old behavior of copying the adjacency list.","message":"In 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.","severity":"breaking","affected_versions":">=2025.2"},{"fix":"Ensure sufficient memory and consider using iterative partitioning for large graphs.","message":"METIS functions can segfault if the graph is too large or if memory is insufficient. pymetis does not provide graceful error handling for such cases.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"search_vec":"'2025.2.2':31 '3.10':34 'activ':38 'algorithm':15 'combinatori':46 'graph':13,29,43 'high':24 'high-level':23 'interfac':26 'level':21,25 'low':20 'low-level':19 'maintain':39 'meti':8,45 'optim':47 'packag':36 'partit':14,28,44 'period':41 'provid':17 'pymeti':1,2 'python':5,33 'releas':42 'serial':12 'set':10 'support':32 'version':30 'wrapper':6","created_at":"2026-04-27T17:01:38.420372+00:00","updated_at":"2026-04-27T17:01:38.420372+00:00","problems":[{"fix":"Install pymetis with `pip install pymetis` or upgrade Python.","cause":"pymetis is not installed or Python version is <3.10.","error":"ImportError: No module named pymetis"},{"fix":"Ensure adjacency is a list of lists of ints, e.g., `[[1,2],[0,2]]`.","cause":"Adjacency list contains non-integer elements (e.g., floats) or is not a list of lists.","error":"ValueError: adjacency must be a list of lists of integers"},{"fix":"Update code to unpack two values: cut, parts = pymetis.part_graph(...)","cause":"Using older version where part_graph returned a single value; modern pymetis returns a tuple (cut, parts).","error":"pymetis.part_graph returns only one argument (unexpected)","affected_versions":">=2022.1"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":"2025.2.2","cli_name":"","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/inducer/pymetis","docs":"https://documen.tician.de/pymetis","changelog":null,"pypi":"https://pypi.org/project/pymetis/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["data"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"passing","verified_at":"2026-06-28","last_verified":"2026-06-28","next_check":"2026-07-28","install_tag":null}}