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.

All METIS partitioning and ordering functions accept an idx_t options[METIS_NOPTIONS] array that controls algorithm behavior. The array has METIS_NOPTIONS = 40 slots, indexed by the constants of the moptions_et enum. The value -1 in any slot means “use the algorithm’s default for this option.” Always initialize the entire array with METIS_SetDefaultOptions before setting individual entries.
idx_t options[METIS_NOPTIONS];
METIS_SetDefaultOptions(options);   /* fills all entries with -1 */

/* Then override what you need */
options[METIS_OPTION_NCUTS]  = 3;
options[METIS_OPTION_SEED]   = 42;

Partitioning Options

METIS_OPTION_PTYPE
idx_t
Partitioning scheme. Selects between recursive bisection and direct k-way.
ValueEnumDescription
0METIS_PTYPE_RBMultilevel recursive bisection
1METIS_PTYPE_KWAYMultilevel k-way partitioning (default)
Used by: METIS_PartMeshDual, METIS_PartMeshNodal (to select the underlying graph partitioner). Implicit for METIS_PartGraphKway and METIS_PartGraphRecursive, which have fixed algorithms.
METIS_OPTION_OBJTYPE
idx_t
Objective function to minimize.
ValueEnumDescription
0METIS_OBJTYPE_CUTMinimize edge cut (default for partitioning)
1METIS_OBJTYPE_VOLMinimize total communication volume (k-way only)
2METIS_OBJTYPE_NODEMinimize node separator size (ordering only)
METIS_PartGraphRecursive only supports METIS_OBJTYPE_CUT. METIS_NodeND always uses METIS_OBJTYPE_NODE regardless of this setting.
METIS_OPTION_NUMBERING
idx_t
Vertex numbering convention used in the input graph arrays.
ValueDescription
00-based (C-style) (default)
11-based (Fortran-style)
When set to 1, METIS temporarily renumbers arrays during processing and restores them on return.
METIS_OPTION_NCUTS
idx_t
Number of different partitionings to compute. METIS performs ncuts independent multilevel runs and returns the best result. Higher values improve quality at the cost of runtime.Default: 1
METIS_OPTION_NIPARTS
idx_t
Number of initial partition trials during the initial partitioning phase. More trials improve quality.Default: -1 (METIS selects automatically based on graph size and nparts)
METIS_OPTION_NITER
idx_t
Number of refinement iterations during the uncoarsening phase.Default: 10
METIS_OPTION_UFACTOR
idx_t
Maximum allowed load imbalance expressed as an integer. The actual balance tolerance is 1 + UFACTOR/1000. For example, UFACTOR = 30 allows up to 3% imbalance.Defaults: 30 for k-way partitioning, 1 for recursive bisection (single constraint), 10 for multi-constraint recursive bisection.
METIS_OPTION_MINCONN
idx_t
Whether to explicitly minimize the maximum subdomain connectivity (the number of neighboring subdomains). Enabling this can increase runtime but typically produces better partitions for iterative solvers.
ValueDescription
0Disabled (default)
1Enabled
Only applicable to METIS_PartGraphKway.
METIS_OPTION_CONTIG
idx_t
Whether to force contiguous (connected) partitions. When enabled, METIS ensures each partition is a connected subgraph.
ValueDescription
0Disabled (default)
1Enabled
Only applicable to METIS_PartGraphKway. The input graph must be connected when this option is used; passing a disconnected graph with CONTIG = 1 is an input error.
METIS_OPTION_SEED
idx_t
Seed for the random number generator. Set to a fixed non-negative value for reproducible results. Set to -1 to use a time-based seed.Default: -1 (random seed)

Coarsening Options

METIS_OPTION_CTYPE
idx_t
Coarsening scheme used to reduce the graph.
ValueEnumDescription
0METIS_CTYPE_RMRandom matching
1METIS_CTYPE_SHEMSorted heavy-edge matching (default)
SHEM tends to produce better coarsened graphs by preferring to match vertices connected by heavy edges.
METIS_OPTION_NO2HOP
idx_t
Whether to disable the 2-hop matching during coarsening. 2-hop matching connects vertices two hops apart in the graph to achieve better coarsening when the direct neighborhood is too small.
ValueDescription
02-hop matching enabled (default)
12-hop matching disabled
METIS_OPTION_TWOHOP
idx_t
Alias for controlling 2-hop coarsening behavior in some contexts. See METIS_OPTION_NO2HOP.Default: -1 (use NO2HOP setting)
METIS_OPTION_COMPRESS
idx_t
Whether to compress the graph before ordering by identifying and merging vertices with identical adjacency lists.
ValueDescription
0Disabled
1Enabled (default for NodeND)
Only applicable to METIS_NodeND. Compression can significantly speed up ordering on graphs with many identical rows (e.g., structured matrices), but is automatically disabled if pruning (METIS_OPTION_PFACTOR) is active.
METIS_OPTION_DROPEDGES
idx_t
Whether to randomly drop edges during coarsening to speed up the process on very dense graphs.
ValueDescription
0Disabled (default)
1Enabled
METIS_OPTION_ONDISK
idx_t
Whether to use out-of-core processing for very large graphs that do not fit in memory.
ValueDescription
0In-memory (default)
1Out-of-core (on-disk)

Refinement Options

METIS_OPTION_RTYPE
idx_t
Refinement scheme applied during uncoarsening.
ValueEnumDescription
0METIS_RTYPE_FMFiduccia-Mattheyses 2-way refinement (used by recursive bisection)
1METIS_RTYPE_GREEDYGreedy k-way refinement (default for k-way)
2METIS_RTYPE_SEP2SIDEDTwo-sided node FM separator refinement
3METIS_RTYPE_SEP1SIDEDOne-sided node FM separator refinement (default for NodeND)
Not all refinement types are valid for all operations. METIS returns METIS_ERROR_INPUT if an incompatible combination is specified.
METIS_OPTION_IPTYPE
idx_t
Initial partitioning scheme applied to the coarsened graph.
ValueEnumDescription
0METIS_IPTYPE_GROWGreedy grow bisection (default for recursive bisection, single constraint)
1METIS_IPTYPE_RANDOMRandom bisection (default for recursive bisection, multi-constraint)
2METIS_IPTYPE_EDGEEdge-based separator computation (default for NodeND)
3METIS_IPTYPE_NODENode-based separator computation
4METIS_IPTYPE_METISRBMETIS recursive bisection for k-way initial partition (default for k-way)

Ordering-Specific Options

METIS_OPTION_NSEPS
idx_t
Number of separators computed at each step of the nested dissection. METIS performs nseps bisections and selects the best separator (smallest weight). Only applicable to METIS_NodeND.Default: 1
METIS_OPTION_CCORDER
idx_t
Whether to detect connected components after each separator computation and order them independently, rather than treating the two halves as a single left/right subgraph pair.
ValueDescription
0Standard ordering (default)
1Order connected components separately
Only applicable to METIS_NodeND.
METIS_OPTION_PFACTOR
idx_t
Pruning factor for high-degree vertices during ordering. Vertices with degree greater than 0.1 * PFACTOR * (average degree) are removed before ordering and placed last in the ordering. This prevents high-degree “hub” vertices from dominating separator computations.A value of 0 disables pruning (default). Typical non-zero values are in the range 50200.Only applicable to METIS_NodeND.

Output and Debug Options

METIS_OPTION_DBGLVL
idx_t
Debug output level. This is a bitmask: OR together the values from mdbglvl_et to enable multiple output types simultaneously.
ValueEnumDescription
1METIS_DBG_INFOGeneral diagnostic messages
2METIS_DBG_TIMETiming information
4METIS_DBG_COARSENCoarsening progress
8METIS_DBG_REFINERefinement progress
16METIS_DBG_IPARTInitial partitioning info
32METIS_DBG_MOVEINFOVertex move info during refinement
64METIS_DBG_SEPINFOSeparator refinement moves
128METIS_DBG_CONNINFOSubdomain connectivity minimization
256METIS_DBG_CONTIGINFOConnected component elimination
2048METIS_DBG_MEMORYWorkspace allocation info
Default: 0 (no debug output)
/* Enable timing and coarsening output */
options[METIS_OPTION_DBGLVL] = METIS_DBG_TIME | METIS_DBG_COARSEN;
METIS_OPTION_FAST
idx_t
When enabled, uses faster but potentially lower-quality algorithms. Intended for large graphs where runtime is the primary concern.Default: -1 (disabled)

Full Initialization Example

#include <metis.h>

void configure_kway_partitioning(idx_t *options, idx_t nparts) {
    METIS_SetDefaultOptions(options);

    /* Objective: minimize edge cut (default, shown explicitly) */
    options[METIS_OPTION_OBJTYPE]  = METIS_OBJTYPE_CUT;

    /* Coarsening: sorted heavy-edge matching (default) */
    options[METIS_OPTION_CTYPE]    = METIS_CTYPE_SHEM;

    /* Try 5 cuts, keep the best */
    options[METIS_OPTION_NCUTS]    = 5;

    /* 10 refinement iterations per cut */
    options[METIS_OPTION_NITER]    = 10;

    /* Allow up to 3% imbalance */
    options[METIS_OPTION_UFACTOR]  = 30;

    /* Require contiguous partitions */
    options[METIS_OPTION_CONTIG]   = 1;

    /* Minimize subdomain connections */
    options[METIS_OPTION_MINCONN]  = 1;

    /* Reproducible run */
    options[METIS_OPTION_SEED]     = 12345;

    /* Show timing info */
    options[METIS_OPTION_DBGLVL]   = METIS_DBG_TIME;
}

void configure_nd_ordering(idx_t *options) {
    METIS_SetDefaultOptions(options);

    /* Try 3 separators at each bisection, keep the smallest */
    options[METIS_OPTION_NSEPS]    = 3;

    /* Compress identical rows before ordering */
    options[METIS_OPTION_COMPRESS] = 1;

    /* Prune high-degree vertices (degree > 0.1*100*sqrt(n)) */
    options[METIS_OPTION_PFACTOR]  = 100;

    /* One-sided separator refinement (default, shown explicitly) */
    options[METIS_OPTION_RTYPE]    = METIS_RTYPE_SEP1SIDED;
}

Build docs developers (and LLMs) love