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 #
Cslib.Algorithms.WordRAM.StoerWagner.workspaceBound: word-address bound covering allO(n²)input, workspace, and output addresses.Cslib.Algorithms.WordRAM.StoerWagner.StoerWagnerInput: documented weighted-multigraph input record carryingn,W, andisMultigraph.Cslib.Algorithms.WordRAM.StoerWagner.StoerWagnerInput.encode: flat Word-RAM input word listI.n :: Karger.flattenMatrix I.W.Cslib.Algorithms.WordRAM.StoerWagner.StoerWagnerInput.wordBound: polynomial word-value and address boundmax (workspaceBound I.n) (totalDoubledWeight I.W)(required to satisfyFits w I.wordBound, i.e.,I.wordBound < 2 ^ w).Cslib.Algorithms.WordRAM.StoerWagner.StoerWagnerInput.expectedOutput: expected output word list consisting of(stoerWagner I.W).weightfollowed by the0/1indicator of(stoerWagner I.W).side.
Main results #
Cslib.Algorithms.WordRAM.StoerWagner.StoerWagnerInput.inputFits_encode: every word width fittingI.wordBoundsatisfiesInputFits w I.encode.Cslib.Algorithms.WordRAM.StoerWagner.StoerWagnerInput.expectedOutput_spec: for2 ≤ I.n, decodingI.expectedOutputyields lengthI.n + 1, head wordminCut I.W, and a non-trivial global minimum cut ofI.WachievingminCut I.W.Cslib.Algorithms.WordRAM.StoerWagner.exists_stoerWagner_program: uniformO(n³)width-blind standard-basis Word-RAM program (Program.ComputesListInTime) computingI.expectedOutputinC * (I.n + 1) ^ 3instructions at every word widthwwithFits w I.wordBound.
References #
Public input, output, and word-value bound interface #
Every word width fitting I.wordBound satisfies InputFits w I.encode.
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.