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.

ndmetis computes a fill-reducing reordering of the vertices of a graph, which corresponds to reordering the rows and columns of a sparse symmetric matrix. The resulting permutation minimizes the fill-in created during Cholesky or LU factorization. It uses METIS’s multilevel nested dissection algorithm, which recursively finds vertex separators and orders them last within each bisected subgraph.

Usage

ndmetis [options] graphfile
ArgumentDescription
graphfilePath to the graph file whose vertices are to be reordered.
The input graph must have exactly one balancing constraint. Graphs with multiple constraints are not supported by the ordering algorithm.

Output Files

ndmetis writes two files derived from the input filename:
FileContents
<graphfile>.ipermInverse permutation: iperm[i] is the new position of old vertex i.
<graphfile>.permForward permutation: perm[j] is the old vertex index at new position j.
Both files contain one integer per line, using 0-based indexing.

Using the Permutation with Sparse Solvers

Most sparse direct solvers accept a reordering in one of two forms. METIS produces both:
1

Reorder the matrix

Apply iperm to permute rows and columns of your matrix A into a new matrix A' with less fill: reorder row/column i to position iperm[i].
2

Factor the reordered matrix

Factorize A' = P A P^T using your sparse Cholesky or LU solver. The factorization of A' has significantly fewer nonzeros than factorizing A directly.
3

Solve the system

To solve Ax = b, solve A'y = Pb, then recover x = P^T y.
Many solver libraries (LAPACK, CHOLMOD, SuperLU) accept a permutation vector directly and handle the reordering internally.

Example

ndmetis graphs/4elt.graph
Sample output:
******************************************************************************
METIS 5.2.1 Copyright 1998-13, Regents of the University of Minnesota

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

Options ---------------------------------------------------------------------
 ctype=shem, rtype=1sided, iptype=node, seed=-1, dbglvl=0
 ufactor=1.200, pfactor=0.00, no2hop=NO, ccorder=NO, compress=YES
 ondisk=NO, nooutput=NO
 niter=10, nseps=1

Node-based Nested Dissection ------------------------------------------------
  Nonzeros: 3.867e+05   Operation Count: 9.544e+06

Timing Information ----------------------------------------------------------
  I/O:               0.012 sec
  Ordering:          0.081 sec   (METIS time)
  Reporting:         0.003 sec
******************************************************************************

Options Reference

Coarsening

ctype
string
default:"shem"
Vertex matching scheme used during graph coarsening.
ValueDescription
shemSorted heavy-edge matching (default)
rmRandom matching
no2hop
flag
Disables 2-hop matchings during coarsening. By default, METIS uses 2-hop matchings as a fallback when standard matching cannot sufficiently reduce the graph size. This flag disables that fallback.
nocompress
flag
Disables vertex compression before ordering. By default, METIS identifies and merges vertices with identical adjacency lists before computing the ordering, which can significantly speed up the process for graphs with many such vertices. Pass this flag to disable that compression step.

Initial Separator

iptype
string
default:"node"
Method used to compute the initial vertex separator at each level of bisection.
ValueDescription
nodeGreedy node-based separator strategy (default)
edgeDerive vertex separator from an edge cut

Refinement

rtype
string
default:"1sided"
Refinement algorithm for improving vertex separators during uncoarsening.
ValueDescription
1sided1-sided node-based refinement (default)
2sided2-sided node-based refinement
niter
integer
default:"10"
Maximum number of refinement iterations applied at each level of the uncoarsening process.
nseps
integer
default:"1"
Number of vertex separators to compute at each level of nested dissection. The smallest separator found is used. Increasing this value improves ordering quality at the cost of additional computation.

Load Balance

ufactor
integer
default:"200"
Maximum allowed load imbalance between the left and right subgraphs at each bisection, expressed as an integer x where the actual tolerance is 1 + x/1000. The default of 200 corresponds to a tolerance of 1.20 (20% imbalance).
pfactor
integer
default:"0"
Minimum degree threshold for ordering high-degree vertices last. Any vertex with degree greater than 0.1 * pfactor * (average_degree) is removed, the remaining graph is ordered, and the removed vertices are appended at the end of the ordering. A value of 0 (the default) disables this behavior.
Setting -pfactor to a positive value (e.g., 8) can significantly improve ordering quality for graphs with a few very high-degree “hub” vertices, such as LP matrices or social graphs.

Graph Preprocessing

ccorder
flag
Identifies connected components of the graph and orders each component independently before combining the results. Useful for graphs that are not fully connected.

Memory and I/O

ondisk
flag
Stores intermediate coarsened graphs to disk during coarsening to reduce peak memory usage. Useful for very large sparse matrices where memory is the primary constraint.
nooutput
flag
Suppresses writing the .iperm and .perm output files. Statistics and fill-in estimates are still printed to stdout.

Reproducibility and Diagnostics

seed
integer
default:"-1"
Seed for the random number generator. The default of -1 uses a time-based seed. Set an explicit value for reproducible orderings.
dbglvl
integer
default:"0"
Debug verbosity level. Set to 0 for no debug output (default). Higher values enable internal diagnostic messages from the ordering algorithm.

Build docs developers (and LLMs) love