/**
 * Holds one graph level of the METIS multilevel pipeline.
 *
 * Extends `CSRGraph` — the CSR adjacency (`edge_addresses`, `adjacency`,
 * `edge_weights`, `vertex_weights`) lives in a single shared `ArrayBuffer`.
 *
 * Adds three groups of fields on top of CSR:
 *
 *   - **Multilevel link**: `coarse_vertex_map`, `coarser_graph`, `finer_graph`.
 *     `coarse_vertex_map[v]` is the id of v's super-vertex one level coarser.
 *
 *   - **Partition state**: `vertex_partition`, `partition_weights`, `current_cut`,
 *     plus the boundary list (`boundary_count` / `boundary_vertices` /
 *     `boundary_position_of_vertex`).
 *
 *   - **K-way refinement bookkeeping**: parallel `internal_degree`,
 *     `external_degree`, `neighbor_partition_count`, `neighbor_partition_offset`
 *     arrays plus the shared `neighbor_partition_pool` of `(partition_id, edge_weight)`
 *     records.
 *
 * Partition / refinement arrays are allocated lazily by
 * `allocate_partition_state(partition_count)` because their sizes depend on `k`,
 * which isn't known at CSR construction time and isn't needed during the
 * coarsening or initial-partitioning phases.
 *
 * Volume objective, multi-constraint balance, separator data, and the various
 * minconn/contig auxiliary fields from libmetis `graph_t` are intentionally
 * omitted — they're not on the path we currently use.
 */
export class MetisGraph extends CSRGraph {
    /**
     * Coarsening map: `coarse_vertex_map[v]` is the id of v's super-vertex
     * in `coarser_graph`. Null until coarsening runs at this level.
     * @type {Uint32Array|null}
     */
    coarse_vertex_map: Uint32Array | null;
    /** @type {MetisGraph|null} */
    coarser_graph: MetisGraph | null;
    /** @type {MetisGraph|null} */
    finer_graph: MetisGraph | null;
    /**
     * Partition id per vertex, in [0, nparts).
     * @type {Uint32Array|null}
     */
    vertex_partition: Uint32Array | null;
    /**
     * Per-partition total weight (sum of `vertex_weights` for vertices
     * currently assigned to that partition).
     * @type {Uint32Array|null}
     */
    partition_weights: Uint32Array | null;
    /**
     * Current edge cut: sum of weights of edges whose endpoints lie in
     * different partitions. Tracked incrementally during refinement.
     * @type {number}
     */
    current_cut: number;
    /**
     * Number of vertices currently on a partition boundary.
     * @type {number}
     */
    boundary_count: number;
    /**
     * Boundary list: the first `boundary_count` entries are vertex ids on
     * a partition boundary. Order is not meaningful (entries get swapped
     * with the tail on removal).
     * @type {Uint32Array|null}
     */
    boundary_vertices: Uint32Array | null;
    /**
     * Inverse of `boundary_vertices`: `boundary_position_of_vertex[v]` is
     * the index of v inside `boundary_vertices`, or -1 if v is interior.
     * Int32Array because of the -1 sentinel.
     * @type {Int32Array|null}
     */
    boundary_position_of_vertex: Int32Array | null;
    /**
     * Internal degree: sum of edge weights from v to vertices in v's own
     * partition. ("id" in METIS / FM literature.)
     * @type {Uint32Array|null}
     */
    internal_degree: Uint32Array | null;
    /**
     * External degree: sum of edge weights from v to vertices in other
     * partitions. ("ed" in METIS / FM literature.)
     * @type {Uint32Array|null}
     */
    external_degree: Uint32Array | null;
    /**
     * Number of distinct neighbouring partitions reachable from v through
     * its edges. ("nnbrs" in METIS.)
     * @type {Uint32Array|null}
     */
    neighbor_partition_count: Uint32Array | null;
    /**
     * Offset (in record units) into `neighbor_partition_pool` for v's list
     * of (partition_id, edge_weight) entries. -1 if v is interior and no
     * pool slot has been allocated yet. ("inbr" in METIS.)
     * @type {Int32Array|null}
     */
    neighbor_partition_offset: Int32Array | null;
    /**
     * Pool of per-(vertex, neighbour-partition) records. Each record is
     * 8 bytes: two uint32 words holding `(partition_id, edge_weight)`.
     * Access record `r` via:
     *   const word_base = neighbor_partition_pool.element_word(r);
     *   const partition_id  = data_uint32[word_base + 2*k    ];
     *   const edge_weight   = data_uint32[word_base + 2*k + 1];
     * where `k` is in `[0, neighbor_partition_count[v])`.
     *
     * ("cnbrpool" in METIS.)
     *
     * @type {BinaryElementPool|null}
     */
    neighbor_partition_pool: BinaryElementPool | null;
    /**
     * Allocate the k-way refinement bookkeeping arrays. Must be called before
     * any of the refinement routines runs on this graph.
     *
     * **`vertex_partition` is preserved** if it's already set with the correct
     * length. This matters when the initial-partition phase has already
     * computed an assignment (e.g. recursive bisection leaves the result in
     * `vertex_partition` as a buffer that's now owned by this graph) — we
     * don't want to allocate a fresh array just to copy the existing one in.
     * If `vertex_partition` is `null` or the wrong size, it gets allocated
     * fresh and zero-filled.
     *
     * Everything else (`partition_weights`, `internal_degree`, etc.) is always
     * allocated fresh because callers expect a clean refinement-state baseline.
     *
     * @param {number} partition_count
     */
    allocate_partition_state(partition_count: number): void;
    /**
     * Reset the partition / refinement bookkeeping in place, leaving the CSR
     * adjacency and `coarse_vertex_map` untouched. Used between FM passes when
     * we want to recompute from a fresh `vertex_partition`.
     */
    reset_refinement_state(): void;
    isMetisGraph: boolean;
}
import { CSRGraph } from "../../csr/CSRGraph.js";
import { BinaryElementPool } from "../../../geom/3d/topology/struct/binary/BinaryElementPool.js";
//# sourceMappingURL=MetisGraph.d.ts.map