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
Instances For
Equations
- SimpleGraph.Walk.instInhabited G v = { default := SimpleGraph.Walk.nil }
The one-edge walk associated to a pair of adjacent vertices.
Equations
- h.toWalk = SimpleGraph.Walk.cons h SimpleGraph.Walk.nil
Instances For
Pattern to get Walk.nil
with the vertex as an explicit argument.
Equations
Instances For
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
Instances For
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."
Equations
- p.copy hu hv = hu ▸ hv ▸ p
Instances For
The length of a walk is the number of edges/darts along it.
Equations
- SimpleGraph.Walk.nil.length = 0
- (SimpleGraph.Walk.cons h q).length = q.length.succ
Instances For
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✝)
Instances For
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)
Instances For
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✝)
Instances For
The walk in reverse.
Equations
- w.reverse = w.reverseAux SimpleGraph.Walk.nil
Instances For
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
Instances For
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)
Instances For
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
Instances For
The support
of a walk is the list of vertices it visits in order.
Equations
- SimpleGraph.Walk.nil.support = [u]
- (SimpleGraph.Walk.cons h q).support = u :: q.support
Instances For
The darts
of a walk is the list of darts it visits in order.
Equations
- SimpleGraph.Walk.nil.darts = []
- (SimpleGraph.Walk.cons h q).darts = { toProd := (u, v_3), adj := h } :: q.darts
Instances For
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
- p.edges = List.map SimpleGraph.Dart.edge p.darts
Instances For
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} : SimpleGraph.Walk.nil.Nil
Instances For
Equations
- SimpleGraph.Walk.nil.instDecidableNil = isTrue ⋯
- (SimpleGraph.Walk.cons h q).instDecidableNil = isFalse ⋯
A walk with its endpoints defeq is Nil
if and only if it is equal to nil
.
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
.
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
Instances For
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).copy ⋯ ⋯
Instances For
The second vertex of a walk, or the only vertex in a nil walk.
Equations
- p.snd = p.getVert 1
Instances For
The penultimate vertex of a walk, or the only vertex in a nil walk.
Instances For
The walk obtained by removing the first dart of a walk. A nil walk stays nil.
Equations
- p.tail = p.drop 1
Instances For
The first dart of a walk.
Equations
- p.firstDart hp = { toProd := (v, p.snd), adj := ⋯ }
Instances For
The last dart of a walk.
Equations
- p.lastDart hp = { toProd := (p.penultimate, w), adj := ⋯ }
Instances For
Walk decompositions #
Given a vertex in the support of a path, give the path up until (and including) that vertex.
Equations
- One or more equations did not get rendered due to their size.
- SimpleGraph.Walk.nil.takeUntil x x_1 = ⋯.mpr SimpleGraph.Walk.nil
Instances For
Given a vertex in the support of a path, give the path from (and including) that vertex to the end. In other words, drop vertices from the front of a path until (and not including) that vertex.
Equations
- One or more equations did not get rendered due to their size.
- SimpleGraph.Walk.nil.dropUntil x x_1 = ⋯.mpr SimpleGraph.Walk.nil
Instances For
The takeUntil
and dropUntil
functions split a walk into two pieces.
The lemma SimpleGraph.Walk.count_support_takeUntil_eq_one
specifies where this split occurs.
Rotate a loop walk such that it is centered at the given vertex.
Equations
- c.rotate h = (c.dropUntil u h).append (c.takeUntil u h)
Instances For
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.
Given a walk w
and a node in the support, there exists a natural n
, such that given node
is the n
-th node (zero-indexed) in the walk. In addition, n
is at most the length of the path.
Due to the definition of getVert
it would otherwise be legal to return a larger n
for the last
node.
Mapping walks #
Given a graph homomorphism, map walks to walks.
Equations
Instances For
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
Instances For
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 ⋯)
Instances For
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) ⋯
Instances For
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
.
Equations
- SimpleGraph.Walk.toDeleteEdge e p hp = SimpleGraph.Walk.toDeleteEdges {e} p ⋯