Hamiltonian Graphs #
In this file we introduce Hamiltonian paths, cycles and graphs.
Main definitions #
SimpleGraph.Walk.IsHamiltonian
: Predicate for a walk to be Hamiltonian.SimpleGraph.Walk.IsHamiltonianCycle
: Predicate for a walk to be a Hamiltonian cycle.SimpleGraph.IsHamiltonian
: Predicate for a graph to be Hamiltonian.
A Hamiltonian path is a walk p
that visits every vertex exactly once. Note that while
this definition doesn't contain that p
is a path, p.isPath
gives that.
Equations
- p.IsHamiltonian = ∀ (a_1 : α), List.count a_1 p.support = 1
Instances For
A Hamiltonian path visits every vertex.
Hamiltonian paths are paths.
A path whose support contains every vertex is Hamiltonian.
If a path p
is Hamiltonian then its vertex set must be finite.
Instances For
The support of a Hamiltonian walk is the entire vertex set.
The length of a Hamiltonian path is one less than the number of vertices of the graph.
A Hamiltonian cycle is a cycle that visits every vertex once.
- edges_nodup : p.edges.Nodup
- isHamiltonian_tail : p.tail.IsHamiltonian
Instances For
A Hamiltonian cycle visits every vertex.
The length of a Hamiltonian cycle is the number of vertices.
A Hamiltonian graph is a graph that contains a Hamiltonian cycle.
By convention, the singleton graph is considered to be Hamiltonian.
Equations
- G.IsHamiltonian = (Fintype.card α ≠ 1 → ∃ (a : α) (p : G.Walk a a), p.IsHamiltonianCycle)