Skip to main content

Documentation Index

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

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

ParMETIS_SerialNodeND computes a fill-reducing nested dissection ordering for a distributed sparse matrix using the serial METIS ordering algorithm rather than the fully parallel approach of ParMETIS_V3_NodeND. Each process contributes its local graph data and the function coordinates across all processes to produce a globally consistent permutation. This can be a better choice for small-to-medium graphs where the serial METIS ordering quality is preferred over the parallel algorithm’s heuristics.
int ParMETIS_SerialNodeND(
    idx_t *vtxdist, idx_t *xadj, idx_t *adjncy, idx_t *numflag,
    idx_t *options, idx_t *order, idx_t *sizes, MPI_Comm *comm);

Parameters

vtxdist
idx_t*
Distribution of vertices (matrix rows/columns) across processes. vtxdist[i] is the global index of the first vertex on process i. Size npes + 1; must be identical on all processes.
xadj
idx_t*
Local adjacency row pointers in CSR format representing the local rows of the sparsity pattern. Size local_nvtxs + 1, where local_nvtxs = vtxdist[rank+1] - vtxdist[rank].
adjncy
idx_t*
Local adjacency column indices in CSR format. Size xadj[local_nvtxs].
numflag
idx_t*
Indexing convention. 0 for C-style 0-based indexing; 1 for Fortran-style 1-based indexing.
options
idx_t*
Algorithm options. If options[0] = 0, all defaults are used. If options[0] = 1, options[PMV3_OPTION_DBGLVL] (index 1) sets the debug level and options[PMV3_OPTION_SEED] (index 2) sets the random seed.
order
idx_t*
Output. Fill-reducing permutation array. order[i] is the new global index assigned to global vertex i. The caller must allocate this array with vtxdist[npes] elements (total vertex count).
sizes
idx_t*
Output. Separator sizes for the nested dissection tree. Array of size 2 * npes. Describes the separator structure of the dissection, which can be used to plan parallel sparse factorization.
comm
MPI_Comm*
Pointer to the MPI communicator covering all participating processes.

Return value

Returns METIS_OK (1) on success. Any other value indicates an error.

When to use this function

Use ParMETIS_SerialNodeND when your graph is small enough that serial METIS ordering quality is important, or when you observe that ParMETIS_V3_NodeND produces orderings with higher fill-in than expected. For large distributed graphs, ParMETIS_V3_NodeND or ParMETIS_V32_NodeND will scale better.
The function has the same signature as ParMETIS_V3_NodeND, so switching between the two requires only changing the function name in your call site.

Usage example

#include <mpi.h>
#include <parmetis.h>

int main(int argc, char *argv[]) {
    MPI_Init(&argc, &argv);
    MPI_Comm comm = MPI_COMM_WORLD;

    int npes, rank;
    MPI_Comm_size(comm, &npes);
    MPI_Comm_rank(comm, &rank);

    /* Assume vtxdist, xadj, adjncy are populated with your graph data */
    idx_t local_nvtxs = 10;
    idx_t vtxdist[npes + 1];
    for (int i = 0; i <= npes; i++) vtxdist[i] = i * local_nvtxs;
    idx_t total_nvtxs = vtxdist[npes];

    idx_t numflag     = 0;
    idx_t options[3]  = {0, 0, 0};     /* use defaults */

    idx_t *order = (idx_t *)malloc(total_nvtxs * sizeof(idx_t));
    idx_t *sizes = (idx_t *)malloc(2 * npes * sizeof(idx_t));

    int ret = ParMETIS_SerialNodeND(
        vtxdist, xadj, adjncy,
        &numflag, options,
        order, sizes, &comm);

    if (ret != METIS_OK) { /* handle error */ }

    /* Use order[] to permute your sparse matrix rows/columns */

    free(order);
    free(sizes);
    MPI_Finalize();
    return 0;
}
Compile with: mpicc -o prog prog.c -lparmetis -lmetis

Build docs developers (and LLMs) love