Traversing walks #
Functions that help access different parts of a walk.
Main definitions #
SimpleGraph.Walk.getVert: Get the nth vertex encountered in a walk, or the last one ifnis too largeSimpleGraph.Walk.snd: The second vertex of a walk, or the only vertex in an empty walkSimpleGraph.Walk.penultimate: The penultimate vertex of a walk, or the only vertex in an empty walkSimpleGraph.Walk.firstDart: The first dart of a non-empty walkSimpleGraph.Walk.lastDart: The last dart of a non-empty walk
Tags #
walks
Get the nth vertex from a walk, where n is generally expected to be
between 0 and p.length, inclusive.
If n is greater than or equal to p.length, the result is the path's endpoint.
Equations
- SimpleGraph.Walk.nil.getVert x✝ = u
- (SimpleGraph.Walk.cons h p).getVert 0 = u
- (SimpleGraph.Walk.cons h q).getVert n.succ = q.getVert n
Instances For
@[simp]
@[simp]
theorem
SimpleGraph.Walk.getVert_of_length_le
{V : Type u}
{G : SimpleGraph V}
{u v : V}
(w : G.Walk u v)
{i : ℕ}
(hi : w.length ≤ i)
:
@[simp]
theorem
SimpleGraph.Walk.getVert_length
{V : Type u}
{G : SimpleGraph V}
{u v : V}
(w : G.Walk u v)
:
@[simp]
theorem
SimpleGraph.Walk.getVert_mem_support
{V : Type u}
{G : SimpleGraph V}
{u v : V}
(p : G.Walk u v)
(i : ℕ)
:
@[deprecated SimpleGraph.Walk.getVert_eq_support_getElem? (since := "2025-06-10")]
theorem
SimpleGraph.Walk.getVert_eq_support_get?
{V : Type u}
{G : SimpleGraph V}
{u v : V}
{n : ℕ}
(p : G.Walk u v)
(h : n ≤ p.length)
:
theorem
SimpleGraph.Walk.getVert_eq_getD_support
{V : Type u}
{G : SimpleGraph V}
{u v : V}
(p : G.Walk u v)
(n : ℕ)
:
@[reducible, inline]
The second vertex of a walk, or the only vertex in a nil walk.
Instances For
@[simp]
theorem
SimpleGraph.Walk.adj_snd
{V : Type u}
{G : SimpleGraph V}
{v w : V}
{p : G.Walk v w}
(hp : ¬p.Nil)
:
theorem
SimpleGraph.Walk.snd_cons
{V : Type u}
{G : SimpleGraph V}
{u v w : V}
(q : G.Walk v w)
(hadj : G.Adj u v)
:
@[reducible, inline]
The penultimate vertex of a walk, or the only vertex in a nil walk.
Equations
- p.penultimate = p.getVert (p.length - 1)
Instances For
@[simp]
@[simp]
theorem
SimpleGraph.Walk.penultimate_cons_nil
{V : Type u}
{G : SimpleGraph V}
{u v : V}
(h : G.Adj u v)
:
@[simp]
theorem
SimpleGraph.Walk.penultimate_cons_cons
{V : Type u}
{G : SimpleGraph V}
{u v w w' : V}
(h : G.Adj u v)
(h₂ : G.Adj v w)
(p : G.Walk w w')
:
theorem
SimpleGraph.Walk.penultimate_cons_of_not_nil
{V : Type u}
{G : SimpleGraph V}
{u v w : V}
(h : G.Adj u v)
(p : G.Walk v w)
(hp : ¬p.Nil)
:
@[simp]
theorem
SimpleGraph.Walk.adj_penultimate
{V : Type u}
{G : SimpleGraph V}
{v w : V}
{p : G.Walk v w}
(hp : ¬p.Nil)
:
G.Adj p.penultimate w
def
SimpleGraph.Walk.lastDart
{V : Type u}
{G : SimpleGraph V}
{v w : V}
(p : G.Walk v w)
(hp : ¬p.Nil)
:
G.Dart
The last dart of a walk.
Equations
- p.lastDart hp = { fst := p.penultimate, snd := w, adj := ⋯ }
Instances For
@[simp]
theorem
SimpleGraph.Walk.lastDart_toProd
{V : Type u}
{G : SimpleGraph V}
{v w : V}
(p : G.Walk v w)
(hp : ¬p.Nil)
:
theorem
SimpleGraph.Walk.edge_lastDart
{V : Type u}
{G : SimpleGraph V}
{v w : V}
(p : G.Walk v w)
(hp : ¬p.Nil)
: