Documentation

CslibFrontier.Algorithms.Karger.Graph

Supervertex contractions and Karger's survival bounds #

Combinatorial and probabilistic core for Karger's randomized contraction algorithm [Karger1993] and the Karger–Stein recursive algorithm [KargerStein1996] on n-vertex weighted undirected multigraphs represented as symmetric zero-diagonal adjacency matrices W : Fin n → Fin n → ℕ. Multigraphs, cut weights, global minimum cuts and contractions along supervertex maps are the general notions of CslibFrontier.Foundations.Combinatorics.WeightedCut (Cslib.WeightedCut), and the swap-compacted contraction of one pair of supervertices (mergePair, embedCompact, contractMatrix, contractPart) is CslibFrontier.Foundations.Combinatorics.WeightedCut.Contraction; this module adds edge-weight-proportional sampling and the survival bounds. Nothing here refers to a machine: the word-RAM programs (CslibFrontier.Algorithms.WordRAM.Karger.Contract, CslibFrontier.Algorithms.WordRAM.KargerMinCut) store the matrix in row-major order (Cslib.Algorithms.WordRAM.Karger.flattenMatrix) and import these facts.

Source statements and notation mapping #

Main definitions #

Main results #

References #

Prefix-sum edge-proportional sampling on Fin S #

def Cslib.Algorithms.Karger.degBefore {k : ℕ} (W : Fin k → Fin k → ℕ) (u : Fin k) :

Sum of rowDeg W a over all a < u.

Instances For
    def Cslib.Algorithms.Karger.weightBefore {k : ℕ} (W : Fin k → Fin k → ℕ) (u v : Fin k) :

    Sum of W u b over all b < v.

    Instances For
      def Cslib.Algorithms.Karger.edgeOffset {k : ℕ} (W : Fin k → Fin k → ℕ) (u v : Fin k) :

      Flattened prefix-sum start offset of directed edge slot (u, v) inside [0, S).

      Instances For
        theorem Cslib.Algorithms.Karger.weightBefore_le_of_lt {k : ℕ} (W : Fin k → Fin k → ℕ) (u : Fin k) {v₁ v₂ : Fin k} (hlt : v₁ < v₂) :
        weightBefore W u v₁ + W u v₁ ≤ weightBefore W u v₂
        theorem Cslib.Algorithms.Karger.degBefore_le_of_lt {k : ℕ} (W : Fin k → Fin k → ℕ) {u₁ u₂ : Fin k} (hlt : u₁ < u₂) :
        def Cslib.Algorithms.Karger.IsSampledPair {k : ℕ} (W : Fin k → Fin k → ℕ) (r : ℕ) (u v : Fin k) :

        IsSampledPair W r u v holds when sample r falls inside the half-open interval [edgeOffset W u v, edgeOffset W u v + W u v).

        Instances For
          @[instance_reducible]
          instance Cslib.Algorithms.Karger.instDecidableIsSampledPair {k : ℕ} (W : Fin k → Fin k → ℕ) (r : ℕ) (u v : Fin k) :
          theorem Cslib.Algorithms.Karger.isSampledPair_ne {k : ℕ} {W : Fin k → Fin k → ℕ} (hW : WeightedCut.IsMultigraph W) {r : ℕ} {u v : Fin k} (h : IsSampledPair W r u v) :
          u ≠ v
          theorem Cslib.Algorithms.Karger.isSampledPair_unique {k : ℕ} (W : Fin k → Fin k → ℕ) {r : ℕ} {u₁ v₁ u₂ v₂ : Fin k} (h₁ : IsSampledPair W r u₁ v₁) (h₂ : IsSampledPair W r u₂ v₂) :
          u₁ = u₂ ∧ v₁ = v₂
          theorem Cslib.Algorithms.Karger.exists_isSampledPair {k : ℕ} (W : Fin k → Fin k → ℕ) {r : ℕ} (hr : r < WeightedCut.totalDoubledWeight W) :
          ∃ (u : Fin k) (v : Fin k), IsSampledPair W r u v
          theorem Cslib.Algorithms.Karger.card_sampledPair_fiber {k : ℕ} (W : Fin k → Fin k → ℕ) (u v : Fin k) :
          {r : Fin (WeightedCut.totalDoubledWeight W) | IsSampledPair W (↑r) u v}.card = W u v

          Event on Fin (totalDoubledWeight W) where the edge sampled at r keeps both endpoints on the same side of B.

          Instances For
            @[instance_reducible]
            theorem Cslib.Algorithms.Karger.not_sampleSurvives_iff_crosses {k : ℕ} (W : Fin k → Fin k → ℕ) (B : Finset (Fin k)) (r : Fin (WeightedCut.totalDoubledWeight W)) :
            ¬SampleSurvives W B r ↔ ∃ (u : Fin k) (v : Fin k), IsSampledPair W (↑r) u v ∧ ¬(u ∈ B ↔ v ∈ B)

            One-step survival probability lower bound: if k ≥ 2, 0 < totalDoubledWeight W, and k * cutWeight W B ≤ totalDoubledWeight W, then a uniform sample r : Fin (totalDoubledWeight W) satisfies SampleSurvives W B r with probability at least (k - 2) / k.

            Telescoping and Bernoulli amplification #

            theorem Cslib.Algorithms.Karger.ennreal_div_pow (a b : ENNReal) (m : ℕ) :
            (a / b) ^ m = a ^ m / b ^ m

            Power of a quotient in ℝ≥0∞: (a / b) ^ m = a ^ m / b ^ m.

            theorem Cslib.Algorithms.Karger.telescope_survival_step {t m : ℕ} (ht : 2 ≤ t) (htm : t ≤ m) :
            ↑(m - 1) / ↑(m + 1) * (↑(t * (t - 1)) / ↑(m * (m - 1))) = ↑(t * (t - 1)) / ↑((m + 1) * m)

            Telescoping cancellation step for contractDownTo survival probability from m + 1 down to t (2 ≤ t ≤ m): ((m - 1) / (m + 1)) * (t * (t - 1) / (m * (m - 1))) = t * (t - 1) / ((m + 1) * m).

            theorem Cslib.Algorithms.Karger.one_sub_two_div_pairs_eq {n : ℕ} (hn : 2 ≤ n) :
            1 - 2 / ↑(n * (n - 1)) = ↑(n * (n - 1) / 2 - 1) / ↑(n * (n - 1) / 2)
            theorem Cslib.Algorithms.Karger.one_sub_two_div_pow_pairs_le_half {n : ℕ} (hn : 2 ≤ n) :
            (1 - 2 / ↑(n * (n - 1))) ^ (n * (n - 1) / 2) ≤ 1 / 2

            Elementary high-probability trial count (n * (n - 1) / 2) * (Nat.log 2 n + 2) for Basic Karger amplification.

            Instances For
              theorem Cslib.Algorithms.Karger.highProb_failure_le {n : ℕ} (hn : 2 ≤ n) :
              (1 - 2 / ↑(n * (n - 1))) ^ highProbTrials n ≤ 1 / ↑(2 * n)

              Elementary failure probability bound for highProbTrials n independent contractions: (1 - 2 / (n * (n - 1))) ^ ((n * (n - 1) / 2) * (Nat.log 2 n + 2)) ≤ 1 / (2 * n).

              theorem Cslib.Algorithms.Karger.highProb_failure_le_inv_n {n : ℕ} (hn : 2 ≤ n) :
              (1 - 2 / ↑(n * (n - 1))) ^ highProbTrials n ≤ 1 / ↑n