Documentation

Mathlib.Combinatorics.SimpleGraph.Hamiltonian

Hamiltonian Graphs #

In this file we introduce Hamiltonian paths, cycles and graphs.

Main definitions #

def SimpleGraph.Walk.IsHamiltonian {α : Type u_1} [DecidableEq α] {G : SimpleGraph α} {a b : α} (p : G.Walk a b) :

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.

Instances For
    theorem SimpleGraph.Walk.IsHamiltonian.map {α : Type u_1} [DecidableEq α] {G : SimpleGraph α} {β : Type u_2} [DecidableEq β] {H : SimpleGraph β} {a b : α} {p : G.Walk a b} (f : G →g H) (hf : Function.Bijective f) (hp : p.IsHamiltonian) :
    @[simp]
    theorem SimpleGraph.Walk.IsHamiltonian.mem_support {α : Type u_1} [DecidableEq α] {G : SimpleGraph α} {a b : α} {p : G.Walk a b} (hp : p.IsHamiltonian) (c : α) :
    c p.support

    A Hamiltonian path visits every vertex.

    theorem SimpleGraph.Walk.IsHamiltonian.isPath {α : Type u_1} [DecidableEq α] {G : SimpleGraph α} {a b : α} {p : G.Walk a b} (hp : p.IsHamiltonian) :

    Hamiltonian paths are paths.

    theorem SimpleGraph.Walk.IsPath.isHamiltonian_of_mem {α : Type u_1} [DecidableEq α] {G : SimpleGraph α} {a b : α} {p : G.Walk a b} (hp : p.IsPath) (hp' : ∀ (w : α), w p.support) :

    A path whose support contains every vertex is Hamiltonian.

    theorem SimpleGraph.Walk.IsPath.isHamiltonian_iff {α : Type u_1} [DecidableEq α] {G : SimpleGraph α} {a b : α} {p : G.Walk a b} (hp : p.IsPath) :
    p.IsHamiltonian ∀ (w : α), w p.support
    theorem SimpleGraph.Walk.IsHamiltonian.of_subsingleton {α : Type u_1} [DecidableEq α] {G : SimpleGraph α} {a b : α} {p : G.Walk a b} [Subsingleton α] :
    @[implicit_reducible]
    def SimpleGraph.Walk.IsHamiltonian.fintype {α : Type u_1} [DecidableEq α] {G : SimpleGraph α} {a b : α} {p : G.Walk a b} (hp : p.IsHamiltonian) :

    If a path p is Hamiltonian then its vertex set must be finite.

    Instances For
      theorem SimpleGraph.Walk.IsHamiltonian.toFinset_support {α : Type u_1} [DecidableEq α] {G : SimpleGraph α} {a b : α} {p : G.Walk a b} [Fintype α] (hp : p.IsHamiltonian) :

      The support of a Hamiltonian walk is the entire vertex set.

      @[deprecated SimpleGraph.Walk.IsHamiltonian.toFinset_support (since := "2026-03-11")]
      theorem SimpleGraph.Walk.IsHamiltonian.support_toFinset {α : Type u_1} [DecidableEq α] {G : SimpleGraph α} {a b : α} {p : G.Walk a b} [Fintype α] (hp : p.IsHamiltonian) :

      Alias of SimpleGraph.Walk.IsHamiltonian.toFinset_support.


      The support of a Hamiltonian walk is the entire vertex set.

      theorem SimpleGraph.Walk.IsHamiltonian.setOf_support {α : Type u_1} [DecidableEq α] {G : SimpleGraph α} {a b : α} {p : G.Walk a b} (hp : p.IsHamiltonian) :
      {v : α | v p.support} = Set.univ
      theorem SimpleGraph.Walk.IsHamiltonian.length_eq {α : Type u_1} [DecidableEq α] {G : SimpleGraph α} {a b : α} {p : G.Walk a b} [Fintype α] (hp : p.IsHamiltonian) :
      p.length = Fintype.card α - 1

      The length of a Hamiltonian path is one less than the number of vertices of the graph.

      theorem SimpleGraph.Walk.IsHamiltonian.length_support {α : Type u_1} [DecidableEq α] {G : SimpleGraph α} {a b : α} {p : G.Walk a b} [Fintype α] (hp : p.IsHamiltonian) :
      p.support.length = Fintype.card α

      The length of the support of a Hamiltonian path equals the number of vertices of the graph.

      def SimpleGraph.Walk.IsHamiltonian.supportGetEquiv {α : Type u_1} [DecidableEq α] {G : SimpleGraph α} {a b : α} {p : G.Walk a b} (hp : p.IsHamiltonian) :
      Fin p.support.length α

      If a path p is Hamiltonian, then p.support.get defines an equivalence between Fin p.support.length and α.

      Instances For
        @[simp]
        theorem SimpleGraph.Walk.IsHamiltonian.supportGetEquiv_apply {α : Type u_1} [DecidableEq α] {G : SimpleGraph α} {a b : α} {p : G.Walk a b} (hp : p.IsHamiltonian) (i : Fin p.support.length) :
        hp.supportGetEquiv i = p.support[i]
        @[simp]
        theorem SimpleGraph.Walk.IsHamiltonian.supportGetEquiv_symm_apply_val {α : Type u_1} [DecidableEq α] {G : SimpleGraph α} {a b : α} {p : G.Walk a b} (hp : p.IsHamiltonian) (a✝ : α) :
        (hp.supportGetEquiv.symm a✝) = List.idxOf a✝ p.support
        def SimpleGraph.Walk.IsHamiltonian.getVertEquiv {α : Type u_1} [DecidableEq α] {G : SimpleGraph α} {a b : α} {p : G.Walk a b} (hp : p.IsHamiltonian) :
        Fin p.support.length α

        If a path p is Hamiltonian, then p.getVert defines an equivalence between Fin p.support.length and α.

        Instances For
          @[simp]
          theorem SimpleGraph.Walk.IsHamiltonian.getVertEquiv_symm_apply {α : Type u_1} [DecidableEq α] {G : SimpleGraph α} {a b : α} {p : G.Walk a b} (hp : p.IsHamiltonian) (a✝ : α) :
          @[simp]
          theorem SimpleGraph.Walk.IsHamiltonian.getVertEquiv_apply {α : Type u_1} [DecidableEq α] {G : SimpleGraph α} {a b : α} {p : G.Walk a b} (hp : p.IsHamiltonian) (a✝ : Fin p.support.length) :
          hp.getVertEquiv a✝ = (p.getVert Fin.val) a✝
          theorem SimpleGraph.Walk.isHamiltonian_iff_support_get_bijective {α : Type u_1} [DecidableEq α] {G : SimpleGraph α} {a b : α} {p : G.Walk a b} :
          theorem SimpleGraph.Walk.IsHamiltonian.getVert_surjective {α : Type u_1} [DecidableEq α] {G : SimpleGraph α} {a b : α} {p : G.Walk a b} (hp : p.IsHamiltonian) :
          Function.Surjective p.getVert
          theorem SimpleGraph.Walk.IsHamiltonian.injective_of_isPath_map {α : Type u_1} [DecidableEq α] {G : SimpleGraph α} {β : Type u_2} {H : SimpleGraph β} {a b : α} {p : G.Walk a b} {f : G →g H} (hp : p.IsHamiltonian) (h : (Walk.map f p).IsPath) :
          Function.Injective f
          theorem SimpleGraph.Walk.isHamiltonian_iff_isPath_and_length_eq {α : Type u_1} [DecidableEq α] {G : SimpleGraph α} {a b : α} {p : G.Walk a b} [Fintype α] :
          p.IsHamiltonian p.IsPath p.length = Fintype.card α - 1
          structure SimpleGraph.Walk.IsHamiltonianCycle {α : Type u_1} [DecidableEq α] {G : SimpleGraph α} {a : α} (p : G.Walk a a) extends p.IsCycle :

          A Hamiltonian cycle is a cycle that visits every vertex once.

          Instances For
            theorem SimpleGraph.Walk.IsHamiltonianCycle.isCycle {α : Type u_1} [DecidableEq α] {G : SimpleGraph α} {a : α} {p : G.Walk a a} (hp : p.IsHamiltonianCycle) :
            theorem SimpleGraph.Walk.IsHamiltonianCycle.map {α : Type u_1} [DecidableEq α] {G : SimpleGraph α} {β : Type u_2} [DecidableEq β] {H : SimpleGraph β} {a : α} {f : G →g H} {p : G.Walk a a} (hf : Function.Bijective f) (hp : p.IsHamiltonianCycle) :
            theorem SimpleGraph.Walk.isHamiltonianCycle_iff_isCycle_and_support_count_tail_eq_one {α : Type u_1} [DecidableEq α] {G : SimpleGraph α} {a : α} {p : G.Walk a a} :
            p.IsHamiltonianCycle p.IsCycle ∀ (a_1 : α), List.count a_1 p.support.tail = 1
            theorem SimpleGraph.Walk.IsHamiltonianCycle.mem_support {α : Type u_1} [DecidableEq α] {G : SimpleGraph α} {a : α} {p : G.Walk a a} (hp : p.IsHamiltonianCycle) (b : α) :
            b p.support

            A Hamiltonian cycle visits every vertex.

            theorem SimpleGraph.Walk.IsHamiltonianCycle.length_eq {α : Type u_1} [DecidableEq α] {G : SimpleGraph α} {a : α} {p : G.Walk a a} [Fintype α] (hp : p.IsHamiltonianCycle) :

            The length of a Hamiltonian cycle is the number of vertices.

            theorem SimpleGraph.Walk.IsHamiltonianCycle.count_support_self {α : Type u_1} [DecidableEq α] {G : SimpleGraph α} {a : α} {p : G.Walk a a} (hp : p.IsHamiltonianCycle) :
            List.count a p.support = 2
            theorem SimpleGraph.Walk.IsHamiltonianCycle.support_count_of_ne {α : Type u_1} [DecidableEq α] {G : SimpleGraph α} {a b : α} {p : G.Walk a a} (hp : p.IsHamiltonianCycle) (h : a b) :
            List.count b p.support = 1
            theorem SimpleGraph.Walk.isHamiltonianCycle_iff_isCycle_and_length_eq {α : Type u_1} [DecidableEq α] {G : SimpleGraph α} {a : α} {p : G.Walk a a} [Fintype α] :
            def SimpleGraph.IsHamiltonian {α : Type u_1} [DecidableEq α] [Fintype α] (G : SimpleGraph α) :

            A Hamiltonian graph is a graph that contains a Hamiltonian cycle.

            By convention, the singleton graph is considered to be Hamiltonian.

            Instances For
              theorem SimpleGraph.IsHamiltonian.mono {α : Type u_1} [DecidableEq α] {G : SimpleGraph α} [Fintype α] {H : SimpleGraph α} (hGH : G H) (hG : G.IsHamiltonian) :
              theorem SimpleGraph.IsHamiltonian.connected {α : Type u_1} [DecidableEq α] {G : SimpleGraph α} [Fintype α] (hG : G.IsHamiltonian) :
              theorem SimpleGraph.IsHamiltonian.of_card_eq_one {α : Type u_1} [DecidableEq α] {G : SimpleGraph α} [Fintype α] (h : Fintype.card α = 1) :
              theorem SimpleGraph.not_isHamiltonian_of_card_eq_two {α : Type u_1} [DecidableEq α] {G : SimpleGraph α} [Fintype α] (h : Fintype.card α = 2) :
              @[simp]
              theorem SimpleGraph.not_isHamiltonian_bot_of_card_ne_one {α : Type u_1} [DecidableEq α] [Fintype α] (h : Fintype.card α 1) :
              theorem SimpleGraph.IsHamiltonian.of_unique {α : Type u_1} [DecidableEq α] {G : SimpleGraph α} [Fintype α] [Unique α] :
              theorem SimpleGraph.not_isHamiltonian_of_isBridge {V : Type u_3} [Fintype V] [DecidableEq V] (G : SimpleGraph V) (h_order : 3 Fintype.card V) (e : Sym2 V) (he : G.IsBridge e) :

              A finite simple graph with at least three vertices and a bridge is not Hamiltonian.

              More precisely, let G : SimpleGraph V be a simple graph on a finite vertex type V. If Fintype.card V ≥ 3 and there exists an edge of G which is a bridge, then G does not admit a Hamiltonian cycle, i.e. ¬ G.IsHamiltonian.