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.
The length of the support of a Hamiltonian path equals the number of vertices of the graph.
If a path p is Hamiltonian, then p.support.get defines an equivalence between
Fin p.support.length and α.
Equations
Instances For
If a path p is Hamiltonian, then p.getVert defines an equivalence between
Fin p.support.length and α.
Equations
- hp.getVertEquiv = { toFun := p.getVert ∘ Fin.val, invFun := hp.supportGetEquiv.invFun, left_inv := ⋯, right_inv := ⋯ }
Instances For
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)