Documentation

Mathlib.Combinatorics.SimpleGraph.Metric

Graph metric #

This module defines the SimpleGraph.edist function, which takes pairs of vertices to the length of the shortest walk between them, or if they are disconnected. It also defines SimpleGraph.dist which is the -valued version of SimpleGraph.edist.

Main definitions #

TODO #

Tags #

graph metric, distance

Metric #

noncomputable def SimpleGraph.edist {V : Type u_1} (G : SimpleGraph V) (u : V) (v : V) :

The extended distance between two vertices is the length of the shortest walk between them. It is if no such walk exists.

Equations
  • G.edist u v = ⨅ (w : G.Walk u v), w.length
Instances For
    theorem SimpleGraph.edist_eq_sInf {V : Type u_1} {G : SimpleGraph V} {u : V} {v : V} :
    G.edist u v = sInf (Set.range fun (w : G.Walk u v) => w.length)
    theorem SimpleGraph.Reachable.exists_walk_length_eq_edist {V : Type u_1} {G : SimpleGraph V} {u : V} {v : V} (hr : G.Reachable u v) :
    ∃ (p : G.Walk u v), p.length = G.edist u v
    theorem SimpleGraph.Connected.exists_walk_length_eq_edist {V : Type u_1} {G : SimpleGraph V} (hconn : G.Connected) (u : V) (v : V) :
    ∃ (p : G.Walk u v), p.length = G.edist u v
    theorem SimpleGraph.edist_le {V : Type u_1} {G : SimpleGraph V} {u : V} {v : V} (p : G.Walk u v) :
    G.edist u v p.length
    theorem SimpleGraph.Walk.edist_le {V : Type u_1} {G : SimpleGraph V} {u : V} {v : V} (p : G.Walk u v) :
    G.edist u v p.length

    Alias of SimpleGraph.edist_le.

    @[simp]
    theorem SimpleGraph.edist_eq_zero_iff {V : Type u_1} {G : SimpleGraph V} {u : V} {v : V} :
    G.edist u v = 0 u = v
    @[simp]
    theorem SimpleGraph.edist_self {V : Type u_1} {G : SimpleGraph V} {v : V} :
    G.edist v v = 0
    theorem SimpleGraph.edist_pos_of_ne {V : Type u_1} {G : SimpleGraph V} {u : V} {v : V} (hne : u v) :
    0 < G.edist u v
    theorem SimpleGraph.edist_eq_top_of_not_reachable {V : Type u_1} {G : SimpleGraph V} {u : V} {v : V} (h : ¬G.Reachable u v) :
    G.edist u v =
    theorem SimpleGraph.reachable_of_edist_ne_top {V : Type u_1} {G : SimpleGraph V} {u : V} {v : V} (h : G.edist u v ) :
    G.Reachable u v
    theorem SimpleGraph.exists_walk_of_edist_ne_top {V : Type u_1} {G : SimpleGraph V} {u : V} {v : V} (h : G.edist u v ) :
    ∃ (p : G.Walk u v), p.length = G.edist u v
    theorem SimpleGraph.edist_triangle {V : Type u_1} {G : SimpleGraph V} {u : V} {v : V} {w : V} :
    G.edist u w G.edist u v + G.edist v w
    theorem SimpleGraph.edist_comm {V : Type u_1} {G : SimpleGraph V} {u : V} {v : V} :
    G.edist u v = G.edist v u
    theorem SimpleGraph.exists_walk_of_edist_eq_coe {V : Type u_1} {G : SimpleGraph V} {u : V} {v : V} {k : } (h : G.edist u v = k) :
    ∃ (p : G.Walk u v), p.length = k
    theorem SimpleGraph.edist_ne_top_iff_reachable {V : Type u_1} {G : SimpleGraph V} {u : V} {v : V} :
    G.edist u v G.Reachable u v
    @[simp]
    theorem SimpleGraph.edist_eq_one_iff_adj {V : Type u_1} {G : SimpleGraph V} {u : V} {v : V} :
    G.edist u v = 1 G.Adj u v

    The extended distance between vertices is equal to 1 if and only if these vertices are adjacent.

    theorem SimpleGraph.edist_bot_of_ne {V : Type u_1} {u : V} {v : V} (h : u v) :
    .edist u v =
    theorem SimpleGraph.edist_bot {V : Type u_1} {u : V} {v : V} [DecidableEq V] :
    .edist u v = if u = v then 0 else
    theorem SimpleGraph.edist_top_of_ne {V : Type u_1} {u : V} {v : V} (h : u v) :
    .edist u v = 1
    theorem SimpleGraph.edist_top {V : Type u_1} {u : V} {v : V} [DecidableEq V] :
    .edist u v = if u = v then 0 else 1
    theorem SimpleGraph.edist_anti {V : Type u_1} {G : SimpleGraph V} {u : V} {v : V} {G' : SimpleGraph V} (h : G G') :
    G'.edist u v G.edist u v

    Supergraphs have smaller or equal extended distances to their subgraphs.

    noncomputable def SimpleGraph.dist {V : Type u_1} (G : SimpleGraph V) (u : V) (v : V) :

    The distance between two vertices is the length of the shortest walk between them. If no such walk exists, this uses the junk value of 0.

    Equations
    • G.dist u v = (G.edist u v).toNat
    Instances For
      theorem SimpleGraph.dist_eq_sInf {V : Type u_1} {G : SimpleGraph V} {u : V} {v : V} :
      G.dist u v = sInf (Set.range SimpleGraph.Walk.length)
      theorem SimpleGraph.Reachable.exists_walk_length_eq_dist {V : Type u_1} {G : SimpleGraph V} {u : V} {v : V} (hr : G.Reachable u v) :
      ∃ (p : G.Walk u v), p.length = G.dist u v
      theorem SimpleGraph.Connected.exists_walk_length_eq_dist {V : Type u_1} {G : SimpleGraph V} (hconn : G.Connected) (u : V) (v : V) :
      ∃ (p : G.Walk u v), p.length = G.dist u v
      theorem SimpleGraph.dist_le {V : Type u_1} {G : SimpleGraph V} {u : V} {v : V} (p : G.Walk u v) :
      G.dist u v p.length
      @[simp]
      theorem SimpleGraph.dist_eq_zero_iff_eq_or_not_reachable {V : Type u_1} {G : SimpleGraph V} {u : V} {v : V} :
      G.dist u v = 0 u = v ¬G.Reachable u v
      theorem SimpleGraph.dist_self {V : Type u_1} {G : SimpleGraph V} {v : V} :
      G.dist v v = 0
      theorem SimpleGraph.Reachable.dist_eq_zero_iff {V : Type u_1} {G : SimpleGraph V} {u : V} {v : V} (hr : G.Reachable u v) :
      G.dist u v = 0 u = v
      theorem SimpleGraph.Reachable.pos_dist_of_ne {V : Type u_1} {G : SimpleGraph V} {u : V} {v : V} (h : G.Reachable u v) (hne : u v) :
      0 < G.dist u v
      theorem SimpleGraph.Connected.dist_eq_zero_iff {V : Type u_1} {G : SimpleGraph V} {u : V} {v : V} (hconn : G.Connected) :
      G.dist u v = 0 u = v
      theorem SimpleGraph.Connected.pos_dist_of_ne {V : Type u_1} {G : SimpleGraph V} {u : V} {v : V} (hconn : G.Connected) (hne : u v) :
      0 < G.dist u v
      theorem SimpleGraph.dist_eq_zero_of_not_reachable {V : Type u_1} {G : SimpleGraph V} {u : V} {v : V} (h : ¬G.Reachable u v) :
      G.dist u v = 0
      theorem SimpleGraph.nonempty_of_pos_dist {V : Type u_1} {G : SimpleGraph V} {u : V} {v : V} (h : 0 < G.dist u v) :
      Set.univ.Nonempty
      theorem SimpleGraph.Connected.dist_triangle {V : Type u_1} {G : SimpleGraph V} {u : V} {v : V} {w : V} (hconn : G.Connected) :
      G.dist u w G.dist u v + G.dist v w
      theorem SimpleGraph.dist_comm {V : Type u_1} {G : SimpleGraph V} {u : V} {v : V} :
      G.dist u v = G.dist v u
      theorem SimpleGraph.dist_ne_zero_iff_ne_and_reachable {V : Type u_1} {G : SimpleGraph V} {u : V} {v : V} :
      G.dist u v 0 u v G.Reachable u v
      theorem SimpleGraph.Reachable.of_dist_ne_zero {V : Type u_1} {G : SimpleGraph V} {u : V} {v : V} (h : G.dist u v 0) :
      G.Reachable u v
      theorem SimpleGraph.exists_walk_of_dist_ne_zero {V : Type u_1} {G : SimpleGraph V} {u : V} {v : V} (h : G.dist u v 0) :
      ∃ (p : G.Walk u v), p.length = G.dist u v
      @[simp]
      theorem SimpleGraph.dist_eq_one_iff_adj {V : Type u_1} {G : SimpleGraph V} {u : V} {v : V} :
      G.dist u v = 1 G.Adj u v

      The distance between vertices is equal to 1 if and only if these vertices are adjacent.

      theorem SimpleGraph.Walk.isPath_of_length_eq_dist {V : Type u_1} {G : SimpleGraph V} {u : V} {v : V} (p : G.Walk u v) (hp : p.length = G.dist u v) :
      p.IsPath
      theorem SimpleGraph.Reachable.exists_path_of_dist {V : Type u_1} {G : SimpleGraph V} {u : V} {v : V} (hr : G.Reachable u v) :
      ∃ (p : G.Walk u v), p.IsPath p.length = G.dist u v
      theorem SimpleGraph.Connected.exists_path_of_dist {V : Type u_1} {G : SimpleGraph V} (hconn : G.Connected) (u : V) (v : V) :
      ∃ (p : G.Walk u v), p.IsPath p.length = G.dist u v
      @[simp]
      theorem SimpleGraph.dist_bot {V : Type u_1} {u : V} {v : V} :
      .dist u v = 0
      theorem SimpleGraph.dist_top_of_ne {V : Type u_1} {u : V} {v : V} (h : u v) :
      .dist u v = 1
      theorem SimpleGraph.dist_top {V : Type u_1} {u : V} {v : V} [DecidableEq V] :
      .dist u v = if u = v then 0 else 1
      theorem SimpleGraph.Reachable.dist_anti {V : Type u_1} {G : SimpleGraph V} {u : V} {v : V} {G' : SimpleGraph V} (h : G G') (hr : G.Reachable u v) :
      G'.dist u v G.dist u v

      Supergraphs have smaller or equal distances to their subgraphs.