/** * Approximate minimum degree ordering on a quotient graph, after Amestoy, * Davis and Duff ("An Approximate Minimum Degree Ordering Algorithm", SIAM * J. Matrix Anal. Appl. 17(4), 1996) and the SuiteSparse AMD reference * implementation. * * The quotient graph replaces the explicit fill edges of classical minimum * degree with elements: eliminating pivot p turns it into an element whose * variable list L_p is the union of p's surviving variable neighbors and the * variable lists of the elements adjacent to p, which are absorbed (their * lists die) in the same step. Cliques are therefore represented by one list * instead of O(|clique|^2) edges, which is what makes hub/supply-rail rows * affordable without the work budgets the previous greedy ordering needed. * * Implemented from the AMD toolbox: * - approximate external degrees via the three-way upper bound * d_i = min(nLeft - nv_i, d_prev + |L_p \ i|, |A_i| + |L_p \ i| + * sum_e |L_e \ L_p|), with the |L_e \ L_p| terms computed by the two-pass * set-counter scheme (w initialised to |L_e|, decremented per member seen * in L_p); * - element absorption, plus aggressive absorption (an element whose live * variables all land in L_p has |L_e \ L_p| = 0 and is deleted even when * it was not adjacent to the pivot); * - supervariable detection: variables in L_p are hashed by the sum of their * adjacency lists mod n, then compared exactly; indistinguishable ones are * merged and emitted consecutively when their representative leaves; * - mass elimination: a variable whose compacted adjacency is exactly the * new element is ordered immediately after the pivot (zero extra fill); * - dense-row deferral exactly as in the reference implementation (alpha = * 10): rows with more than max(16, 10*sqrt(n)) neighbors are taken out of * the quotient graph up front and appended to the order last. This is the * reference algorithm's structural answer to hubs, not a work budget — * without it every hub update rescans the hub's O(n) list and the * ordering degenerates to quadratic time on star patterns. * * Not implemented: assembly-tree postordering (the Gilbert-Peierls consumer * derives its own topological structure per column, so postorder would only * change memory locality, not fill), multiple elimination (that is MMD, not * AMD), and exact-degree recomputation. * * Determinism: the order is a pure function of the input pattern — no * randomness, no recursion; all workspaces are typed arrays sized once per * call. Index tie-breaks are bucket-local, not global: the initial degree * lists are linked in descending index order so bucket heads start lowest, * L_p is sorted ascending before it is scanned, hash chains are built * ascending so the representative of an indistinguishable set is always its * lowest index, and each pivot's update relinks in descending index order so * the lowest just-updated index surfaces first. Degree buckets are LIFO, * though, so a freshly relinked vertex sits ahead of untouched vertices of * equal degree regardless of index — the O(1) head insertion the reference * implementation also uses. Which of two equal-degree pivots goes first is * an ordering-quality heuristic either way; validity never depends on it. */ /** * Compute an AMD elimination order for the symmetric pattern given as a * deduplicated adjacency structure WITHOUT self-edges (CSR over vertices; * the caller symmetrises A + A^T and strips the diagonal). * * Returns `order` with order[k] = vertex eliminated at step k (bijective). * The permutation postcondition is checked on every call and violations * throw: a non-bijective order would silently scramble the factorization * coordinate system downstream, and the O(n) check is negligible next to * the ordering work itself (same rationale as SparseMNA's own guard). */ export declare function amdOrder(n: number, adjPtr: Int32Array, adjIdx: Int32Array): Int32Array;