Counting walks of a given length #
Main definitions #
walkLengthTwoEquivCommonNeighbors: bijective correspondence between walks of length two fromutovand common neighbours ofuandv. Note thatuandvmay be the same.finsetWalkLength: theFinsetof length-nwalks fromutov. This is used to give{p : G.walk u v | p.length = n}aFintypeinstance, and it can also be useful as a recursive description of this set whenVis finite.
TODO: should this be extended further?
@[deprecated SimpleGraph.Walk.setOfPred_length_eq_zero_of_ne (since := "2026-07-09")]
theorem SimpleGraph.Walk.setOf_length_eq_zero_of_ne {V : Type u} (G : SimpleGraph V) {u v : V} (h : u ≠ v) :
@[deprecated SimpleGraph.Walk.setOfPred_length_eq_zero_of_ne (since := "2026-05-12")]
theorem SimpleGraph.set_walk_length_zero_eq_of_ne {V : Type u} (G : SimpleGraph V) {u v : V} (h : u ≠ v) :
@[deprecated SimpleGraph.Walk.setOfPred_length_eq_add_one (since := "2026-07-09")]
theorem SimpleGraph.Walk.setOf_length_eq_add_one {V : Type u} (G : SimpleGraph V) (u v : V) (n : ℕ) :
@[deprecated SimpleGraph.Walk.setOfPred_length_eq_add_one (since := "2026-05-12")]
Walks of length two from u to v correspond bijectively to common neighbours of u and v.
Note that u and v may be the same.
Instances For
@[simp]
theorem SimpleGraph.walkLengthTwoEquivCommonNeighbors_symm_apply_coe {V : Type u} (G : SimpleGraph V) (u v : V) (w : ↑(G.commonNeighbors u v)) :
@[simp]
theorem SimpleGraph.walkLengthTwoEquivCommonNeighbors_apply_coe {V : Type u} (G : SimpleGraph V) (u v : V) (p : { p : G.Walk u v // p.length = 2 }) :
def SimpleGraph.finsetWalkLength {V : Type u} (G : SimpleGraph V) [DecidableEq V] [G.LocallyFinite] (n : ℕ) (u v : V) :
The Finset of length-n walks from u to v.
This is used to give {p : G.walk u v | p.length = n} a Fintype instance, and it
can also be useful as a recursive description of this set when V is finite.
See SimpleGraph.coe_finsetWalkLength_eq for the relationship between this Finset and
the set of length-n walks.
Instances For
theorem SimpleGraph.coe_finsetWalkLength_eq {V : Type u} (G : SimpleGraph V) [DecidableEq V] [G.LocallyFinite] (n : ℕ) (u v : V) :
theorem SimpleGraph.mem_finsetWalkLength_iff {V : Type u} {G : SimpleGraph V} [DecidableEq V] [G.LocallyFinite] {n : ℕ} {u v : V} {p : G.Walk u v} :
def SimpleGraph.finsetWalkLengthLT {V : Type u} (G : SimpleGraph V) [DecidableEq V] [G.LocallyFinite] (n : ℕ) (u v : V) :
The Finset of walks from u to v with length less than n. See finsetWalkLength for
context. In particular, we use this definition for SimpleGraph.Path.instFintype.
Instances For
theorem SimpleGraph.coe_finsetWalkLengthLT_eq {V : Type u} (G : SimpleGraph V) [DecidableEq V] [G.LocallyFinite] (n : ℕ) (u v : V) :
theorem SimpleGraph.mem_finsetWalkLengthLT_iff {V : Type u} {G : SimpleGraph V} [DecidableEq V] [G.LocallyFinite] {n : ℕ} {u v : V} {p : G.Walk u v} :
@[instance_reducible]
instance SimpleGraph.fintypeSetWalkLength {V : Type u} (G : SimpleGraph V) [DecidableEq V] [G.LocallyFinite] (u v : V) (n : ℕ) :
@[instance_reducible]
instance SimpleGraph.fintypeSubtypeWalkLength {V : Type u} (G : SimpleGraph V) [DecidableEq V] [G.LocallyFinite] (u v : V) (n : ℕ) :
theorem SimpleGraph.set_walk_length_toFinset_eq {V : Type u} (G : SimpleGraph V) [DecidableEq V] [G.LocallyFinite] (n : ℕ) (u v : V) :
theorem SimpleGraph.card_set_walk_length_eq {V : Type u} (G : SimpleGraph V) [DecidableEq V] [G.LocallyFinite] (u v : V) (n : ℕ) :
See SimpleGraph.adjMatrix_pow_apply_eq_card_walk for the cardinality in terms of the nth
power of the adjacency matrix.
@[instance_reducible]
instance SimpleGraph.fintypeSetWalkLengthLT {V : Type u} (G : SimpleGraph V) [DecidableEq V] [G.LocallyFinite] (u v : V) (n : ℕ) :
@[instance_reducible]
instance SimpleGraph.fintypeSubtypeWalkLengthLT {V : Type u} (G : SimpleGraph V) [DecidableEq V] [G.LocallyFinite] (u v : V) (n : ℕ) :
@[instance_reducible]
instance SimpleGraph.fintypeSetPathLength {V : Type u} (G : SimpleGraph V) [DecidableEq V] [G.LocallyFinite] (u v : V) (n : ℕ) :
@[instance_reducible]
instance SimpleGraph.fintypeSubtypePathLength {V : Type u} (G : SimpleGraph V) [DecidableEq V] [G.LocallyFinite] (u v : V) (n : ℕ) :
@[instance_reducible]
instance SimpleGraph.fintypeSetPathLengthLT {V : Type u} (G : SimpleGraph V) [DecidableEq V] [G.LocallyFinite] (u v : V) (n : ℕ) :
@[instance_reducible]
instance SimpleGraph.fintypeSubtypePathLengthLT {V : Type u} (G : SimpleGraph V) [DecidableEq V] [G.LocallyFinite] (u v : V) (n : ℕ) :
@[instance_reducible]
instance SimpleGraph.Path.instFintype {V : Type u} (G : SimpleGraph V) [DecidableEq V] [Fintype V] [DecidableRel G.Adj] {u v : V} :