ParMETIS partitions a distributed graph across MPI processes so that the number of edges cut between partitions is minimized while keeping vertex weights balanced. Each process owns a contiguous range of vertices and the local adjacency lists for those vertices. The library handles all inter-process communication internally, so you only need to build the distributed data structures and call the appropriate function.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.
Choosing a partitioning function
| Function | When to use |
|---|---|
ParMETIS_V3_PartKway | General-purpose k-way partitioning. Best default choice. |
ParMETIS_V3_PartGeomKway | You have geometric coordinates (e.g. mesh node positions). Combines geometric and graph information for better initial partitioning. |
ParMETIS_V3_PartGeom | Geometry-only partitioning (no graph structure). Useful as a fast initial partition or when no adjacency data is available. |
PartGeomKway when vertex coordinates are available and the graph has spatial locality — it typically produces lower edge cuts than PartKway alone for structured meshes.
Step-by-step setup
Build vtxdist
vtxdist is a replicated array of length npes + 1. vtxdist[i] holds the global index of the first vertex owned by process i. vtxdist[npes] equals the total number of vertices.vtxdist.Build local xadj and adjncy in CSR format
Each process stores the adjacency lists of its local vertices in compressed sparse row (CSR) format. Neighbor indices are global vertex numbers.
xadj has length local_nvtxs + 1; xadj[i] is the index into adjncy where vertex i’s neighbor list begins.Set wgtflag
wgtflag controls which weight arrays are used:| Value | Meaning |
|---|---|
0 | No weights (pass NULL for vwgt and adjwgt) |
1 | Edge weights only |
2 | Vertex weights only |
3 | Both vertex and edge weights |
Set tpwgts
tpwgts is an array of nparts * ncon floats specifying the target fraction of total weight for each (partition, constraint) pair. The values for each constraint must sum to 1.0.Set ubvec
ubvec is an array of ncon floats, one per constraint, giving the maximum allowed imbalance ratio. A value of 1.05 permits up to 5% imbalance.Complete example
Function signatures
Compilation
Set
numflag = 0 for C-style 0-based indexing. Set numflag = 1 for Fortran-style 1-based indexing.