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_NodeND computes a fill-reducing permutation for a sparse symmetric matrix using the multilevel nested dissection algorithm. The resulting permutation, when applied to reorder the rows and columns of the matrix before factorization, significantly reduces the number of nonzeros introduced during Cholesky or LU decomposition (fill). It is the standard preprocessing step for direct sparse solvers such as CHOLMOD, PARDISO, SuperLU, and similar libraries.
The
vwgt parameter is NULL in most practical use cases. Vertex weights are only needed when the graph has vertices representing unequal amounts of work in the downstream computation (e.g., supernodes of different sizes). When in doubt, pass NULL.METIS_NodeND
Computes a fill-reducing ordering of the vertices of a graph. The graph should represent the nonzero structure of the lower triangle of the symmetric matrix to be factored (diagonal entries are excluded).Number of vertices in the graph (equivalently, the order of the sparse matrix).
CSR row-pointer array of size
nvtxs + 1. xadj[i] is the index into adjncy where vertex i’s adjacency list starts.CSR column-index array. Stores all adjacency lists concatenated. The adjacency list of each vertex should not contain the vertex itself (no self-loops).
Vertex weights array of size
nvtxs. Controls how separator size is measured during nested dissection. Pass NULL in most cases; METIS will treat all vertices as having unit weight.Options array of size
METIS_NOPTIONS initialized with METIS_SetDefaultOptions. Key ordering-specific options include METIS_OPTION_NSEPS, METIS_OPTION_COMPRESS, METIS_OPTION_CCORDER, and METIS_OPTION_PFACTOR. See Options Reference.Output: permutation array of size
nvtxs. If A is the original matrix and A' is the permuted matrix, then A'[i][j] = A[perm[i]][perm[j]]. Equivalently, perm[i] gives the original row/column index that maps to position i in the reordered matrix. Must be pre-allocated by the caller.Output: inverse permutation array of size
nvtxs. iperm[i] gives the new position of original vertex i in the reordered matrix. The relationship between the two arrays is: perm[iperm[i]] == i and iperm[perm[i]] == i. Must be pre-allocated by the caller.Understanding perm and iperm
The two output arrays encode the same reordering from opposite directions:- To reorder a matrix
AtoA' = P*A*P^T, usepermto index into the original row/column arrays. - To map a right-hand side vector
btob' = P*b, applyb'[iperm[i]] = b[i]for alli.
Using the Ordering with a Sparse Solver
Build the graph from your matrix
Extract the nonzero pattern of your symmetric matrix as a CSR graph. Diagonal entries and the upper triangle are excluded; only store the off-diagonal entries of the lower triangle (or use the full symmetric pattern — METIS handles both).
Reorder rows and columns
Apply the permutation to build the reordered matrix Many sparse solver libraries accept the permutation arrays directly and perform the reordering internally.
A' = P*A*P^T:Complete C Example
METIS_NodeNDP
A variant ofMETIS_NodeND designed for use by ParMETIS. It computes fill-reducing orderings for parallel direct solvers by performing a nested dissection that is aware of the desired number of processors. In addition to the permutation and inverse permutation, it returns separator sizes at each level of the dissection tree.
Number of vertices. Passed by value (not a pointer), unlike
METIS_NodeND.CSR row-pointer array of size
nvtxs + 1.CSR column-index array.
Vertex weights array of size
nvtxs. Pass NULL for unit weights.Number of parallel processors. The dissection tree will have
2*npes - 1 nodes. Passed by value.Options array initialized with
METIS_SetDefaultOptions.Output: permutation array of size
nvtxs. Pre-allocate before calling.Output: inverse permutation array of size
nvtxs. Pre-allocate before calling.Output: array of size
2*npes that stores the sizes of the vertex ranges for each subgraph and separator in the dissection tree. Used by ParMETIS to determine communication patterns. Pre-allocate before calling.METIS_NodeNDP is designed as an internal utility for ParMETIS and direct parallel solver interfaces. For standalone fill-reducing ordering, use METIS_NodeND.