/**
 * K-way Fiduccia–Mattheyses cut refinement (single-constraint, cut objective).
 *
 * For each pass:
 *   1. Insert all boundary vertices into a max-heap keyed by
 *      `gain = external_degree / sqrt(neighbor_partition_count) - internal_degree`.
 *   2. Repeatedly pop the highest-gain vertex. Find the best target partition
 *      satisfying either the standard balance bounds OR a balance-improvement
 *      exception. Commit the move.
 *   3. Each move incrementally updates id/ed/nbrs for the moved vertex and all
 *      its neighbours, including queue priorities and boundary membership.
 *
 * The pass terminates when the heap drains or no further moves help. Multiple
 * passes are run (default 10) until cut stops improving.
 *
 * Mirrors `Greedy_KWayCutOptimize` from libmetis/kwayfm.c master (post-5.1.0),
 * OMODE_REFINE branch. Three master-era refinements over the 5.1.0 baseline:
 *
 *   - **Adaptive ub_factor**: at start, expand `ub_factor` to match the current
 *     load imbalance if the graph is already worse than the configured bound.
 *     Without this, refinement starting from an imbalanced state can't legally
 *     act on it and gets stuck.
 *   - **No `fudge_factor` slack** on the max-weight check (master forces this to
 *     0 internally). The looser balance comes from the adaptive ub_factor instead.
 *   - **Balance-improvement exception**: a move that violates the strict balance
 *     bound is still allowed if it improves the proportional balance ratio
 *     between `from` and `to`. Lets refinement pull weight back toward the
 *     target over time.
 *
 * Skipped:
 *   - minconn (sub-domain connectivity minimisation)
 *   - contig (contiguous-partition articulation-point checks)
 *   - ncon > 1 (multi-constraint balance)
 *   - OMODE_BALANCE (we run REFINE only; the adaptive ub_factor recovers most
 *     of what an explicit BALANCE pass would have done)
 *
 * Assumes `compute_kway_params` (or `project_kway`) has populated the refinement
 * state on the graph.
 *
 * @param {import('../MetisGraph.js').MetisGraph} graph
 * @param {number} partition_count
 * @param {{
 *   random: function():number,
 *   pass_count?: number,
 *   ub_factor?: number,
 *   fudge_factor?: number,
 * }} opts
 *   `ub_factor` (default 1.03) caps `partition_weight` at `target × ub_factor`.
 *   Will be expanded automatically if the input is already more imbalanced.
 *   `fudge_factor` (default 0; master sets this to 0). Set non-zero to allow
 *   positive-gain moves to overshoot the max bound by `fudge_factor × gain`.
 * @param {import('./RefinementScratch.js').RefinementScratch} scratch shared
 *   scratch sized to the original (finest) graph's vertex_count and the same
 *   partition_count used here
 * @returns {number} total moves committed across all passes
 */
export function fm_kway(graph: import('../MetisGraph.js').MetisGraph, partition_count: number, opts: {
    random: () => number;
    pass_count?: number;
    ub_factor?: number;
    fudge_factor?: number;
}, scratch: import('./RefinementScratch.js').RefinementScratch): number;
//# sourceMappingURL=fm_kway.d.ts.map