Walk #
In a simple graph, a walk is a finite sequence of adjacent vertices, and can be thought of equally well as a sequence of directed edges.
Warning: graph theorists mean something different by "path" than do homotopy theorists. A "walk" in graph theory is a "path" in homotopy theory. Another warning: some graph theorists use "path" and "simple path" for "walk" and "path."
Some definitions and theorems have inspiration from multigraph counterparts in [Chou1994].
Main definitions #
SimpleGraph.Walk
(with accompanying pattern definitionsSimpleGraph.Walk.nil'
andSimpleGraph.Walk.cons'
)SimpleGraph.Walk.map
for the induced map on walks, given an (injective) graph homomorphism.
Tags #
walks
A walk is a sequence of adjacent vertices. For vertices u v : V
,
the type walk u v
consists of all walks starting at u
and ending at v
.
We say that a walk visits the vertices it contains. The set of vertices a
walk visits is SimpleGraph.Walk.support
.
See SimpleGraph.Walk.nil'
and SimpleGraph.Walk.cons'
for patterns that
can be useful in definitions since they make the vertices explicit.
- nil {V : Type u} {G : SimpleGraph V} {u : V} : G.Walk u u
- cons {V : Type u} {G : SimpleGraph V} {u v w : V} (h : G.Adj u v) (p : G.Walk v w) : G.Walk u w
Equations
- SimpleGraph.Walk.instInhabited G v = { default := SimpleGraph.Walk.nil }
The one-edge walk associated to a pair of adjacent vertices.
Equations
Pattern to get Walk.nil
with the vertex as an explicit argument.
Equations
Pattern to get Walk.cons
with the vertices as explicit arguments.
Equations
- SimpleGraph.Walk.cons' u v w h p = SimpleGraph.Walk.cons h p
Change the endpoints of a walk using equalities. This is helpful for relaxing
definitional equality constraints and to be able to state otherwise difficult-to-state
lemmas. While this is a simple wrapper around Eq.rec
, it gives a canonical way to write it.
The simp-normal form is for the copy
to be pushed outward. That way calculations can
occur within the "copy context."
The length of a walk is the number of edges/darts along it.
Equations
The concatenation of two compatible walks.
Equations
- SimpleGraph.Walk.nil.append q = q
- (SimpleGraph.Walk.cons h p).append x✝ = SimpleGraph.Walk.cons h (p.append x✝)
The reversed version of SimpleGraph.Walk.cons
, concatenating an edge to
the end of a walk.
Equations
- p.concat h = p.append (SimpleGraph.Walk.cons h SimpleGraph.Walk.nil)
The concatenation of the reverse of the first walk with the second walk.
Equations
- SimpleGraph.Walk.nil.reverseAux x✝ = x✝
- (SimpleGraph.Walk.cons h p).reverseAux x✝ = p.reverseAux (SimpleGraph.Walk.cons ⋯ x✝)
The walk in reverse.
Equations
Get the n
th 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
Auxiliary definition for SimpleGraph.Walk.concatRec
Equations
- SimpleGraph.Walk.concatRecAux Hnil Hconcat SimpleGraph.Walk.nil = Hnil
- SimpleGraph.Walk.concatRecAux Hnil Hconcat (SimpleGraph.Walk.cons h q) = ⋯ ▸ Hconcat q.reverse ⋯ (SimpleGraph.Walk.concatRecAux Hnil Hconcat q)
Recursor on walks by inducting on SimpleGraph.Walk.concat
.
This is inducting from the opposite end of the walk compared
to SimpleGraph.Walk.rec
, which inducts on SimpleGraph.Walk.cons
.
Equations
- SimpleGraph.Walk.concatRec Hnil Hconcat p = ⋯ ▸ SimpleGraph.Walk.concatRecAux Hnil Hconcat p.reverse
The darts
of a walk is the list of darts it visits in order.
The edges
of a walk is the list of edges it visits in order.
This is defined to be the list of edges underlying SimpleGraph.Walk.darts
.
Equations
Every edge in a walk's edge list is an edge of the graph.
It is written in this form (rather than using ⊆
) to avoid unsightly coercions.
Predicate for the empty walk.
Solves the dependent type problem where p = G.Walk.nil
typechecks
only if p
has defeq endpoints.
- nil {V : Type u} {G : SimpleGraph V} {u : V} : Walk.nil.Nil
Equations
Alias of the forward direction of SimpleGraph.Walk.nil_iff_eq_nil
.
A walk with its endpoints defeq is Nil
if and only if it is equal to nil
.
The recursion principle for nonempty walks
Equations
- SimpleGraph.Walk.notNilRec cons SimpleGraph.Walk.nil = fun (hp : ¬SimpleGraph.Walk.nil.Nil) => absurd ⋯ hp
- SimpleGraph.Walk.notNilRec cons (SimpleGraph.Walk.cons h q) = fun (x : ¬(SimpleGraph.Walk.cons h q).Nil) => cons h q
The walk obtained by removing the first n
darts of a walk.
Equations
- SimpleGraph.Walk.nil.drop n = SimpleGraph.Walk.nil
- p.drop 0 = p.copy ⋯ ⋯
- (SimpleGraph.Walk.cons h q).drop n_2.succ = q.drop n_2
The second vertex of a walk, or the only vertex in a nil walk.
The walk obtained by taking the first n
darts of a walk.
Equations
- SimpleGraph.Walk.nil.take n = SimpleGraph.Walk.nil
- p.take 0 = SimpleGraph.Walk.nil.copy ⋯ ⋯
- (SimpleGraph.Walk.cons h q).take n_2.succ = SimpleGraph.Walk.cons h (q.take n_2)
The penultimate vertex of a walk, or the only vertex in a nil walk.
Equations
- p.penultimate = p.getVert (p.length - 1)
The walk obtained by removing the first dart of a walk. A nil walk stays nil.
The walk obtained by removing the last dart of a walk. A nil walk stays nil.
The last dart of a walk.
Equations
- p.lastDart hp = { fst := p.penultimate, snd := w, adj := ⋯ }
Given a set S
and a walk w
from u
to v
such that u ∈ S
but v ∉ S
,
there exists a dart in the walk whose start is in S
but whose end is not.
Mapping walks #
Given a graph homomorphism, map walks to walks.
Unlike categories, for graphs vertex equality is an important notion, so needing to be able to work with equality of graph homomorphisms is a necessary evil.
The specialization of SimpleGraph.Walk.map
for mapping walks to supergraphs.
Equations
Transferring between graphs #
The walk p
transferred to lie in H
, given that H
contains its edges.
Equations
- SimpleGraph.Walk.nil.transfer H h_2 = SimpleGraph.Walk.nil
- (SimpleGraph.Walk.cons h_2 p_2).transfer H h_3 = SimpleGraph.Walk.cons ⋯ (p_2.transfer H ⋯)
Alias of SimpleGraph.Walk.transfer_eq_map_ofLE
.
Deleting edges #
Given a walk that avoids a set of edges, produce a walk in the graph with those edges deleted.
Equations
- SimpleGraph.Walk.toDeleteEdges s p hp = p.transfer (G.deleteEdges s) ⋯
Given a walk that avoids an edge, create a walk in the subgraph with that edge deleted.
This is an abbreviation for SimpleGraph.Walk.toDeleteEdges
.