While this submission is a draft, it cannot be used by other submissions.

Cycles, Spanning Trees and Spanning Forests of a Multigraph

Lax630294.SpanningStructures · concepts/Lax630294/SpanningStructures.lean · lax-630294

definition

Loading review…

Sign in with ORCID

Community review

Flags

Each flag is tied to a public ORCID identity and explains why this concept may be incorrect.

No flags have been submitted.

    Community review

    Flag this concept

    State precisely what appears incorrect. This explanation will be public under your ORCID name.

    No source line selected.

    Natural Language Statement

    Definition

    Let GG be a multigraph and let FF be a set of edges of GG; we identify FF with the spanning subgraph of GG that keeps all vertices of GG and only the edges in FF. The components of FF are the connected components of this subgraph; every vertex of GG lies in a component, even if it is incident to no edge of FF.

    A set FF of edges is simple if it contains no loop and no two parallel edges. A simple set FF is acyclic if the subgraph it forms has no cycle, and it is a tree if it is acyclic and connected. A spanning tree of GG is a simple set of edges of GG forming a tree on all vertices of GG. A spanning forest with kk components of GG is a simple acyclic set of edges of GG with exactly kk components.

    A cycle of length n≥1n ≥ 1 consists of nn pairwise distinct vertices v0,…,vn−1v₀, …, vₙ₋₁ and nn pairwise distinct edges e0,…,en−1e₀, …, eₙ₋₁ such that eieᵢ joins vivᵢ and vi+1vᵢ₊₁, with indices taken modulo nn. Its edge set is e0,…,en−1{e₀, …, eₙ₋₁}.

    Concept map
    1 concept; 3 descendants hidden
    100%
    Proven claimDefinitionThis conceptRelated conceptA → B: B builds on A

    In the paper

    • page 3 of this submission's paper

    Lean source view on GitHub

    1import Mathlib.Combinatorics.Graph.Delete
    2import Mathlib.Combinatorics.Graph.Simple
    3import Mathlib.Combinatorics.SimpleGraph.Acyclic
    4import Mathlib.Data.Set.Card
    5import Mathlib.Data.ENat.Basic
    6
    7/-!
    8---
    9title: Cycles, Spanning Trees and Spanning Forests of a Multigraph
    10type: definition
    11---
    12
    13Let `G` be a multigraph and let `F` be a set of edges of `G`; we identify `F`
    14with the spanning subgraph of `G` that keeps all vertices of `G` and only the
    15edges in `F`. The *components* of `F` are the connected components of this
    16subgraph; every vertex of `G` lies in a component, even if it is incident to no
    17edge of `F`.
    18
    19A set `F` of edges is *simple* if it contains no loop and no two parallel edges.
    20A simple set `F` is *acyclic* if the subgraph it forms has no cycle, and it is a
    21*tree* if it is acyclic and connected. A *spanning tree* of `G` is a simple set of
    22edges of `G` forming a tree on all vertices of `G`. A *spanning forest with `k`
    23components* of `G` is a simple acyclic set of edges of `G` with exactly `k`
    24components.
    25
    26A *cycle of length `n ≥ 1`* consists of `n` pairwise distinct vertices
    27`v₀, …, vₙ₋₁` and `n` pairwise distinct edges `e₀, …, eₙ₋₁` such that `eᵢ` joins
    28`vᵢ` and `vᵢ₊₁`, with indices taken modulo `n`. Its edge set is `{e₀, …, eₙ₋₁}`.
    29
    30# Formalization notes
    31
    32The multigraph is Mathlib's `Graph α β`. Connectivity, components, trees and
    33acyclicity are taken from Mathlib's theory of simple graphs, applied to
    34`Graph.toSimpleGraph` of the spanning subgraph `G.restrict F`; this forgets loops
    35and parallel edges. Requiring `(G.restrict F).Simple` restores them, so that a loop
    36or a pair of parallel edges in `F` is never accepted as part of a tree or a forest
    37(these are the cycles of length one and two). Cycles are given by an explicit cyclic
    38sequence indexed by `ZMod n`; a cycle of length one is a loop and a cycle of length
    39two is a pair of parallel edges. The number of components is an extended natural number (`ENat.card`), so
    40that infinitely many components are not mistaken for a finite number.
    41-/
    42
    43namespace Lax630294.SpanningStructures
    44
    45open Graph
    46
    47variable {α β : Type*}
    48
    49/-- The simple graph underlying the spanning subgraph of `G` with edge set `F`. -/
    50abbrev underlying (G : Graph α β) (F : Set β) : SimpleGraph V(G) :=
    51 (G.restrict F).toSimpleGraph
    52
    53/-- The vertices of `G` incident to an edge of `F`. -/
    54def incidentVertices (G : Graph α β) (F : Set β) : Set α :=
    55 {x | ∃ e ∈ F, G.Inc e x}
    56
    57/-- `C` is the edge set of a cycle of `G` of some length `n ≥ 1`: there are
    58pairwise distinct vertices `v 0, …, v (n - 1)` and pairwise distinct edges
    59`e 0, …, e (n - 1)` such that `e i` links `v i` and `v (i + 1)`, with indices
    60taken modulo `n`, and `C` consists of these edges. Its length is `C.encard`. -/
    61def IsCycle (G : Graph α β) (C : Set β) : Prop :=
    62 ∃ n : ℕ, 0 < n ∧ ∃ (v : ZMod n → α) (e : ZMod n → β),
    63 Function.Injective v ∧ Function.Injective e ∧
    64 (∀ i, G.IsLink (e i) (v i) (v (i + 1))) ∧ Set.range e = C
    65
    66/-- `T` is a spanning tree of `G`. -/
    67def IsSpanningTree (G : Graph α β) (T : Set β) : Prop :=
    68 T ⊆ E(G) ∧ (G.restrict T).Simple ∧ (underlying G T).IsTree
    69
    70/-- `F` is a spanning forest of `G` with exactly `k` components. -/
    71def IsSpanningForest (G : Graph α β) (F : Set β) (k : ℕ) : Prop :=
    72 F ⊆ E(G) ∧ (G.restrict F).Simple ∧ (underlying G F).IsAcyclic ∧
    73 ENat.card (underlying G F).ConnectedComponent = k
    74
    75end Lax630294.SpanningStructures
    76
    Formalization notes

    The multigraph is Mathlib's GraphαβGraph α β. Connectivity, components, trees and acyclicity are taken from Mathlib's theory of simple graphs, applied to Graph.toSimpleGraphGraph.toSimpleGraph of the spanning subgraph G.restrictFG.restrict F; this forgets loops and parallel edges. Requiring (G.restrictF).Simple(G.restrict F).Simple restores them, so that a loop or a pair of parallel edges in FF is never accepted as part of a tree or a forest (these are the cycles of length one and two). Cycles are given by an explicit cyclic sequence indexed by ZModnZMod n; a cycle of length one is a loop and a cycle of length two is a pair of parallel edges. The number of components is an extended natural number (ENat.cardENat.card), so that infinitely many components are not mistaken for a finite number.

    Discussion

    Ask a question or add context. Endorsements and structured flags are kept in the review panel above.

    Loading discussion…