Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/KarypisLab/METIS/llms.txt

Use this file to discover all available pages before exploring further.

METIS ships with both command-line tools and a C library API. The CLI tools let you partition graphs and compute orderings directly from the terminal using the sample graphs included in the repository. The C API gives you full control from your own programs by calling METIS functions directly. This guide covers both approaches using the 4elt.graph finite element mesh included in the graphs/ directory.

CLI usage

After installing METIS, the following programs are available in your <prefix>/bin directory:
ProgramPurpose
gpmetisPartition a graph into k parts
ndmetisCompute a nested dissection ordering for sparse matrix fill reduction
mpmetisPartition a finite element mesh
m2gmetisConvert a mesh to a graph
graphchkValidate a graph file
cmpfillinCompare fill-in of two orderings

Partition a graph into 4 parts

The gpmetis command takes a graph file and the number of desired partitions:
gpmetis graphs/4elt.graph 4
Or, if running from the METIS source directory before installation:
./build/programs/gpmetis graphs/4elt.graph 4
Sample output:
******************************************************************************
METIS 5.2.1 Copyright 1998-2020, Regents of the University of Minnesota
 (HEAD: , )

 size of idx_t: 32bits, size of real_t: 32bits

Graph Information -----------------------------------------------------------
 Name: graphs/4elt.graph, #Vertices: 15606, #Edges: 45878, #Parts: 4

Options Information ---------------------------------------------------------
 ptype=kway, objtype=cut, ctype=shem, iptype=grow, rtype=greedy
 dbglvl=0, ufactor=1.030, minconn=0, contig=0, nooutput=0
 seed=-1, niter=10, ncuts=1

Direct k-way Partitioning --------------------------------------------------
 ...
 - Edgecut: 716, communication volume: 641

Timing Information ---------------------------------------------------------
 I/O:          0.001 sec
 Partitioning: 0.018 sec   (METIS time)
 Total:        0.019 sec

Completed.
******************************************************************************
The key result is the edgecut — the number of edges that cross partition boundaries. A lower edgecut means less inter-partition communication.METIS writes a partition file named <graphfile>.part.<k> (here: graphs/4elt.graph.part.4). Each line i contains the partition number (0-indexed) assigned to vertex i.

Compute a sparse matrix ordering

The ndmetis command computes a nested dissection ordering that reduces fill-in when factoring a sparse matrix:
ndmetis graphs/4elt.graph
Or from the source directory:
./build/programs/ndmetis graphs/4elt.graph
This produces two output files:
  • graphs/4elt.graph.iperm — the inverse permutation (node → reordered position)
  • graphs/4elt.graph.perm — the forward permutation (reordered position → original node)

Validate a graph file

Before partitioning, you can check that a graph file is well-formed:
graphchk graphs/4elt.graph

Build docs developers (and LLMs) love