The distance matrix of a partial graph

Lax185574.DistanceMatrix · concepts/Lax185574/DistanceMatrix.lean · lax-185574

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

    The distance matrix of a partial graph G is the |G| × |G| matrix D_G with entries D_G(u, v) = dist^G(u, v) ∈ ℕ ∪ {∞}.

    Concept map
    8 concepts; 2 descendants hidden
    100%
    Proven claimDefinitionThis conceptRelated conceptA → B: B builds on A

    In the paper

    • page 40 of this submission's paper

    Lean source view on GitHub

    1import Lax185574.PartialGraphs
    2import Mathlib.Combinatorics.SimpleGraph.Metric
    3
    4/-!
    5---
    6title: The distance matrix of a partial graph
    7type: definition
    8---
    9The *distance matrix* of a partial graph G is the |G| × |G| matrix D_G
    10with entries D_G(u, v) = dist^G(u, v) ∈ ℕ ∪ {∞}.
    11
    12# Formalization notes
    13
    14The distance is the extended distance `SimpleGraph.edist` of mathlib in
    15the graph of resolved pairs, a value in `ℕ∞`. So D_G is 0 on the
    16diagonal, and ∞ for vertices in different components of the graph of
    17resolved pairs. The matrix of a partial graph on `Fin n` is a function
    18of two vertices.
    19
    20Algorithms receive the matrix in the encoding of `Lax185574.Encodings`.
    21A distance in ℕ ∪ {∞} is encoded as one entry, 0 for ∞ and d + 1 for a
    22finite distance d. The matrix is the family of its rows, and each row is
    23the family of its entries. So the word of D_G is n, followed by every
    24row in order as n and the n entries of the row. Every row has n + 1
    25entries, the word has length 1 + n(n + 1), and the entry at (u, v) is at
    26position 2 + u(n + 1) + v, counting from 0. The paper does not say how
    27∞ is represented. Its bounds O(|G|²) for reading the matrix need entries
    28of constant size, which this encoding provides.
    29-/
    30
    31namespace Lax185574.DistanceMatrix
    32
    33open Lax185574.PartialGraphs
    34
    35/-- The distance matrix `D_G`: `D_G(u, v) = dist^G(u, v)`, the distance
    36in the graph of resolved pairs, and `∞` if there is no path. -/
    37noncomputable def distMatrix {n : ℕ} (G : PartialGraph (Fin n)) : Fin n → Fin n → ℕ∞ :=
    38 fun u v => G.resolved.edist u v
    39
    40end Lax185574.DistanceMatrix
    41
    Formalization notes

    The distance is the extended distance SimpleGraph.edistSimpleGraph.edist of mathlib in the graph of resolved pairs, a value in N∞ℕ∞. So D_G is 0 on the diagonal, and ∞ for vertices in different components of the graph of resolved pairs. The matrix of a partial graph on FinnFin n is a function of two vertices.

    Algorithms receive the matrix in the encoding of Lax185574.EncodingsLax185574.Encodings. A distance in ℕ ∪ {∞} is encoded as one entry, 0 for ∞ and d + 1 for a finite distance d. The matrix is the family of its rows, and each row is the family of its entries. So the word of D_G is n, followed by every row in order as n and the n entries of the row. Every row has n + 1 entries, the word has length 1 + n(n + 1), and the entry at (u, v) is at position 2 + u(n + 1) + v, counting from 0. The paper does not say how ∞ is represented. Its bounds O(|G|²) for reading the matrix need entries of constant size, which this encoding provides.

    Discussion

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

    Loading discussion…