Documentation

CslibFrontier.Algorithms.Lean.SteinerTree.Graph

Steiner tree in graphs: the metric completion and the Kou–Markowsky–Berman heuristic #

This module carries the MST 2-approximation of CslibFrontier.Algorithms.Lean.SteinerTree.Metric over to Steiner tree in an edge-weighted graph, whose costs need not satisfy the triangle inequality ([WS11], Exercise 2.5(b)). The algorithm computes a minimum spanning tree on the terminals under shortest-path distances (the metric completion), and then replaces each tree edge by the edges of a shortest walk. This is steps 1–3 of the heuristic of Kou, Markowsky and Berman [KMB81].

Model #

Source mapping #

Main definitions #

Main results #

References #

Walk costs and the metric completion #

def Cslib.Algorithms.Lean.SteinerTree.walkWeight {V : Type u_1} {G : SimpleGraph V} (w : Sym2 V → ℕ) {u v : V} (p : G.Walk u v) :

The cost of a walk: the sum of the weights of its edges, with multiplicity.

theorem Cslib.Algorithms.Lean.SteinerTree.walkWeight_reverse {V : Type u_1} {G : SimpleGraph V} (w : Sym2 V → ℕ) {u v : V} (p : G.Walk u v) :
theorem Cslib.Algorithms.Lean.SteinerTree.walkWeight_append {V : Type u_1} {G : SimpleGraph V} (w : Sym2 V → ℕ) {u v x : V} (p : G.Walk u v) (q : G.Walk v x) :
noncomputable def Cslib.Algorithms.Lean.SteinerTree.metricCompletion {V : Type u_1} (w : Sym2 V → ℕ) (G : SimpleGraph V) (u v : V) :

The metric completion of G: the least cost of a walk from u to v. It is 0 when there is no such walk.

def Cslib.Algorithms.Lean.SteinerTree.IsShortestWalkOracle {V : Type u_1} (w : Sym2 V → ℕ) (G : SimpleGraph V) (P : (u v : V) → G.Walk u v) :

P chooses a shortest walk between every two vertices.

theorem Cslib.Algorithms.Lean.SteinerTree.exists_isShortestWalkOracle {V : Type u_1} {G : SimpleGraph V} (w : Sym2 V → ℕ) (hG : G.Preconnected) :
∃ (P : (u v : V) → G.Walk u v), IsShortestWalkOracle w G P

A preconnected graph has a shortest-walk oracle.

theorem Cslib.Algorithms.Lean.SteinerTree.IsShortestWalkOracle.walkWeight_eq {V : Type u_1} {G : SimpleGraph V} {w : Sym2 V → ℕ} {P : (u v : V) → G.Walk u v} (hP : IsShortestWalkOracle w G P) (u v : V) :
walkWeight w (P u v) = metricCompletion w G u v

A shortest-walk oracle computes the metric completion.

theorem Cslib.Algorithms.Lean.SteinerTree.IsShortestWalkOracle.symm {V : Type u_1} {G : SimpleGraph V} {w : Sym2 V → ℕ} {P : (u v : V) → G.Walk u v} (hP : IsShortestWalkOracle w G P) (u v : V) :
walkWeight w (P u v) = walkWeight w (P v u)
theorem Cslib.Algorithms.Lean.SteinerTree.IsShortestWalkOracle.triangle {V : Type u_1} {G : SimpleGraph V} {w : Sym2 V → ℕ} {P : (u v : V) → G.Walk u v} (hP : IsShortestWalkOracle w G P) (x y z : V) :
walkWeight w (P x z) ≤ walkWeight w (P x y) + walkWeight w (P y z)
theorem Cslib.Algorithms.Lean.SteinerTree.IsShortestWalkOracle.walkWeight_self {V : Type u_1} {G : SimpleGraph V} {w : Sym2 V → ℕ} {P : (u v : V) → G.Walk u v} (hP : IsShortestWalkOracle w G P) (x : V) :
walkWeight w (P x x) = 0
theorem Cslib.Algorithms.Lean.SteinerTree.IsShortestWalkOracle.le_of_adj {V : Type u_1} {G : SimpleGraph V} {w : Sym2 V → ℕ} {P : (u v : V) → G.Walk u v} (hP : IsShortestWalkOracle w G P) {u v : V} (h : G.Adj u v) :
walkWeight w (P u v) ≤ w s(u, v)

The problem #

F is a set of edges of G whose spanning subgraph connects every two terminals.

noncomputable def Cslib.Algorithms.Lean.SteinerTree.graphSteinerOpt {V : Type u_1} (w : Sym2 V → ℕ) (G : SimpleGraph V) (R : List V) :

The optimum graph Steiner cost: the least weight of a Steiner subgraph (0 if there is none).

theorem Cslib.Algorithms.Lean.SteinerTree.graphSteinerOpt_le {V : Type u_1} {G : SimpleGraph V} {w : Sym2 V → ℕ} {R : List V} {F : Finset (Sym2 V)} (hF : IsSteinerSubgraph G R F) :

Expanding pairs into walks #

def Cslib.Algorithms.Lean.SteinerTree.expandEdges {V : Type u_1} {G : SimpleGraph V} [DecidableEq V] (P : (u v : V) → G.Walk u v) (T : List (V × V)) :

The edges of the walks P u v for the pairs (u, v) of T.

theorem Cslib.Algorithms.Lean.SteinerTree.expandEdges_subset {V : Type u_1} {G : SimpleGraph V} [DecidableEq V] (P : (u v : V) → G.Walk u v) (T : List (V × V)) :
↑(expandEdges P T) ⊆ G.edgeSet
theorem Cslib.Algorithms.Lean.SteinerTree.reachable_expandEdges {V : Type u_1} {G : SimpleGraph V} [DecidableEq V] (P : (u v : V) → G.Walk u v) {T : List (V × V)} {a b : V} (h : Relation.EqvGen (fun (x y : V) => (x, y) ∈ T) a b) :

Pairs related by T are connected through the expanded edges.

theorem Cslib.Algorithms.Lean.SteinerTree.sum_expandEdges_le {V : Type u_1} {G : SimpleGraph V} {w : Sym2 V → ℕ} [DecidableEq V] (P : (u v : V) → G.Walk u v) (T : List (V × V)) :
(expandEdges P T).sum w ≤ edgeCost (fun (u v : V) => walkWeight w (P u v)) T

The expanded edges cost at most the walks: shared edges are paid for once.

From edge sets to pair lists #

The Kou–Markowsky–Berman heuristic #

def Cslib.Algorithms.Lean.SteinerTree.kmbEdges {V : Type u_1} {G : SimpleGraph V} [DecidableEq V] (w : Sym2 V → ℕ) (P : (u v : V) → G.Walk u v) (R : List V) :

The Kou–Markowsky–Berman heuristic, steps 1–3: the MST heuristic on the terminals under the shortest-walk costs of P, with each tree edge replaced by the edges of its shortest walk.

theorem Cslib.Algorithms.Lean.SteinerTree.kmbEdges_eq {V : Type u_1} {G : SimpleGraph V} {w : Sym2 V → ℕ} [DecidableEq V] {P : (u v : V) → G.Walk u v} (hP : IsShortestWalkOracle w G P) (R : List V) :

For a shortest-walk oracle, the tree in kmbEdges is the MST heuristic in the metric completion.

theorem Cslib.Algorithms.Lean.SteinerTree.isSteinerSubgraph_kmbEdges {V : Type u_1} {G : SimpleGraph V} {w : Sym2 V → ℕ} [DecidableEq V] (P : (u v : V) → G.Walk u v) (R : List V) :

The heuristic returns a Steiner subgraph.

theorem Cslib.Algorithms.Lean.SteinerTree.length_mul_sum_kmbEdges_le {V : Type u_1} {G : SimpleGraph V} {w : Sym2 V → ℕ} [DecidableEq V] {P : (u v : V) → G.Walk u v} (hP : IsShortestWalkOracle w G P) (R : List V) {F : Finset (Sym2 V)} (hF : IsSteinerSubgraph G R F) :
R.length * (kmbEdges w P R).sum w ≤ 2 * (R.length - 1) * F.sum w

The Kou–Markowsky–Berman heuristic, sharp form: for a shortest-walk oracle, |R| · cost(kmbEdges) ≤ 2 (|R| - 1) · cost(F) for every Steiner subgraph F. This is the factor 2 (1 - 1/|R|), a restricted form of [KMB81]'s 2 (1 - 1/ℓ) with ℓ the number of leaves of an optimal tree.

theorem Cslib.Algorithms.Lean.SteinerTree.sum_kmbEdges_le_two_mul {V : Type u_1} {G : SimpleGraph V} {w : Sym2 V → ℕ} [DecidableEq V] {P : (u v : V) → G.Walk u v} (hP : IsShortestWalkOracle w G P) (R : List V) {F : Finset (Sym2 V)} (hF : IsSteinerSubgraph G R F) :
(kmbEdges w P R).sum w ≤ 2 * F.sum w

The heuristic costs at most twice any Steiner subgraph.

theorem Cslib.Algorithms.Lean.SteinerTree.exists_isSteinerSubgraph_sum_eq_graphSteinerOpt {V : Type u_1} {G : SimpleGraph V} {w : Sym2 V → ℕ} (P : (u v : V) → G.Walk u v) (R : List V) :
∃ (F : Finset (Sym2 V)), IsSteinerSubgraph G R F ∧ F.sum w = graphSteinerOpt w G R

If G has walks between all pairs of vertices, the optimum is attained.

theorem Cslib.Algorithms.Lean.SteinerTree.sum_kmbEdges_le_two_mul_graphSteinerOpt {V : Type u_1} {G : SimpleGraph V} {w : Sym2 V → ℕ} [DecidableEq V] {P : (u v : V) → G.Walk u v} (hP : IsShortestWalkOracle w G P) (R : List V) :
(kmbEdges w P R).sum w ≤ 2 * graphSteinerOpt w G R

The metric-completion MST 2-approximation for Steiner tree in graphs ([WS11], Exercise 2.5(b)): cost(kmbEdges) ≤ 2 · OPT.