Documentation

Mathlib.Combinatorics.SimpleGraph.Finite

Definitions for finite and locally finite graphs #

This file defines finite versions of edgeSet, neighborSet and incidenceSet and proves some of their basic properties. It also defines the notion of a locally finite graph, which is one whose vertices have finite degree.

The design for finiteness is that each definition takes the smallest finiteness assumption necessary. For example, SimpleGraph.neighborFinset v only requires that v have finitely many neighbors.

Main definitions #

Naming conventions #

If the vertex type of a graph is finite, we refer to its cardinality as CardVerts or card_verts.

Implementation notes #

def SimpleGraph.edgeFinset {V : Type u_1} (G : SimpleGraph V) [Fintype ↑G.edgeSet] :

The edgeSet of the graph as a Finset.

Instances For
    @[simp]
    theorem SimpleGraph.coe_edgeFinset {V : Type u_1} (G : SimpleGraph V) [Fintype ↑G.edgeSet] :
    ↑G.edgeFinset = G.edgeSet
    @[simp]
    theorem SimpleGraph.mem_edgeFinset {V : Type u_1} {G : SimpleGraph V} {e : Sym2 V} [Fintype ↑G.edgeSet] :
    e ∈ G.edgeFinset ↔ e ∈ G.edgeSet
    theorem SimpleGraph.not_isDiag_of_mem_edgeFinset {V : Type u_1} {G : SimpleGraph V} {e : Sym2 V} [Fintype ↑G.edgeSet] :
    e ∈ G.edgeFinset → ¬e.IsDiag
    theorem SimpleGraph.card_toFinset_mem_edgeFinset {V : Type u_1} {G : SimpleGraph V} [Fintype ↑G.edgeSet] [DecidableEq V] (e : ↄG.edgeFinset) :
    (↑e).toFinset.card = 2

    Mapping an edge to a finite set produces a finset of size 2.

    @[simp]
    theorem SimpleGraph.edgeFinset_inj {V : Type u_1} {G₁ Gā‚‚ : SimpleGraph V} [Fintype ↑G₁.edgeSet] [Fintype ↑Gā‚‚.edgeSet] :
    G₁.edgeFinset = Gā‚‚.edgeFinset ↔ G₁ = Gā‚‚
    @[simp]
    theorem SimpleGraph.edgeFinset_subset_edgeFinset {V : Type u_1} {G₁ Gā‚‚ : SimpleGraph V} [Fintype ↑G₁.edgeSet] [Fintype ↑Gā‚‚.edgeSet] :
    G₁.edgeFinset āŠ† Gā‚‚.edgeFinset ↔ G₁ ≤ Gā‚‚
    @[simp]
    theorem SimpleGraph.edgeFinset_ssubset_edgeFinset {V : Type u_1} {G₁ Gā‚‚ : SimpleGraph V} [Fintype ↑G₁.edgeSet] [Fintype ↑Gā‚‚.edgeSet] :
    G₁.edgeFinset āŠ‚ Gā‚‚.edgeFinset ↔ G₁ < Gā‚‚
    theorem SimpleGraph.edgeFinset_mono {V : Type u_1} {G₁ Gā‚‚ : SimpleGraph V} [Fintype ↑G₁.edgeSet] [Fintype ↑Gā‚‚.edgeSet] :
    G₁ ≤ Gā‚‚ → G₁.edgeFinset āŠ† Gā‚‚.edgeFinset

    Alias of the reverse direction of SimpleGraph.edgeFinset_subset_edgeFinset.

    theorem SimpleGraph.edgeFinset_strict_mono {V : Type u_1} {G₁ Gā‚‚ : SimpleGraph V} [Fintype ↑G₁.edgeSet] [Fintype ↑Gā‚‚.edgeSet] :
    G₁ < Gā‚‚ → G₁.edgeFinset āŠ‚ Gā‚‚.edgeFinset

    Alias of the reverse direction of SimpleGraph.edgeFinset_ssubset_edgeFinset.

    @[simp]
    theorem SimpleGraph.edgeFinset_sup {V : Type u_1} {G₁ Gā‚‚ : SimpleGraph V} [Fintype ↑G₁.edgeSet] [Fintype ↑Gā‚‚.edgeSet] [Fintype ↑(G₁ āŠ” Gā‚‚).edgeSet] [DecidableEq V] :
    (G₁ āŠ” Gā‚‚).edgeFinset = G₁.edgeFinset ∪ Gā‚‚.edgeFinset
    @[simp]
    theorem SimpleGraph.edgeFinset_inf {V : Type u_1} {G₁ Gā‚‚ : SimpleGraph V} [Fintype ↑G₁.edgeSet] [Fintype ↑Gā‚‚.edgeSet] [DecidableEq V] :
    (G₁ āŠ“ Gā‚‚).edgeFinset = G₁.edgeFinset ∩ Gā‚‚.edgeFinset
    @[simp]
    theorem SimpleGraph.edgeFinset_sdiff {V : Type u_1} {G₁ Gā‚‚ : SimpleGraph V} [Fintype ↑G₁.edgeSet] [Fintype ↑Gā‚‚.edgeSet] [DecidableEq V] :
    (G₁ \ Gā‚‚).edgeFinset = G₁.edgeFinset \ Gā‚‚.edgeFinset
    @[simp]
    theorem SimpleGraph.disjoint_edgeFinset {V : Type u_1} {G₁ Gā‚‚ : SimpleGraph V} [Fintype ↑G₁.edgeSet] [Fintype ↑Gā‚‚.edgeSet] :
    Disjoint G₁.edgeFinset Gā‚‚.edgeFinset ↔ Disjoint G₁ Gā‚‚
    @[simp]
    theorem SimpleGraph.edgeFinset_eq_empty {V : Type u_1} {G : SimpleGraph V} [Fintype ↑G.edgeSet] :
    G.edgeFinset = āˆ… ↔ G = ⊄
    @[simp]
    theorem SimpleGraph.edgeFinset_nonempty {V : Type u_1} {G : SimpleGraph V} [Fintype ↑G.edgeSet] :
    G.edgeFinset.Nonempty ↔ G ≠ ⊄

    The complete graph on n vertices has n.choose 2 edges.

    Any graph on n vertices has at most n.choose 2 edges.

    Finiteness at a vertex #

    This section contains definitions and lemmas concerning vertices that have finitely many adjacent vertices. We denote this condition by Fintype (G.neighborSet v).

    We define G.neighborFinset v to be the Finset version of G.neighborSet v. Use neighborFinset_eq_filter to rewrite this definition as a Finset.filter expression.

    def SimpleGraph.neighborFinset {V : Type u_1} (G : SimpleGraph V) (v : V) [Fintype ↑(G.neighborSet v)] :

    G.neighborFinset v is the Finset version of G.neighborSet v in case G is locally finite at v.

    Instances For
      @[simp]
      theorem SimpleGraph.coe_neighborFinset {V : Type u_1} (G : SimpleGraph V) (v : V) [Fintype ↑(G.neighborSet v)] :
      ↑(G.neighborFinset v) = G.neighborSet v
      @[simp]
      theorem SimpleGraph.mem_neighborFinset {V : Type u_1} (G : SimpleGraph V) (v : V) [Fintype ↑(G.neighborSet v)] (w : V) :
      w ∈ G.neighborFinset v ↔ G.Adj v w
      def SimpleGraph.degree {V : Type u_1} (G : SimpleGraph V) (v : V) [Fintype ↑(G.neighborSet v)] :
      ā„•

      G.degree v is the number of vertices adjacent to v.

      Instances For
        @[simp]
        theorem SimpleGraph.card_neighborSet_eq_degree {V : Type u_1} (G : SimpleGraph V) (v : V) [Fintype ↑(G.neighborSet v)] :
        Fintype.card ↑(G.neighborSet v) = G.degree v
        theorem SimpleGraph.degree_pos_iff_exists_adj {V : Type u_1} (G : SimpleGraph V) (v : V) [Fintype ↑(G.neighborSet v)] :
        0 < G.degree v ↔ ∃ (w : V), G.Adj v w
        theorem SimpleGraph.degree_pos_iff_nonempty {V : Type u_1} {G : SimpleGraph V} {v : V} [Fintype ↑(G.neighborSet v)] :
        0 < G.degree v ↔ (G.neighborSet v).Nonempty
        theorem SimpleGraph.Adj.degree_pos_left {V : Type u_1} {G : SimpleGraph V} {v : V} [Fintype ↑(G.neighborSet v)] {w : V} (h : G.Adj v w) :
        0 < G.degree v
        theorem SimpleGraph.Adj.degree_pos_right {V : Type u_1} {G : SimpleGraph V} {v : V} [Fintype ↑(G.neighborSet v)] {w : V} (h : G.Adj w v) :
        0 < G.degree v
        theorem SimpleGraph.degree_pos_iff_mem_support {V : Type u_1} (G : SimpleGraph V) (v : V) [Fintype ↑(G.neighborSet v)] :
        0 < G.degree v ↔ v ∈ G.support
        theorem SimpleGraph.degree_eq_zero_iff_notMem_support {V : Type u_1} (G : SimpleGraph V) (v : V) [Fintype ↑(G.neighborSet v)] :
        G.degree v = 0 ↔ v āˆ‰ G.support
        @[simp]
        theorem SimpleGraph.degree_eq_zero_of_subsingleton {V : Type u_1} {G : SimpleGraph V} (v : V) [Fintype ↑(G.neighborSet v)] [Subsingleton V] :
        G.degree v = 0
        theorem SimpleGraph.degree_eq_one_iff_existsUnique_adj {V : Type u_1} {G : SimpleGraph V} {v : V} [Fintype ↑(G.neighborSet v)] :
        G.degree v = 1 ↔ ∃! w : V, G.Adj v w
        theorem SimpleGraph.nontrivial_of_degree_ne_zero {V : Type u_1} {G : SimpleGraph V} {v : V} [Fintype ↑(G.neighborSet v)] (h : G.degree v ≠ 0) :
        theorem SimpleGraph.degree_compl {V : Type u_1} (G : SimpleGraph V) (v : V) [Fintype ↑(G.neighborSet v)] [Fintype ↑(Gᶜ.neighborSet v)] [Fintype V] :
        Gᶜ.degree v = Fintype.card V - 1 - G.degree v
        @[implicit_reducible]
        instance SimpleGraph.incidenceSetFintype {V : Type u_1} (G : SimpleGraph V) (v : V) [Fintype ↑(G.neighborSet v)] [DecidableEq V] :
        Fintype ↑(G.incidenceSet v)
        def SimpleGraph.incidenceFinset {V : Type u_1} (G : SimpleGraph V) (v : V) [Fintype ↑(G.neighborSet v)] [DecidableEq V] :

        This is the Finset version of incidenceSet.

        Instances For
          @[simp]
          theorem SimpleGraph.card_incidenceSet_eq_degree {V : Type u_1} (G : SimpleGraph V) (v : V) [Fintype ↑(G.neighborSet v)] [DecidableEq V] :
          Fintype.card ↑(G.incidenceSet v) = G.degree v
          @[simp]
          theorem SimpleGraph.coe_incidenceFinset {V : Type u_1} (G : SimpleGraph V) (v : V) [Fintype ↑(G.neighborSet v)] [DecidableEq V] :
          ↑(G.incidenceFinset v) = G.incidenceSet v
          @[simp]
          theorem SimpleGraph.card_incidenceFinset_eq_degree {V : Type u_1} (G : SimpleGraph V) (v : V) [Fintype ↑(G.neighborSet v)] [DecidableEq V] :
          @[simp]
          theorem SimpleGraph.mem_incidenceFinset {V : Type u_1} (G : SimpleGraph V) (v : V) [Fintype ↑(G.neighborSet v)] [DecidableEq V] (e : Sym2 V) :
          e ∈ G.incidenceFinset v ↔ e ∈ G.incidenceSet v
          theorem SimpleGraph.incidenceFinset_eq_filter {V : Type u_1} (G : SimpleGraph V) (v : V) [Fintype ↑(G.neighborSet v)] [DecidableEq V] [Fintype ↑G.edgeSet] :
          G.incidenceFinset v = {e ∈ G.edgeFinset | v ∈ e}
          theorem SimpleGraph.incidenceFinset_subset {V : Type u_1} (G : SimpleGraph V) (v : V) [Fintype ↑(G.neighborSet v)] [DecidableEq V] [Fintype ↑G.edgeSet] :
          theorem SimpleGraph.degree_le_card_edgeFinset {V : Type u_1} (G : SimpleGraph V) (v : V) [Fintype ↑(G.neighborSet v)] [Fintype ↑G.edgeSet] :

          The degree of a vertex is at most the number of edges.

          theorem SimpleGraph.degree_le_of_le {V : Type u_1} {G : SimpleGraph V} {v : V} [Fintype ↑(G.neighborSet v)] {H : SimpleGraph V} [Fintype ↑(H.neighborSet v)] (hle : G ≤ H) :

          If G ≤ H then G.degree v ≤ H.degree v for any vertex v.

          @[reducible, inline]
          abbrev SimpleGraph.LocallyFinite {V : Type u_1} (G : SimpleGraph V) :
          Type u_1

          A graph is locally finite if every vertex has a finite neighbor set.

          Instances For
            def SimpleGraph.IsRegularOfDegree {V : Type u_1} (G : SimpleGraph V) [G.LocallyFinite] (d : ā„•) :

            A locally finite simple graph is regular of degree d if every vertex has degree d.

            Instances For
              theorem SimpleGraph.IsRegularOfDegree.degree_eq {V : Type u_1} {G : SimpleGraph V} [G.LocallyFinite] {d : ā„•} (h : G.IsRegularOfDegree d) (v : V) :
              G.degree v = d
              theorem SimpleGraph.IsRegularOfDegree.compl {V : Type u_1} [Fintype V] [DecidableEq V] {G : SimpleGraph V} [DecidableRel G.Adj] {k : ā„•} (h : G.IsRegularOfDegree k) :
              @[implicit_reducible]
              instance SimpleGraph.neighborSetFintype {V : Type u_1} (G : SimpleGraph V) [Fintype V] [DecidableRel G.Adj] (v : V) :
              Fintype ↑(G.neighborSet v)
              theorem SimpleGraph.neighborFinset_eq_filter {V : Type u_1} (G : SimpleGraph V) [Fintype V] {v : V} [DecidableRel G.Adj] :
              G.neighborFinset v = {w : V | G.Adj v w}
              theorem SimpleGraph.neighborFinset_compl {V : Type u_1} (G : SimpleGraph V) [Fintype V] [DecidableEq V] [DecidableRel G.Adj] (v : V) :
              @[simp]
              theorem SimpleGraph.complete_graph_degree {V : Type u_1} [Fintype V] [DecidableEq V] (v : V) :
              @[simp]
              theorem SimpleGraph.bot_degree {V : Type u_1} [Fintype V] (v : V) :
              def SimpleGraph.minDegree {V : Type u_1} (G : SimpleGraph V) [Fintype V] [DecidableRel G.Adj] :
              ā„•

              The minimum degree of all vertices (and 0 if there are no vertices). The key properties of this are given in exists_minimal_degree_vertex, minDegree_le_degree and le_minDegree_of_forall_le_degree.

              Instances For
                theorem SimpleGraph.exists_minimal_degree_vertex {V : Type u_1} (G : SimpleGraph V) [Fintype V] [DecidableRel G.Adj] [Nonempty V] :
                ∃ (v : V), G.minDegree = G.degree v

                There exists a vertex of minimal degree. Note the assumption of being nonempty is necessary, as the lemma implies there exists a vertex.

                theorem SimpleGraph.minDegree_le_degree {V : Type u_1} (G : SimpleGraph V) [Fintype V] [DecidableRel G.Adj] (v : V) :

                The minimum degree in the graph is at most the degree of any particular vertex.

                theorem SimpleGraph.le_minDegree_of_forall_le_degree {V : Type u_1} (G : SimpleGraph V) [Fintype V] [DecidableRel G.Adj] [Nonempty V] (k : ā„•) (h : āˆ€ (v : V), k ≤ G.degree v) :

                In a nonempty graph, if k is at most the degree of every vertex, it is at most the minimum degree. Note the assumption that the graph is nonempty is necessary as long as G.minDegree is defined to be a natural.

                @[simp]
                theorem SimpleGraph.minDegree_of_isEmpty {V : Type u_1} (G : SimpleGraph V) [Fintype V] [DecidableRel G.Adj] [IsEmpty V] :
                G.minDegree = 0

                If there are no vertices then the minDegree is zero.

                theorem SimpleGraph.minDegree_le_minDegree {V : Type u_1} {G : SimpleGraph V} [Fintype V] {H : SimpleGraph V} [DecidableRel G.Adj] [DecidableRel H.Adj] (hle : G ≤ H) :

                If G is a subgraph of H then G.minDegree ≤ H.minDegree.

                theorem SimpleGraph.minDegree_lt_card {V : Type u_1} (G : SimpleGraph V) [Fintype V] [DecidableRel G.Adj] [Nonempty V] :

                In a nonempty graph, the minimal degree is less than the number of vertices.

                def SimpleGraph.maxDegree {V : Type u_1} (G : SimpleGraph V) [Fintype V] [DecidableRel G.Adj] :
                ā„•

                The maximum degree of all vertices (and 0 if there are no vertices). The key properties of this are given in exists_maximal_degree_vertex, degree_le_maxDegree and maxDegree_le_of_forall_degree_le.

                Instances For
                  theorem SimpleGraph.exists_maximal_degree_vertex {V : Type u_1} (G : SimpleGraph V) [Fintype V] [DecidableRel G.Adj] [Nonempty V] :
                  ∃ (v : V), G.maxDegree = G.degree v

                  There exists a vertex of maximal degree. Note the assumption of being nonempty is necessary, as the lemma implies there exists a vertex.

                  theorem SimpleGraph.degree_le_maxDegree {V : Type u_1} (G : SimpleGraph V) [Fintype V] [DecidableRel G.Adj] (v : V) :

                  The maximum degree in the graph is at least the degree of any particular vertex.

                  @[simp]
                  theorem SimpleGraph.maxDegree_of_isEmpty {V : Type u_1} (G : SimpleGraph V) [Fintype V] [DecidableRel G.Adj] [IsEmpty V] :
                  G.maxDegree = 0
                  theorem SimpleGraph.maxDegree_le_of_forall_degree_le {V : Type u_1} (G : SimpleGraph V) [Fintype V] [DecidableRel G.Adj] (k : ā„•) (h : āˆ€ (v : V), G.degree v ≤ k) :

                  In a graph, if k is at least the degree of every vertex, then it is at least the maximum degree.

                  theorem SimpleGraph.degree_lt_card_verts {V : Type u_1} (G : SimpleGraph V) [Fintype V] [DecidableRel G.Adj] (v : V) :
                  theorem SimpleGraph.maxDegree_lt_card_verts {V : Type u_1} (G : SimpleGraph V) [Fintype V] [DecidableRel G.Adj] [Nonempty V] :

                  The maximum degree of a nonempty graph is less than the number of vertices. Note that the assumption that V is nonempty is necessary, as otherwise this would assert the existence of a natural number less than zero.

                  theorem SimpleGraph.Adj.card_commonNeighbors_lt_degree {V : Type u_1} [Fintype V] {G : SimpleGraph V} [DecidableRel G.Adj] {v w : V} (h : G.Adj v w) :

                  If the condition G.Adj v w fails, then card_commonNeighbors_le_degree is the best we can do in general.

                  theorem SimpleGraph.card_commonNeighbors_top {V : Type u_1} [Fintype V] [DecidableEq V] {v w : V} (h : v ≠ w) :
                  theorem SimpleGraph.Iso.card_edgeFinset_eq {V : Type u_1} {G : SimpleGraph V} {W : Type u_2} {G' : SimpleGraph W} (f : G ā‰ƒg G') [Fintype ↑G.edgeSet] [Fintype ↑G'.edgeSet] :
                  @[simp]
                  theorem SimpleGraph.Iso.degree_eq {V : Type u_1} {G : SimpleGraph V} {W : Type u_2} {G' : SimpleGraph W} (f : G ā‰ƒg G') (x : V) [Fintype ↑(G.neighborSet x)] [Fintype ↑(G'.neighborSet (f x))] :
                  G'.degree (f x) = G.degree x
                  theorem SimpleGraph.Iso.minDegree_eq {V : Type u_1} {G : SimpleGraph V} {W : Type u_2} {G' : SimpleGraph W} [Fintype V] [DecidableRel G.Adj] [Fintype W] [DecidableRel G'.Adj] (f : G ā‰ƒg G') :
                  theorem SimpleGraph.Iso.maxDegree_eq {V : Type u_1} {G : SimpleGraph V} {W : Type u_2} {G' : SimpleGraph W} [Fintype V] [DecidableRel G.Adj] [Fintype W] [DecidableRel G'.Adj] (f : G ā‰ƒg G') :
                  theorem SimpleGraph.edgeFinset_subset_sym2_of_support_subset {V : Type u_1} {s : Set V} [DecidablePred fun (x : V) => x ∈ s] [Fintype V] {G : SimpleGraph V} [DecidableRel G.Adj] (h : G.support āŠ† s) :
                  @[implicit_reducible]
                  instance SimpleGraph.instDecidablePredMemSetSupport {V : Type u_1} [Fintype V] {G : SimpleGraph V} [DecidableRel G.Adj] :
                  DecidablePred fun (x : V) => x ∈ G.support
                  theorem SimpleGraph.map_edgeFinset_induce {V : Type u_1} {s : Set V} [DecidablePred fun (x : V) => x ∈ s] [Fintype V] {G : SimpleGraph V} [DecidableRel G.Adj] [DecidableEq V] :
                  Finset.map (Function.Embedding.subtype fun (x : V) => x ∈ s).sym2Map (induce s G).edgeFinset = G.edgeFinset ∩ s.toFinset.sym2
                  theorem SimpleGraph.map_edgeFinset_induce_of_support_subset {V : Type u_1} {s : Set V} [DecidablePred fun (x : V) => x ∈ s] [Fintype V] {G : SimpleGraph V} [DecidableRel G.Adj] (h : G.support āŠ† s) :
                  theorem SimpleGraph.card_edgeFinset_induce_of_support_subset {V : Type u_1} {s : Set V} [DecidablePred fun (x : V) => x ∈ s] [Fintype V] {G : SimpleGraph V} [DecidableRel G.Adj] (h : G.support āŠ† s) :

                  If the support of the simple graph G is a subset of the set s, then the induced subgraph of s has the same number of edges as G.

                  theorem SimpleGraph.map_neighborFinset_induce {V : Type u_1} {s : Set V} [DecidablePred fun (x : V) => x ∈ s] [Fintype V] {G : SimpleGraph V} [DecidableRel G.Adj] [DecidableEq V] (v : ↑s) :
                  Finset.map (Function.Embedding.subtype fun (x : V) => x ∈ s) ((induce s G).neighborFinset v) = G.neighborFinset ↑v ∩ s.toFinset
                  theorem SimpleGraph.map_neighborFinset_induce_of_neighborSet_subset {V : Type u_1} {s : Set V} [DecidablePred fun (x : V) => x ∈ s] [Fintype V] {G : SimpleGraph V} [DecidableRel G.Adj] {v : ↑s} (h : G.neighborSet ↑v āŠ† s) :
                  Finset.map (Function.Embedding.subtype fun (x : V) => x ∈ s) ((induce s G).neighborFinset v) = G.neighborFinset ↑v
                  theorem SimpleGraph.degree_induce_of_neighborSet_subset {V : Type u_1} {s : Set V} [DecidablePred fun (x : V) => x ∈ s] [Fintype V] {G : SimpleGraph V} [DecidableRel G.Adj] {v : ↑s} (h : G.neighborSet ↑v āŠ† s) :
                  (induce s G).degree v = G.degree ↑v

                  If the neighbor set of a vertex v is a subset of s, then the degree of the vertex in the induced subgraph of s is the same as in G.

                  theorem SimpleGraph.degree_induce_of_support_subset {V : Type u_1} {s : Set V} [DecidablePred fun (x : V) => x ∈ s] [Fintype V] {G : SimpleGraph V} [DecidableRel G.Adj] (h : G.support āŠ† s) (v : ↑s) :
                  (induce s G).degree v = G.degree ↑v

                  If the support of the simple graph G is a subset of the set s, then the degree of vertices in the induced subgraph of s are the same as in G.

                  @[simp]
                  theorem SimpleGraph.degree_induce_support {V : Type u_1} [Fintype V] {G : SimpleGraph V} [DecidableRel G.Adj] (v : ↑G.support) :
                  (induce G.support G).degree v = G.degree ↑v
                  @[simp]
                  theorem SimpleGraph.edgeFinset_map {V : Type u_1} [Fintype V] {W : Type u_2} [Fintype W] [DecidableEq W] (f : V ↪ W) (G : SimpleGraph V) [DecidableRel G.Adj] :
                  theorem SimpleGraph.card_edgeFinset_map {V : Type u_1} [Fintype V] {W : Type u_2} [Fintype W] [DecidableEq W] (f : V ↪ W) (G : SimpleGraph V) [DecidableRel G.Adj] :