Documentation

CslibFrontier.Foundations.Combinatorics.Multigraph.MinimumSpanningForest

Minimum spanning forests of multigraphs #

For a multigraph ends : E → Sym2 V (parallel edges and self-loops allowed), a finite set S : Finset E of its edges and weights w : E → W in a linear order, the minimum spanning forest Cslib.Multigraph.msf ends w S consists of the edges e ∈ S whose ends are not joined by the edges of S strictly lighter than e. A self-loop is never in it. With distinct weights this is the usual minimum spanning forest: it is a spanning forest of S (Cslib.Multigraph.isSpanningForest_msf) of least total weight among all spanning forests of S (Cslib.Multigraph.sum_msf_le).

Edges are joined along walks: Cslib.Multigraph.Joins ends S u v says that u and v are joined by edges of S, that is, are reachable from each other in the multigraph restricted to S (Cslib.Multigraph.joins_iff_reachable). An edge e is supported by a set F of edges when the edges of F of weight at most w e join its ends (Cslib.Multigraph.Supported).

The module proves, in this setting, the standard facts of §2 of Khanna, Putterman and Song (the paper's Facts 2.2–2.4, p. 11, and Fact 2.5, p. 12) and the filtering identity behind line 8 of their Algorithm 2 (§4, p. 25). These are steps in the proof of their Theorem 4.1 (§4, p. 25), tracked in #8325, and the paper's numbers are kept as pointers. Distinct weights are assumed, as in the paper, through Function.Injective w, and only where needed: the cut and cycle properties, threshold connectivity and the first filtering lemma hold for all weights.

The contraction property is stated without changing the vertex type: contracting a set C of edges is the vertex map q that identifies exactly the vertices joined by C, and the contracted multigraph is Sym2.map q ∘ ends on the same edges. Cslib.Multigraph.contract is one such map.

Main definitions #

Main results #

References #

Vertices joined by a set of edges #

def Cslib.Multigraph.Joins {V : Type u_1} {E : Type u_3} (ends : E → Sym2 V) (S : Set E) :
V → V → Prop

Joins ends S u v: the vertices u and v are joined by a walk along edges of S. Every vertex is joined to itself, by the empty walk.

theorem Cslib.Multigraph.Joins.refl {V : Type u_1} {E : Type u_3} {ends : E → Sym2 V} {S : Set E} (u : V) :
Joins ends S u u
theorem Cslib.Multigraph.Joins.of_mem {V : Type u_1} {E : Type u_3} {ends : E → Sym2 V} {S : Set E} {u v : V} {e : E} (he : e ∈ S) (h : ends e = s(u, v)) :
Joins ends S u v

An edge of S joins its ends.

theorem Cslib.Multigraph.Joins.symm {V : Type u_1} {E : Type u_3} {ends : E → Sym2 V} {S : Set E} {u v : V} (h : Joins ends S u v) :
Joins ends S v u
theorem Cslib.Multigraph.Joins.trans {V : Type u_1} {E : Type u_3} {ends : E → Sym2 V} {S : Set E} {u v x : V} (h₁ : Joins ends S u v) (h₂ : Joins ends S v x) :
Joins ends S u x
theorem Cslib.Multigraph.Joins.equivalence {V : Type u_1} {E : Type u_3} {ends : E → Sym2 V} {S : Set E} :

Joins ends S is an equivalence relation.

theorem Cslib.Multigraph.Joins.lift {V : Type u_1} {V' : Type u_2} {E : Type u_3} {ends : E → Sym2 V} {S : Set E} {u v : V} {E' : Type u_5} {ends' : E' → Sym2 V'} {T : Set E'} (f : V → V') (hf : ∀ e ∈ S, ∀ (a b : V), ends e = s(a, b) → Joins ends' T (f a) (f b)) (h : Joins ends S u v) :
Joins ends' T (f u) (f v)

Walks are carried along a vertex map f that sends the ends of every edge of S to vertices joined by T in a multigraph ends'.

theorem Cslib.Multigraph.Joins.of_forall {V : Type u_1} {E : Type u_3} {ends : E → Sym2 V} {S T : Set E} {u v : V} (hf : ∀ e ∈ S, ∀ (a b : V), ends e = s(a, b) → Joins ends T a b) (h : Joins ends S u v) :
Joins ends T u v

If the ends of every edge of S are joined by T, then so is everything joined by S.

theorem Cslib.Multigraph.Joins.mono {V : Type u_1} {E : Type u_3} {ends : E → Sym2 V} {S T : Set E} {u v : V} (hST : S ⊆ T) (h : Joins ends S u v) :
Joins ends T u v
theorem Cslib.Multigraph.Joins.exists_mem_edgeCut {V : Type u_1} {E : Type u_3} {ends : E → Sym2 V} {S : Set E} {u v : V} {P : Set V} (h : Joins ends S u v) (hu : u ∈ P) (hv : v ∉ P) :
∃ e ∈ S, e ∈ (toGraph ends).edgeCut P

A walk from inside a set of vertices to outside it uses an edge leaving the set.

@[simp]
theorem Cslib.Multigraph.joins_empty_iff {V : Type u_1} {E : Type u_3} {ends : E → Sym2 V} {u v : V} :
Joins ends ∅ u v ↔ u = v

No edges join only each vertex to itself.

theorem Cslib.Multigraph.joins_insert_iff {V : Type u_1} {E : Type u_3} {ends : E → Sym2 V} {S : Set E} {e : E} {u v : V} :
Joins ends (insert e S) u v ↔ Joins ends S u v ∨ ∃ (x : V) (y : V), ends e = s(x, y) ∧ Joins ends S u x ∧ Joins ends S y v

The vertices joined by insert e S are those joined by S, and those joined by S to the two ends of e.

theorem Cslib.Multigraph.joins_iff_reachable {V : Type u_1} {E : Type u_3} {ends : E → Sym2 V} {S : Set E} {u v : V} :
Joins ends S u v ↔ (toSimpleGraph fun (e : ↑S) => ends ↑e).Reachable u v

Joins is reachability: u and v are joined by edges of S exactly when they are reachable from each other in the simple graph underlying the multigraph restricted to S.

Non-isolated vertices #

noncomputable def Cslib.Multigraph.support {V : Type u_1} {E : Type u_3} (ends : E → Sym2 V) (S : Finset E) :

The non-isolated vertices of the edges S: the ends of the edges of S other than self-loops.

theorem Cslib.Multigraph.mem_support {V : Type u_1} {E : Type u_3} {ends : E → Sym2 V} {S : Finset E} {v : V} :
v ∈ support ends S ↔ ∃ e ∈ S, ¬(ends e).IsDiag ∧ v ∈ ends e
theorem Cslib.Multigraph.sum_card_incident_le {V : Type u_1} {E : Type u_3} [DecidableEq V] (ends : E → Sym2 V) (S : Finset E) (X : Finset V) :
∑ v ∈ X, {e ∈ S | v ∈ ends e}.card ≤ 2 * S.card

Degree sum: every edge has at most two ends, so the numbers of edges of S at the vertices of any X add up to at most 2 |S|. A self-loop counts once at its vertex.

Contraction #

theorem Cslib.Multigraph.joins_map_iff {V : Type u_1} {V' : Type u_2} {E : Type u_3} {ends : E → Sym2 V} {q : V → V'} {C T : Set E} (hq : ∀ (u v : V), q u = q v ↔ Joins ends C u v) {u v : V} :
Joins (Sym2.map q ∘ ends) T (q u) (q v) ↔ Joins ends (T ∪ C) u v

Contracted walks. Let q identify exactly the vertices joined by C. Then vertices are joined by T in the contracted multigraph Sym2.map q ∘ ends exactly when their preimages are joined by T ∪ C.

noncomputable def Cslib.Multigraph.contract {V : Type u_1} {E : Type u_3} (ends : E → Sym2 V) (C : Set E) (u : V) :
V

A vertex map identifying exactly the vertices joined by C: each vertex goes to a chosen representative of its class, a vertex of the same type.

theorem Cslib.Multigraph.contract_eq_contract_iff {V : Type u_1} {E : Type u_3} {ends : E → Sym2 V} {C : Set E} {u v : V} :
contract ends C u = contract ends C v ↔ Joins ends C u v

Minimum spanning forests #

noncomputable def Cslib.Multigraph.msf {V : Type u_1} {E : Type u_3} {W : Type u_4} [LinearOrder W] (ends : E → Sym2 V) (w : E → W) (S : Finset E) :

The minimum spanning forest of the edges S: the edges e ∈ S whose ends are not joined by the edges of S strictly lighter than e. A self-loop is never in it. The paper defines the minimum spanning forest only for distinct weights (§2, p. 11), and for injective w this set is it (Cslib.Multigraph.isSpanningForest_msf, Cslib.Multigraph.sum_msf_le). With ties it need not be a forest: two parallel edges of equal weight are both in it.

theorem Cslib.Multigraph.mem_msf_iff {V : Type u_1} {E : Type u_3} {W : Type u_4} {ends : E → Sym2 V} [LinearOrder W] (w : E → W) {S : Finset E} {e : E} {a b : V} (h : ends e = s(a, b)) :
e ∈ msf ends w S ↔ e ∈ S ∧ ¬Joins ends {f : E | f ∈ S ∧ w f < w e} a b

An edge with ends a and b is in msf S exactly when it is in S and a and b are not joined by the strictly lighter edges of S.

theorem Cslib.Multigraph.msf_subset {V : Type u_1} {E : Type u_3} {W : Type u_4} {ends : E → Sym2 V} [LinearOrder W] (w : E → W) {S : Finset E} :
msf ends w S ⊆ S
theorem Cslib.Multigraph.notMem_msf_of_isDiag {V : Type u_1} {E : Type u_3} {W : Type u_4} {ends : E → Sym2 V} [LinearOrder W] (w : E → W) {S : Finset E} {e : E} (he : (ends e).IsDiag) :
e ∉ msf ends w S

A self-loop is never in msf S.

theorem Cslib.Multigraph.notMem_msf_of_joins {V : Type u_1} {E : Type u_3} {W : Type u_4} {ends : E → Sym2 V} [LinearOrder W] (w : E → W) {S : Finset E} {e : E} {X : Set E} (hX : X ⊆ ↑S) (hlt : ∀ f ∈ X, w f < w e) {a b : V} (h : ends e = s(a, b)) (hj : Joins ends X a b) :
e ∉ msf ends w S

Cycle property, a step in the proof of Theorem 4.1 of [KPS26] (the paper's Fact 2.3, §2, p. 11): an edge whose ends are joined by edges of S strictly lighter than it is not in msf S.

theorem Cslib.Multigraph.mem_msf_of_mem_edgeCut {V : Type u_1} {E : Type u_3} {W : Type u_4} {ends : E → Sym2 V} [LinearOrder W] (w : E → W) {S : Finset E} {P : Set V} {e : E} (he : e ∈ S) (hcut : e ∈ (toGraph ends).edgeCut P) (hmin : ∀ f ∈ S, f ∈ (toGraph ends).edgeCut P → w e ≤ w f) :
e ∈ msf ends w S

Cut property, a step in the proof of Theorem 4.1 of [KPS26] (the paper's Fact 2.2, §2, p. 11): an edge of S crossing a cut (P, Pᶜ) that is no heavier than any edge of S crossing it is in msf S.

theorem Cslib.Multigraph.joins_msf_of_mem {V : Type u_1} {E : Type u_3} {W : Type u_4} {ends : E → Sym2 V} [LinearOrder W] (w : E → W) {S : Finset E} {e : E} (he : e ∈ S) {a b : V} (h : ends e = s(a, b)) :
Joins ends {f : E | f ∈ msf ends w S ∧ w f ≤ w e} a b

Every edge of S has its ends joined by the edges of msf S that are no heavier.

theorem Cslib.Multigraph.joins_msf_of_joins {V : Type u_1} {E : Type u_3} {W : Type u_4} {ends : E → Sym2 V} [LinearOrder W] (w : E → W) {S : Finset E} {X : Set E} (hX : X ⊆ ↑S) {k : W} {u v : V} (h : Joins ends {f : E | f ∈ X ∧ w f ≤ k} u v) :
Joins ends {f : E | f ∈ msf ends w S ∧ w f ≤ k} u v

Threshold connectivity, a step in the proof of Theorem 4.1 of [KPS26] (the paper's Fact 2.5, §2, p. 12): vertices joined by edges of weight at most k from some X ⊆ S are joined by the edges of msf S of weight at most k, for every threshold k.

theorem Cslib.Multigraph.joins_msf_lt_iff {V : Type u_1} {E : Type u_3} {W : Type u_4} {ends : E → Sym2 V} [LinearOrder W] (w : E → W) {S : Finset E} {k : W} {u v : V} :
Joins ends {f : E | f ∈ msf ends w S ∧ w f < k} u v ↔ Joins ends {f : E | f ∈ S ∧ w f < k} u v

msf S also preserves connectivity by the edges strictly lighter than any threshold k.

theorem Cslib.Multigraph.nonempty_of_joins {V : Type u_1} {E : Type u_3} {ends : E → Sym2 V} {T : Finset E} {u v : V} (huv : u ≠ v) (h : Joins ends (↑T) u v) :

Distinct vertices are joined by a set of edges only if the set is nonempty.

theorem Cslib.Multigraph.exists_bottleneck {V : Type u_1} {E : Type u_3} {W : Type u_4} {ends : E → Sym2 V} [LinearOrder W] {w : E → W} {F : Finset E} {u v : V} (huv : u ≠ v) (h : Joins ends (↑F) u v) :
∃ g ∈ F, Joins ends {x : E | x ∈ F ∧ w x ≤ w g} u v ∧ ¬Joins ends {x : E | x ∈ F ∧ w x < w g} u v

Bottleneck edges. Distinct vertices joined by a finite set F of edges have a bottleneck edge g ∈ F: the edges of F of weight at most w g join them and those of weight less than w g do not. With distinct weights it is unique, and when F is acyclic it is the heaviest edge on the path of F between the two vertices. Any weights in a linear order will do.

theorem Cslib.Multigraph.msf_eq_of_subset {V : Type u_1} {E : Type u_3} {W : Type u_4} {ends : E → Sym2 V} [LinearOrder W] (w : E → W) {S S' : Finset E} (h₁ : msf ends w S ⊆ S') (h₂ : S' ⊆ S) :
msf ends w S' = msf ends w S

Filtering: any S' with msf S ⊆ S' ⊆ S has the same minimum spanning forest as S.

theorem Cslib.Multigraph.support_filter_not_isDiag {V : Type u_1} {E : Type u_3} [DecidableEq V] (ends : E → Sym2 V) (S : Finset E) :
support ends ({e ∈ S | ¬(ends e).IsDiag}) = support ends S

Dropping the self-loops does not change the non-isolated vertices.

theorem Cslib.Multigraph.msf_filter_not_isDiag {V : Type u_1} {E : Type u_3} {W : Type u_4} [LinearOrder W] (w : E → W) [DecidableEq V] (ends : E → Sym2 V) (S : Finset E) :
msf ends w ({e ∈ S | ¬(ends e).IsDiag}) = msf ends w S

Dropping the self-loops does not change the minimum spanning forest.

Acyclicity #

def Cslib.Multigraph.IsAcyclic {V : Type u_1} {E : Type u_3} (ends : E → Sym2 V) (F : Set E) :

The set F of edges is acyclic: no edge of F has its ends joined by the other edges of F. A self-loop, or a pair of parallel edges, is a cycle.

theorem Cslib.Multigraph.isAcyclic_iff {V : Type u_1} {E : Type u_3} {ends : E → Sym2 V} {F : Set E} :
IsAcyclic ends F ↔ ∀ e ∈ F, ∀ (a b : V), ends e = s(a, b) → ¬Joins ends (F \ {e}) a b
theorem Cslib.Multigraph.isAcyclic_empty {V : Type u_1} {E : Type u_3} {ends : E → Sym2 V} :
theorem Cslib.Multigraph.IsAcyclic.mono {V : Type u_1} {E : Type u_3} {ends : E → Sym2 V} {F G : Set E} (hG : IsAcyclic ends G) (hFG : F ⊆ G) :
IsAcyclic ends F

A subset of an acyclic set of edges is acyclic.

theorem Cslib.Multigraph.isAcyclic_msf {V : Type u_1} {E : Type u_3} {W : Type u_4} {ends : E → Sym2 V} [LinearOrder W] (w : E → W) {S : Finset E} (hw : Function.Injective w) :
IsAcyclic ends ↑(msf ends w S)

With distinct weights, msf S is acyclic.

theorem Cslib.Multigraph.IsAcyclic.card_le {V : Type u_1} {E : Type u_3} {ends : E → Sym2 V} {F : Finset E} (hF : IsAcyclic ends ↑F) {X : Finset V} (hX : ∀ e ∈ F, ∀ v ∈ ends e, v ∈ X) :
F.card ≤ X.card - 1

An acyclic set of edges whose ends lie in X has at most |X| - 1 edges. Induction on the number of edges: contracting one edge of an acyclic set leaves an acyclic set on one vertex fewer.

theorem Cslib.Multigraph.card_msf_le {V : Type u_1} {E : Type u_3} {W : Type u_4} {ends : E → Sym2 V} [LinearOrder W] (w : E → W) {S : Finset E} (hw : Function.Injective w) {X : Finset V} (hX : ∀ e ∈ S, ∀ v ∈ ends e, v ∈ X) :
(msf ends w S).card ≤ X.card - 1

With distinct weights, msf S has at most |X| - 1 edges when the ends of the edges of S lie in X.

Contraction #

theorem Cslib.Multigraph.msf_eq_union_msf_map {V : Type u_1} {V' : Type u_2} {E : Type u_3} {W : Type u_4} {ends : E → Sym2 V} [LinearOrder W] (w : E → W) {S : Finset E} [DecidableEq E] (hw : Function.Injective w) {C : Finset E} (hC : C ⊆ msf ends w S) {q : V → V'} (hq : ∀ (u v : V), q u = q v ↔ Joins ends (↑C) u v) :
msf ends w S = C ∪ msf (Sym2.map q ∘ ends) w (S \ C)

Contraction property, a step in the proof of Theorem 4.1 of [KPS26] (the paper's Fact 2.4, §2, p. 11): with distinct weights, if C ⊆ msf S and q identifies exactly the vertices joined by C, then msf S is C together with the minimum spanning forest of the remaining edges S \ C in the contracted multigraph Sym2.map q ∘ ends.

Support and filtering #

def Cslib.Multigraph.Supported {V : Type u_1} {E : Type u_3} {W : Type u_4} [LinearOrder W] (ends : E → Sym2 V) (w : E → W) (F : Set E) (e : E) :

The edge e is supported by the set F of edges when the edges of F of weight at most w e join its ends (§1.2, p. 5; §3.1, p. 13).

theorem Cslib.Multigraph.supported_iff {V : Type u_1} {E : Type u_3} {W : Type u_4} {ends : E → Sym2 V} [LinearOrder W] (w : E → W) {F : Set E} {e : E} {a b : V} (h : ends e = s(a, b)) :
Supported ends w F e ↔ Joins ends {f : E | f ∈ F ∧ w f ≤ w e} a b
theorem Cslib.Multigraph.Supported.mono {V : Type u_1} {E : Type u_3} {W : Type u_4} {ends : E → Sym2 V} [LinearOrder W] {w : E → W} {F G : Set E} (hFG : F ⊆ G) {e : E} (h : Supported ends w F e) :
Supported ends w G e

An edge supported by F is supported by every superset of F.

theorem Cslib.Multigraph.supported_of_mem {V : Type u_1} {E : Type u_3} {W : Type u_4} {ends : E → Sym2 V} [LinearOrder W] (w : E → W) {F : Set E} {e : E} (he : e ∈ F) :
Supported ends w F e

Every edge of F is supported by F.

theorem Cslib.Multigraph.supported_msf_iff {V : Type u_1} {E : Type u_3} {W : Type u_4} {ends : E → Sym2 V} [LinearOrder W] (w : E → W) {S : Finset E} {e : E} :
Supported ends w (↑(msf ends w S)) e ↔ Supported ends w (↑S) e

An edge is supported by msf S exactly when it is supported by S, by Fact 2.5.

noncomputable def Cslib.Multigraph.unsupported {V : Type u_1} {E : Type u_3} {W : Type u_4} [LinearOrder W] (ends : E → Sym2 V) (w : E → W) (F : Set E) (S : Finset E) :

The edges of S not supported by F, the set U(F) of §3.1 (p. 13).

theorem Cslib.Multigraph.mem_unsupported {V : Type u_1} {E : Type u_3} {W : Type u_4} {ends : E → Sym2 V} [LinearOrder W] (w : E → W) {S : Finset E} {F : Set E} {e : E} :
e ∈ unsupported ends w F S ↔ e ∈ S ∧ ¬Supported ends w F e
theorem Cslib.Multigraph.notMem_msf_of_supported {V : Type u_1} {E : Type u_3} {W : Type u_4} {ends : E → Sym2 V} [LinearOrder W] (w : E → W) {S : Finset E} (hw : Function.Injective w) {F : Set E} (hFS : F ⊆ ↑S) {e : E} (heF : e ∉ F) (hsup : Supported ends w F e) :
e ∉ msf ends w S

Filtering: with distinct weights, an edge supported by a set F ⊆ S of edges and not in F is not in msf S.

theorem Cslib.Multigraph.msf_union_unsupported {V : Type u_1} {E : Type u_3} {W : Type u_4} {ends : E → Sym2 V} [LinearOrder W] (w : E → W) {S : Finset E} [DecidableEq E] (hw : Function.Injective w) {F : Finset E} (hFS : F ⊆ S) :
msf ends w (F ∪ unsupported ends w (↑F) S) = msf ends w S

Filtering (Algorithm 2, line 8, p. 25): with distinct weights, for every F ⊆ S the minimum spanning forest of S is that of F together with the edges of S it does not support.

Weight optimality #

structure Cslib.Multigraph.IsSpanningForest {V : Type u_1} {E : Type u_3} (ends : E → Sym2 V) (S F : Finset E) :

F is a spanning forest of the edges S: an acyclic subset of S that joins the ends of every edge of S.

  • subset : F ⊆ S

    The forest consists of edges of S.

  • isAcyclic : IsAcyclic ends ↑F

    The forest is acyclic.

  • joins (e : E) : e ∈ S → ∀ (a b : V), ends e = s(a, b) → Joins ends (↑F) a b

    The forest joins the ends of every edge of S.

theorem Cslib.Multigraph.isSpanningForest_msf {V : Type u_1} {E : Type u_3} {W : Type u_4} {ends : E → Sym2 V} [LinearOrder W] (w : E → W) {S : Finset E} (hw : Function.Injective w) :
IsSpanningForest ends S (msf ends w S)

With distinct weights, msf S is a spanning forest of S.

theorem Cslib.Multigraph.sum_msf_le {V : Type u_1} {E : Type u_3} {W : Type u_4} {ends : E → Sym2 V} [LinearOrder W] (w : E → W) {S : Finset E} [AddCommMonoid W] [IsOrderedAddMonoid W] (hw : Function.Injective w) {F : Finset E} (hF : IsSpanningForest ends S F) :
∑ e ∈ msf ends w S, w e ≤ ∑ e ∈ F, w e

Weight optimality: with distinct weights in an ordered additive monoid, msf S has the least total weight among the spanning forests of S. Each spanning forest F ≠ msf S exchanges an edge outside msf S for a lighter edge of msf S, as in the cut property.