Contracting two supervertices #
Contraction of a weighted multigraph W : Fin (m + 1) → Fin (m + 1) → ℕ
(Cslib.WeightedCut.IsMultigraph) along a pair of distinct supervertices u ≠ v, keeping the
supervertices as Fin m. Merging v into u (mergePair) redirects the edges at v to u and
drops the edges between them. Swap-compaction (embedCompact, compactIdx) then moves the last
supervertex Fin.last m into the freed slot v, so that a contraction step on m + 1 active
supervertices only touches rows and columns 0, …, m, as in the O(n)-time matrix update of
Karger and Stein, Section 3.2. The contracted matrix is contractMatrix W u v,
the updated map from the original vertices to supervertices is contractPart part u v huv, and a
cut of Fin (m + 1) that does not separate u and v becomes the cut contractCut v B of
Fin m.
Contraction preserves Cslib.WeightedCut.IsContractionOf (isContractionOf_contract), so pulled
back cuts keep their weight, and a cut that does not separate u and v keeps its weight
(cutWeight_contractCut). The randomized algorithms of Karger and Karger–Stein
(CslibFrontier.Algorithms.Karger.Graph) and the deterministic Stoer–Wagner algorithm
(CslibFrontier.Algorithms.Lean.StoerWagner.Basic) are built on this API.
Main definitions #
Cslib.WeightedCut.mergePair: the weight matrix after mergingvintou.Cslib.WeightedCut.embedCompact,Cslib.WeightedCut.compactIdx: swap-compaction of the slots other thanv, and its inverse.Cslib.WeightedCut.contractMatrix,Cslib.WeightedCut.contractPart,Cslib.WeightedCut.contractCut: the contracted matrix, supervertex map and cut.
Main results #
Cslib.WeightedCut.isMultigraph_contractMatrix: the contracted matrix is a multigraph.Cslib.WeightedCut.rowDeg_contractMatrix,Cslib.WeightedCut.totalDoubledWeight_contractMatrix: degrees after contraction; the total doubled weight drops by2 * W u v.Cslib.WeightedCut.isContractionOf_contract: contracting a distinct pair(u, v)and swap-compacting the last active slot preservesCslib.WeightedCut.IsContractionOf.Cslib.WeightedCut.pullbackCut_contractCut,Cslib.WeightedCut.cutWeight_contractCut: a cut that does not separateuandvpulls back to the same set, with the same weight.Cslib.WeightedCut.pullbackCut_id: pulling a cut back along the identity gives the same cut.
References #
Merging (mergePair) and swap-compaction (embedCompact / contractMatrix) #
Inverse of embedCompact v on {a : Fin (m + 1) // a ≠ v}.
Instances For
Pulling a cut back along the identity gives the same cut.