mt-kahypar 0.2.0

A statically-linked Mt-KaHyPar
Documentation
  • Coverage
  • 55.15%
    107 out of 194 items documented1 out of 55 items with examples
  • Size
  • Source code size: 38.16 MB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 2.46 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 10m 35s Average build duration of successful builds.
  • all releases: 11m 21s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • gzz2000/mt-kahypar-rs
    2 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • gzz2000

mt-kahypar — (Non-official) Static & Safe Rust bindings for Mt‑KaHyPar

mt-kahypar provides an idiomatic, ownership‑aware interface to the high‑performance C++ Mt‑KaHyPar (multi‑level hypergraph partitioner) library.

mt-kahypar compiles and links Mt-KaHyPar and all its dependencies (Boost and TBB) statically inside special namespaces.


Add the dependency

[dependencies]
mt-kahypar = "0.2"

Quick start

use mt_kahypar::*;

// 1. Build a partitioning context.
let ctx = Context::builder()
    .preset(Preset::Deterministic)
    .k(4)                 // number of blocks
    .epsilon(0.03)        // 3 % imbalance
    .objective(Objective::Km1)
    .seed(42)
    .verbose(false)       // change to true to print detailed logs
    .build()?;

// 2. Load (or construct) the hypergraph to be partitioned.
let hg = Hypergraph::from_file("netlist.hgr", &ctx, FileFormat::HMetis)?;

// 3. Partition it.
let part = hg.partition()?;

println!("cut = {} | imbalance = {}%", part.cut(), part.imbalance()*100.0);
# Ok::<(), mt_kahypar::Error>(())

Thread‑pool control

The very first Context creation implicitly calls [initialize_default], spawning an Mt‑KaHyPar thread pool with as many threads as logical CPUs. If you need finer control invoke [initialize] once before any other call:

mt_kahypar::initialize(64, /* interleaved = */ true);

Design notes & safety

  • All FFI handles (Context, Hypergraph, …) own their native resources and free them via Drop.
  • Each handle stores an immutable reference to the Context it was created with. Mixing objects built from different contexts triggers an assertion at the point of use.

For more details see the docs of individual types below or the upstream Mt‑KaHyPar README.