Documentation

CslibFrontier.Algorithms.WordRAM.StoerWagner

Deterministic Stoer–Wagner global minimum cut on the Word-RAM (O(n³)) #

This module implements the dense O(n³) array version of the Stoer–Wagner deterministic global minimum cut algorithm [SW97] on the deterministic width-blind standard-basis Word-RAM (Cslib.WordRAM.Basis.standard, ¬prog.ReadsWidth), proving a uniform C * (I.n + 1) ^ 3 instruction-count bound (Program.ComputesListInTime) at any word width w satisfying Fits w I.wordBound (i.e., I.wordBound < 2 ^ w, where I.wordBound is a polynomial bound on word values and addresses, so a bit width w of order log (I.n + 2) + log (totalDoubledWeight I.W + 2) suffices).

On input I.encode = I.n :: Karger.flattenMatrix I.W for any weighted multigraph I : StoerWagnerInput (I.isMultigraph : Cslib.WeightedCut.IsMultigraph I.W), the algorithm maintains the active m × m contracted weight matrix in-place with stride n, the supervertex assignment array part : Fin n → Fin m, maximum-adjacency-search key/visited arrays, and the best cut buffer directly in the output list layout [n + 1, bestWeight, bestSide[0], …, bestSide[n - 1]]. Across all n - 1 contraction phases, totalDoubledWeight is nonincreasing (Cslib.WeightedCut.totalDoubledWeight_contractMatrix), so every intermediate matrix entry, merged edge sum W s j + W t j, attachment key, and cut weight stays at most totalDoubledWeight I.W. Any word width w with Fits w I.wordBound, where I.wordBound = max (workspaceBound I.n) (totalDoubledWeight I.W) bounds all word values and addresses (I.wordBound < 2 ^ w), therefore executes without overflow.

The dense O(n³) array Word-RAM program and word-value/address bound are original over [SW97] (which states the algorithm at the high level using a priority queue in O(n m + n² log n) time).

Main definitions #

Main results #

References #

Public input, output, and word-value bound interface #

Word-address bound covering the input list, mutable n × n matrix workspace, part/key/ used arrays, and the (n + 2)-word output buffer.

Weighted multigraph input on Fin n for Word-RAM Stoer–Wagner global minimum cut.

  • n : ℕ

    Number of vertices.

  • W : Fin self.n → Fin self.n → ℕ

    Nonnegative symmetric zero-diagonal edge-weight matrix.

  • isMultigraph : WeightedCut.IsMultigraph self.W

    Symmetry and zero-diagonal witness (IsMultigraph W).

Flat Word-RAM input encoding I.n :: Karger.flattenMatrix I.W.

Polynomial word-value and address bound max (workspaceBound I.n) (totalDoubledWeight I.W) (requiring Fits w I.wordBound, i.e., I.wordBound < 2 ^ w).

Expected list output [weight, bit₀, …, bitₙ₋₁] of stoerWagner I.W, where bitᵥ = 1 iff v ∈ (stoerWagner I.W).side.

For every multigraph with 2 ≤ I.n, the output word list I.expectedOutput has length I.n + 1, its head word is minCut I.W, and decoding the 1-bits at positions 1, …, I.n recovers a non-trivial global minimum cut of I.W achieving weight minCut I.W.

Local Memory.Prog simplification #

Pure combinatorics and maSearch / run bridges #

Workspace address layout #

Primitive array loops (copyWordsProg, initPartProg, initMAProg, writeSideProg) #

Maximum adjacency search (maPickMaxProg, maUpdateKeysProg, maOrderProg) #

In-place matrix contraction (mergeRowColProg, compactRowColProg, contractPartProg) #

Phase loop (phaseStep) and main program (stoerWagnerProg) #

Phase invariant and end-to-end correctness #

Main O(n³) Word-RAM running-time theorem #

Stoer–Wagner global minimum cut on the Word-RAM (O(n³)): There is a single uniform deterministic width-blind standard-basis Word-RAM program (Program .standard r, ¬prog.ReadsWidth) that, on input I.encode = I.n :: Karger.flattenMatrix I.W for any weighted multigraph I : StoerWagnerInput at any word width w satisfying Fits w I.wordBound (i.e., I.wordBound < 2 ^ w, where I.wordBound = max (workspaceBound I.n) (totalDoubledWeight I.W) bounds all word values and addresses, so a bit width w of order log (I.n + 2) + log (totalDoubledWeight I.W + 2) suffices), outputs I.expectedOutput within C * (I.n + 1) ^ 3 instructions (Program.ComputesListInTime). For all 2 ≤ I.n, StoerWagnerInput.expectedOutput_spec identifies this output with a non-trivial global minimum cut and its weight minCut I.W.