Documentation

Mathlib.Combinatorics.SimpleGraph.Basic

Simple graphs #

This module defines simple graphs on a vertex type V as an irreflexive symmetric relation.

There is a basic API for locally finite graphs and for graphs with finitely many vertices.

Main definitions #

Notations #

Implementation notes #

Naming Conventions #

Todo #

A variant of the aesop tactic for use in the graph library. Changes relative to standard aesop:

  • We use the SimpleGraph rule set in addition to the default rule sets.
  • We instruct Aesop's intro rule to unfold with default transparency.
  • We instruct Aesop to fail if it can't fully solve the goal. This allows us to use aesop_graph for auto-params.
Instances For

    Use aesop_graph? to pass along a Try this suggestion when using aesop_graph

    Instances For

      A variant of aesop_graph which does not fail if it is unable to solve the goal. Use this only for exploration! Nonterminal Aesop is even worse than nonterminal simp.

      Instances For
        theorem SimpleGraph.ext {V : Type u} (x : SimpleGraph V) (y : SimpleGraph V) (Adj : x.Adj = y.Adj) :
        x = y
        theorem SimpleGraph.ext_iff {V : Type u} (x : SimpleGraph V) (y : SimpleGraph V) :
        x = y x.Adj = y.Adj
        structure SimpleGraph (V : Type u) :

        A simple graph is an irreflexive symmetric relation Adj on a vertex type V. The relation describes which pairs of vertices are adjacent. There is exactly one edge for every pair of adjacent vertices; see SimpleGraph.edgeSet for the corresponding edge set.

        Instances For
          @[simp]
          theorem SimpleGraph.mk'_apply_Adj {V : Type u} (x : { adj // (∀ (x y : V), adj x y = adj y x) ∀ (x : V), ¬adj x x = true }) (v : V) (w : V) :
          SimpleGraph.Adj (SimpleGraph.mk' x) v w = (x v w = true)
          def SimpleGraph.mk' {V : Type u} :
          { adj // (∀ (x y : V), adj x y = adj y x) ∀ (x : V), ¬adj x x = true } SimpleGraph V

          Constructor for simple graphs using a symmetric irreflexive boolean function.

          Instances For

            We can enumerate simple graphs by enumerating all functions V → V → Bool and filtering on whether they are symmetric and irreflexive.

            def SimpleGraph.fromRel {V : Type u} (r : VVProp) :

            Construct the simple graph induced by the given relation. It symmetrizes the relation and makes it irreflexive.

            Instances For
              @[simp]
              theorem SimpleGraph.fromRel_adj {V : Type u} (r : VVProp) (v : V) (w : V) :
              SimpleGraph.Adj (SimpleGraph.fromRel r) v w v w (r v w r w v)

              The complete graph on a type V is the simple graph with all pairs of distinct vertices adjacent. In Mathlib, this is usually referred to as .

              Instances For
                def emptyGraph (V : Type u) :

                The graph with no edges on a given vertex type V. Mathlib prefers the notation .

                Instances For
                  def completeBipartiteGraph (V : Type u_1) (W : Type u_2) :

                  Two vertices are adjacent in the complete bipartite graph on two vertex types if and only if they are not from the same side. Any bipartite graph may be regarded as a subgraph of one of these.

                  Instances For
                    @[simp]
                    theorem SimpleGraph.irrefl {V : Type u} (G : SimpleGraph V) {v : V} :
                    theorem SimpleGraph.adj_comm {V : Type u} (G : SimpleGraph V) (u : V) (v : V) :
                    theorem SimpleGraph.adj_symm {V : Type u} (G : SimpleGraph V) {u : V} {v : V} (h : SimpleGraph.Adj G u v) :
                    theorem SimpleGraph.Adj.symm {V : Type u} {G : SimpleGraph V} {u : V} {v : V} (h : SimpleGraph.Adj G u v) :
                    theorem SimpleGraph.ne_of_adj {V : Type u} (G : SimpleGraph V) {a : V} {b : V} (h : SimpleGraph.Adj G a b) :
                    a b
                    theorem SimpleGraph.Adj.ne {V : Type u} {G : SimpleGraph V} {a : V} {b : V} (h : SimpleGraph.Adj G a b) :
                    a b
                    theorem SimpleGraph.Adj.ne' {V : Type u} {G : SimpleGraph V} {a : V} {b : V} (h : SimpleGraph.Adj G a b) :
                    b a
                    theorem SimpleGraph.ne_of_adj_of_not_adj {V : Type u} (G : SimpleGraph V) {v : V} {w : V} {x : V} (h : SimpleGraph.Adj G v x) (hn : ¬SimpleGraph.Adj G w x) :
                    v w
                    @[simp]
                    theorem SimpleGraph.adj_inj {V : Type u} {G : SimpleGraph V} {H : SimpleGraph V} :
                    G.Adj = H.Adj G = H

                    The relation that one SimpleGraph is a subgraph of another. Note that this should be spelled .

                    Instances For
                      @[simp]
                      theorem SimpleGraph.isSubgraph_eq_le {V : Type u} :
                      SimpleGraph.IsSubgraph = fun x x_1 => x x_1

                      The supremum of two graphs x ⊔ y has edges where either x or y have edges.

                      @[simp]
                      theorem SimpleGraph.sup_adj {V : Type u} (x : SimpleGraph V) (y : SimpleGraph V) (v : V) (w : V) :

                      The infimum of two graphs x ⊓ y has edges where both x and y have edges.

                      @[simp]
                      theorem SimpleGraph.inf_adj {V : Type u} (x : SimpleGraph V) (y : SimpleGraph V) (v : V) (w : V) :

                      We define Gᶜ to be the SimpleGraph V such that no two adjacent vertices in G are adjacent in the complement, and every nonadjacent pair of vertices is adjacent (still ensuring that vertices are not adjacent to themselves).

                      @[simp]
                      theorem SimpleGraph.compl_adj {V : Type u} (G : SimpleGraph V) (v : V) (w : V) :
                      instance SimpleGraph.sdiff {V : Type u} :

                      The difference of two graphs x \ y has the edges of x with the edges of y removed.

                      @[simp]
                      theorem SimpleGraph.sdiff_adj {V : Type u} (x : SimpleGraph V) (y : SimpleGraph V) (v : V) (w : V) :
                      @[simp]
                      theorem SimpleGraph.sSup_adj {V : Type u} {s : Set (SimpleGraph V)} {a : V} {b : V} :
                      SimpleGraph.Adj (sSup s) a b G, G s SimpleGraph.Adj G a b
                      @[simp]
                      theorem SimpleGraph.sInf_adj {V : Type u} {a : V} {b : V} {s : Set (SimpleGraph V)} :
                      SimpleGraph.Adj (sInf s) a b (∀ (G : SimpleGraph V), G sSimpleGraph.Adj G a b) a b
                      @[simp]
                      theorem SimpleGraph.iSup_adj {ι : Sort u_1} {V : Type u} {a : V} {b : V} {f : ιSimpleGraph V} :
                      SimpleGraph.Adj (⨆ (i : ι), f i) a b i, SimpleGraph.Adj (f i) a b
                      @[simp]
                      theorem SimpleGraph.iInf_adj {ι : Sort u_1} {V : Type u} {a : V} {b : V} {f : ιSimpleGraph V} :
                      SimpleGraph.Adj (⨅ (i : ι), f i) a b (∀ (i : ι), SimpleGraph.Adj (f i) a b) a b
                      theorem SimpleGraph.sInf_adj_of_nonempty {V : Type u} {a : V} {b : V} {s : Set (SimpleGraph V)} (hs : Set.Nonempty s) :
                      SimpleGraph.Adj (sInf s) a b ∀ (G : SimpleGraph V), G sSimpleGraph.Adj G a b
                      theorem SimpleGraph.iInf_adj_of_nonempty {ι : Sort u_1} {V : Type u} {a : V} {b : V} [Nonempty ι] {f : ιSimpleGraph V} :
                      SimpleGraph.Adj (⨅ (i : ι), f i) a b ∀ (i : ι), SimpleGraph.Adj (f i) a b

                      For graphs G, H, G ≤ H iff ∀ a b, G.Adj a b → H.Adj a b.

                      @[simp]
                      theorem SimpleGraph.top_adj {V : Type u} (v : V) (w : V) :
                      @[simp]
                      theorem SimpleGraph.bot_adj {V : Type u} (v : V) (w : V) :
                      instance SimpleGraph.Sup.adjDecidable (V : Type u) (G : SimpleGraph V) (H : SimpleGraph V) [DecidableRel G.Adj] [DecidableRel H.Adj] :
                      DecidableRel (G H).Adj
                      instance SimpleGraph.Inf.adjDecidable (V : Type u) (G : SimpleGraph V) (H : SimpleGraph V) [DecidableRel G.Adj] [DecidableRel H.Adj] :
                      DecidableRel (G H).Adj
                      instance SimpleGraph.Sdiff.adjDecidable (V : Type u) (G : SimpleGraph V) (H : SimpleGraph V) [DecidableRel G.Adj] [DecidableRel H.Adj] :
                      DecidableRel (G \ H).Adj
                      def SimpleGraph.support {V : Type u} (G : SimpleGraph V) :
                      Set V

                      G.support is the set of vertices that form edges in G.

                      Instances For
                        theorem SimpleGraph.mem_support {V : Type u} (G : SimpleGraph V) {v : V} :
                        def SimpleGraph.neighborSet {V : Type u} (G : SimpleGraph V) (v : V) :
                        Set V

                        G.neighborSet v is the set of vertices adjacent to v in G.

                        Instances For

                          The edges of G consist of the unordered pairs of vertices related by G.Adj. This is the order embedding; for the edge set of a particular graph, see SimpleGraph.edgeSet.

                          The way edgeSet is defined is such that mem_edgeSet is proved by refl. (That is, ⟦(v, w)⟧ ∈ G.edgeSet is definitionally equal to G.Adj v w.)

                          Instances For
                            @[inline, reducible]
                            abbrev SimpleGraph.edgeSet {V : Type u} (G : SimpleGraph V) :
                            Set (Sym2 V)

                            G.edgeSet is the edge set for G. This is an abbreviation for edgeSetEmbedding G that permits dot notation.

                            Instances For
                              @[simp]
                              theorem SimpleGraph.edgeSet_inj {V : Type u} {G₁ : SimpleGraph V} {G₂ : SimpleGraph V} :
                              @[simp]
                              theorem SimpleGraph.edgeSet_injective {V : Type u} :
                              Function.Injective SimpleGraph.edgeSet
                              theorem SimpleGraph.edgeSet_mono {V : Type u} {G₁ : SimpleGraph V} {G₂ : SimpleGraph V} :

                              Alias of the reverse direction of SimpleGraph.edgeSet_subset_edgeSet.

                              theorem SimpleGraph.edgeSet_strict_mono {V : Type u} {G₁ : SimpleGraph V} {G₂ : SimpleGraph V} :

                              Alias of the reverse direction of SimpleGraph.edgeSet_ssubset_edgeSet.

                              @[simp]
                              @[simp]

                              This lemma, combined with edgeSet_sdiff and edgeSet_from_edgeSet, allows proving (G \ from_edgeSet s).edge_set = G.edgeSet \ s by simp.

                              theorem SimpleGraph.adj_iff_exists_edge {V : Type u} (G : SimpleGraph V) {v : V} {w : V} :

                              Two vertices are adjacent iff there is an edge between them. The condition v ≠ w ensures they are different endpoints of the edge, which is necessary since when v = w the existential ∃ (e ∈ G.edgeSet), v ∈ e ∧ w ∈ e is satisfied by every edge incident to v.

                              theorem SimpleGraph.adj_iff_exists_edge_coe {V : Type u} (G : SimpleGraph V) {a : V} {b : V} :
                              SimpleGraph.Adj G a b e, e = Quotient.mk (Sym2.Rel.setoid V) (a, b)
                              theorem SimpleGraph.edge_other_ne {V : Type u} (G : SimpleGraph V) {e : Sym2 V} (he : e SimpleGraph.edgeSet G) {v : V} (h : v e) :

                              fromEdgeSet constructs a SimpleGraph from a set of edges, without loops.

                              Instances For
                                @[simp]
                                theorem SimpleGraph.fromEdgeSet_adj {V : Type u} {v : V} {w : V} (s : Set (Sym2 V)) :

                                Darts #

                                structure SimpleGraph.Dart {V : Type u} (G : SimpleGraph V) extends Prod :

                                A Dart is an oriented edge, implemented as an ordered pair of adjacent vertices. This terminology comes from combinatorial maps, and they are also known as "half-edges" or "bonds."

                                Instances For
                                  instance SimpleGraph.instDecidableEqDart :
                                  {V : Type u_3} → {G : SimpleGraph V} → [inst : DecidableEq V] → DecidableEq (SimpleGraph.Dart G)
                                  theorem SimpleGraph.Dart.ext_iff {V : Type u} {G : SimpleGraph V} (d₁ : SimpleGraph.Dart G) (d₂ : SimpleGraph.Dart G) :
                                  d₁ = d₂ d₁.toProd = d₂.toProd
                                  theorem SimpleGraph.Dart.ext {V : Type u} {G : SimpleGraph V} (d₁ : SimpleGraph.Dart G) (d₂ : SimpleGraph.Dart G) (h : d₁.toProd = d₂.toProd) :
                                  d₁ = d₂
                                  theorem SimpleGraph.Dart.toProd_injective {V : Type u} {G : SimpleGraph V} :
                                  Function.Injective SimpleGraph.Dart.toProd

                                  The edge associated to the dart.

                                  Instances For
                                    @[simp]
                                    theorem SimpleGraph.Dart.edge_mk {V : Type u} {G : SimpleGraph V} {p : V × V} (h : SimpleGraph.Adj G p.fst p.snd) :
                                    SimpleGraph.Dart.edge { toProd := p, is_adj := h } = Quotient.mk (Sym2.Rel.setoid V) p
                                    @[simp]

                                    The dart with reversed orientation from a given dart.

                                    Instances For
                                      @[simp]
                                      theorem SimpleGraph.Dart.symm_mk {V : Type u} {G : SimpleGraph V} {p : V × V} (h : SimpleGraph.Adj G p.fst p.snd) :
                                      SimpleGraph.Dart.symm { toProd := p, is_adj := h } = { toProd := Prod.swap p, is_adj := (_ : SimpleGraph.Adj G p.snd p.fst) }
                                      @[simp]
                                      theorem SimpleGraph.Dart.edge_comp_symm {V : Type u} {G : SimpleGraph V} :
                                      SimpleGraph.Dart.edge SimpleGraph.Dart.symm = SimpleGraph.Dart.edge
                                      @[simp]
                                      theorem SimpleGraph.Dart.symm_involutive {V : Type u} {G : SimpleGraph V} :
                                      Function.Involutive SimpleGraph.Dart.symm
                                      theorem SimpleGraph.dart_edge_eq_mk'_iff' {V : Type u} {G : SimpleGraph V} {d : SimpleGraph.Dart G} {u : V} {v : V} :
                                      SimpleGraph.Dart.edge d = Quotient.mk (Sym2.Rel.setoid V) (u, v) d.fst = u d.snd = v d.fst = v d.snd = u

                                      Two darts are said to be adjacent if they could be consecutive darts in a walk -- that is, the first dart's second vertex is equal to the second dart's first vertex.

                                      Instances For
                                        @[simp]
                                        theorem SimpleGraph.dartOfNeighborSet_toProd {V : Type u} (G : SimpleGraph V) (v : V) (w : ↑(SimpleGraph.neighborSet G v)) :
                                        (SimpleGraph.dartOfNeighborSet G v w).toProd = (v, w)

                                        For a given vertex v, this is the bijective map from the neighbor set at v to the darts d with d.fst = v.

                                        Instances For

                                          Incidence set #

                                          def SimpleGraph.incidenceSet {V : Type u} (G : SimpleGraph V) (v : V) :
                                          Set (Sym2 V)

                                          Set of edges incident to a given vertex, aka incidence set.

                                          Instances For
                                            theorem SimpleGraph.mk'_mem_incidenceSet_iff {V : Type u} (G : SimpleGraph V) {a : V} {b : V} {c : V} :
                                            theorem SimpleGraph.adj_of_mem_incidenceSet {V : Type u} (G : SimpleGraph V) {a : V} {b : V} {e : Sym2 V} (h : a b) (ha : e SimpleGraph.incidenceSet G a) (hb : e SimpleGraph.incidenceSet G b) :
                                            @[reducible]

                                            The edgeSet of the graph as a Finset.

                                            Instances For
                                              @[simp]
                                              theorem SimpleGraph.mem_neighborSet {V : Type u} (G : SimpleGraph V) (v : V) (w : V) :
                                              def SimpleGraph.commonNeighbors {V : Type u} (G : SimpleGraph V) (v : V) (w : V) :
                                              Set V

                                              The set of common neighbors between two vertices v and w in a graph G is the intersection of the neighbor sets of v and w.

                                              Instances For
                                                theorem SimpleGraph.commonNeighbors_top_eq {V : Type u} {v : V} {w : V} :
                                                SimpleGraph.commonNeighbors v w = Set.univ \ {v, w}
                                                def SimpleGraph.otherVertexOfIncident {V : Type u} (G : SimpleGraph V) [DecidableEq V] {v : V} {e : Sym2 V} (h : e SimpleGraph.incidenceSet G v) :
                                                V

                                                Given an edge incident to a particular vertex, get the other vertex on the edge.

                                                Instances For

                                                  There is an equivalence between the set of edges incident to a given vertex and the set of vertices adjacent to the vertex.

                                                  Instances For

                                                    Edge deletion #

                                                    def SimpleGraph.deleteEdges {V : Type u} (G : SimpleGraph V) (s : Set (Sym2 V)) :

                                                    Given a set of vertex pairs, remove all of the corresponding edges from the graph's edge set, if present.

                                                    See also: SimpleGraph.Subgraph.deleteEdges.

                                                    Instances For
                                                      @[simp]
                                                      def SimpleGraph.DeleteFar {𝕜 : Type u_2} {V : Type u} (G : SimpleGraph V) [OrderedRing 𝕜] [Fintype (Sym2 V)] [DecidableRel G.Adj] (p : SimpleGraph VProp) (r : 𝕜) :

                                                      A graph is r-delete-far from a property p if we must delete at least r edges from it to get a graph with the property p.

                                                      Instances For
                                                        theorem SimpleGraph.deleteFar_iff {𝕜 : Type u_2} {V : Type u} {G : SimpleGraph V} [OrderedRing 𝕜] [Fintype (Sym2 V)] [DecidableEq V] [DecidableRel G.Adj] {p : SimpleGraph VProp} {r : 𝕜} :
                                                        theorem SimpleGraph.DeleteFar.le_card_sub_card {𝕜 : Type u_2} {V : Type u} {G : SimpleGraph V} [OrderedRing 𝕜] [Fintype (Sym2 V)] [DecidableEq V] [DecidableRel G.Adj] {p : SimpleGraph VProp} {r : 𝕜} :
                                                        SimpleGraph.DeleteFar G p r∀ ⦃H : SimpleGraph V⦄, H Gp Hr ↑(Finset.card (SimpleGraph.edgeFinset G)) - ↑(Finset.card (SimpleGraph.edgeFinset H))

                                                        Alias of the forward direction of SimpleGraph.deleteFar_iff.

                                                        theorem SimpleGraph.DeleteFar.mono {𝕜 : Type u_2} {V : Type u} {G : SimpleGraph V} [OrderedRing 𝕜] [Fintype (Sym2 V)] [DecidableRel G.Adj] {p : SimpleGraph VProp} {r₁ : 𝕜} {r₂ : 𝕜} (h : SimpleGraph.DeleteFar G p r₂) (hr : r₁ r₂) :

                                                        Map and comap #

                                                        def SimpleGraph.map {V : Type u} {W : Type v} (f : V W) (G : SimpleGraph V) :

                                                        Given an injective function, there is a covariant induced map on graphs by pushing forward the adjacency relation.

                                                        This is injective (see SimpleGraph.map_injective).

                                                        Instances For
                                                          @[simp]
                                                          theorem SimpleGraph.map_adj {V : Type u} {W : Type v} (f : V W) (G : SimpleGraph V) (u : W) (v : W) :
                                                          SimpleGraph.Adj (SimpleGraph.map f G) u v u' v', SimpleGraph.Adj G u' v' f u' = u f v' = v
                                                          theorem SimpleGraph.map_monotone {V : Type u} {W : Type v} (f : V W) :
                                                          @[simp]
                                                          theorem SimpleGraph.comap_Adj {V : Type u} {W : Type v} (f : VW) (G : SimpleGraph W) (u : V) (v : V) :
                                                          def SimpleGraph.comap {V : Type u} {W : Type v} (f : VW) (G : SimpleGraph W) :

                                                          Given a function, there is a contravariant induced map on graphs by pulling back the adjacency relation. This is one of the ways of creating induced graphs. See SimpleGraph.induce for a wrapper.

                                                          This is surjective when f is injective (see SimpleGraph.comap_surjective).

                                                          Instances For
                                                            theorem SimpleGraph.comap_monotone {V : Type u} {W : Type v} (f : V W) :
                                                            @[simp]
                                                            theorem SimpleGraph.comap_map_eq {V : Type u} {W : Type v} (f : V W) (G : SimpleGraph V) :
                                                            theorem SimpleGraph.map_le_iff_le_comap {V : Type u} {W : Type v} (f : V W) (G : SimpleGraph V) (G' : SimpleGraph W) :
                                                            theorem SimpleGraph.map_comap_le {V : Type u} {W : Type v} (f : V W) (G : SimpleGraph W) :
                                                            theorem SimpleGraph.le_comap_of_subsingleton {V : Type u} {W : Type v} (G : SimpleGraph V) (G' : SimpleGraph W) (f : VW) [Subsingleton V] :
                                                            theorem SimpleGraph.map_le_of_subsingleton {V : Type u} {W : Type v} (G : SimpleGraph V) (G' : SimpleGraph W) (f : V W) [Subsingleton V] :
                                                            @[inline, reducible]
                                                            abbrev SimpleGraph.completeMultipartiteGraph {ι : Type u_3} (V : ιType u_4) :
                                                            SimpleGraph ((i : ι) × V i)

                                                            Given a family of vertex types indexed by ι, pulling back from ⊤ : SimpleGraph ι yields the complete multipartite graph on the family. Two vertices are adjacent if and only if their indices are not equal.

                                                            Instances For

                                                              Induced graphs #

                                                              @[reducible]
                                                              def SimpleGraph.induce {V : Type u} (s : Set V) (G : SimpleGraph V) :

                                                              Restrict a graph to the vertices in the set s, deleting all edges incident to vertices outside the set. This is a wrapper around SimpleGraph.comap.

                                                              Instances For
                                                                @[simp]
                                                                @[reducible]
                                                                def SimpleGraph.spanningCoe {V : Type u} {s : Set V} (G : SimpleGraph s) :

                                                                Given a graph on a set of vertices, we can make it be a SimpleGraph V by adding in the remaining vertices without adding in any additional edges. This is a wrapper around SimpleGraph.map.

                                                                Instances For

                                                                  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.

                                                                  G.neighbors v is the Finset version of G.Adj v in case G is locally finite at v.

                                                                  Instances For
                                                                    def SimpleGraph.degree {V : Type u} (G : SimpleGraph V) (v : V) [Fintype ↑(SimpleGraph.neighborSet G v)] :

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

                                                                    Instances For

                                                                      This is the Finset version of incidenceSet.

                                                                      Instances For
                                                                        @[reducible]

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

                                                                        Instances For

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

                                                                          Instances For

                                                                            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

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

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

                                                                              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.

                                                                              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

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

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

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

                                                                                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.

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

                                                                                @[inline, reducible]
                                                                                abbrev SimpleGraph.Hom {V : Type u} {W : Type v} (G : SimpleGraph V) (G' : SimpleGraph W) :
                                                                                Type (max u v)

                                                                                A graph homomorphism is a map on vertex sets that respects adjacency relations.

                                                                                The notation G →g G' represents the type of graph homomorphisms.

                                                                                Instances For
                                                                                  @[inline, reducible]
                                                                                  abbrev SimpleGraph.Embedding {V : Type u} {W : Type v} (G : SimpleGraph V) (G' : SimpleGraph W) :
                                                                                  Type (max u v)

                                                                                  A graph embedding is an embedding f such that for vertices v w : V, G.Adj (f v) (f w) ↔ G.Adj v w . Its image is an induced subgraph of G'.

                                                                                  The notation G ↪g G' represents the type of graph embeddings.

                                                                                  Instances For
                                                                                    @[inline, reducible]
                                                                                    abbrev SimpleGraph.Iso {V : Type u} {W : Type v} (G : SimpleGraph V) (G' : SimpleGraph W) :
                                                                                    Type (max u v)

                                                                                    A graph isomorphism is a bijective map on vertex sets that respects adjacency relations.

                                                                                    The notation G ≃g G' represents the type of graph isomorphisms.

                                                                                    Instances For
                                                                                      @[inline, reducible]
                                                                                      abbrev SimpleGraph.Hom.id {V : Type u} {G : SimpleGraph V} :
                                                                                      G →g G

                                                                                      The identity homomorphism from a graph to itself.

                                                                                      Instances For
                                                                                        theorem SimpleGraph.Hom.map_adj {V : Type u} {W : Type v} {G : SimpleGraph V} {G' : SimpleGraph W} (f : G →g G') {v : V} {w : V} (h : SimpleGraph.Adj G v w) :
                                                                                        SimpleGraph.Adj G' (f v) (f w)
                                                                                        theorem SimpleGraph.Hom.map_mem_edgeSet {V : Type u} {W : Type v} {G : SimpleGraph V} {G' : SimpleGraph W} (f : G →g G') {e : Sym2 V} (h : e SimpleGraph.edgeSet G) :
                                                                                        theorem SimpleGraph.Hom.apply_mem_neighborSet {V : Type u} {W : Type v} {G : SimpleGraph V} {G' : SimpleGraph W} (f : G →g G') {v : V} {w : V} (h : w SimpleGraph.neighborSet G v) :
                                                                                        f w SimpleGraph.neighborSet G' (f v)
                                                                                        @[simp]
                                                                                        theorem SimpleGraph.Hom.mapEdgeSet_coe {V : Type u} {W : Type v} {G : SimpleGraph V} {G' : SimpleGraph W} (f : G →g G') (e : ↑(SimpleGraph.edgeSet G)) :
                                                                                        def SimpleGraph.Hom.mapEdgeSet {V : Type u} {W : Type v} {G : SimpleGraph V} {G' : SimpleGraph W} (f : G →g G') (e : ↑(SimpleGraph.edgeSet G)) :

                                                                                        The map between edge sets induced by a homomorphism. The underlying map on edges is given by Sym2.map.

                                                                                        Instances For
                                                                                          @[simp]
                                                                                          theorem SimpleGraph.Hom.mapNeighborSet_coe {V : Type u} {W : Type v} {G : SimpleGraph V} {G' : SimpleGraph W} (f : G →g G') (v : V) (w : ↑(SimpleGraph.neighborSet G v)) :
                                                                                          ↑(SimpleGraph.Hom.mapNeighborSet f v w) = f w
                                                                                          def SimpleGraph.Hom.mapNeighborSet {V : Type u} {W : Type v} {G : SimpleGraph V} {G' : SimpleGraph W} (f : G →g G') (v : V) (w : ↑(SimpleGraph.neighborSet G v)) :
                                                                                          ↑(SimpleGraph.neighborSet G' (f v))

                                                                                          The map between neighbor sets induced by a homomorphism.

                                                                                          Instances For
                                                                                            def SimpleGraph.Hom.mapDart {V : Type u} {W : Type v} {G : SimpleGraph V} {G' : SimpleGraph W} (f : G →g G') (d : SimpleGraph.Dart G) :

                                                                                            The map between darts induced by a homomorphism.

                                                                                            Instances For
                                                                                              @[simp]
                                                                                              theorem SimpleGraph.Hom.mapDart_apply {V : Type u} {W : Type v} {G : SimpleGraph V} {G' : SimpleGraph W} (f : G →g G') (d : SimpleGraph.Dart G) :
                                                                                              SimpleGraph.Hom.mapDart f d = { toProd := Prod.map (f) (f) d.toProd, is_adj := (_ : SimpleGraph.Adj G' (f d.1.fst) (f d.1.snd)) }
                                                                                              @[simp]
                                                                                              def SimpleGraph.Hom.mapSpanningSubgraphs {V : Type u} {G : SimpleGraph V} {G' : SimpleGraph V} (h : G G') :
                                                                                              G →g G'

                                                                                              The induced map for spanning subgraphs, which is the identity on vertices.

                                                                                              Instances For
                                                                                                theorem SimpleGraph.Hom.injective_of_top_hom {V : Type u} {W : Type v} {G' : SimpleGraph W} (f : →g G') :

                                                                                                Every graph homomorphism from a complete graph is injective.

                                                                                                @[simp]
                                                                                                theorem SimpleGraph.Hom.comap_apply {V : Type u} {W : Type v} (f : VW) (G : SimpleGraph W) :
                                                                                                ∀ (a : V), ↑(SimpleGraph.Hom.comap f G) a = f a
                                                                                                def SimpleGraph.Hom.comap {V : Type u} {W : Type v} (f : VW) (G : SimpleGraph W) :

                                                                                                There is a homomorphism to a graph from a comapped graph. When the function is injective, this is an embedding (see SimpleGraph.Embedding.comap).

                                                                                                Instances For
                                                                                                  @[inline, reducible]
                                                                                                  abbrev SimpleGraph.Hom.comp {V : Type u} {W : Type v} {X : Type w} {G : SimpleGraph V} {G' : SimpleGraph W} {G'' : SimpleGraph X} (f' : G' →g G'') (f : G →g G') :
                                                                                                  G →g G''

                                                                                                  Composition of graph homomorphisms.

                                                                                                  Instances For
                                                                                                    @[simp]
                                                                                                    theorem SimpleGraph.Hom.coe_comp {V : Type u} {W : Type v} {X : Type w} {G : SimpleGraph V} {G' : SimpleGraph W} {G'' : SimpleGraph X} (f' : G' →g G'') (f : G →g G') :
                                                                                                    ↑(SimpleGraph.Hom.comp f' f) = f' f
                                                                                                    @[inline, reducible]
                                                                                                    abbrev SimpleGraph.Embedding.refl {V : Type u} {G : SimpleGraph V} :
                                                                                                    G ↪g G

                                                                                                    The identity embedding from a graph to itself.

                                                                                                    Instances For
                                                                                                      @[inline, reducible]
                                                                                                      abbrev SimpleGraph.Embedding.toHom {V : Type u} {W : Type v} {G : SimpleGraph V} {G' : SimpleGraph W} (f : G ↪g G') :
                                                                                                      G →g G'

                                                                                                      An embedding of graphs gives rise to a homomorphism of graphs.

                                                                                                      Instances For
                                                                                                        theorem SimpleGraph.Embedding.map_adj_iff {V : Type u} {W : Type v} {G : SimpleGraph V} {G' : SimpleGraph W} (f : G ↪g G') {v : V} {w : V} :
                                                                                                        SimpleGraph.Adj G' (f v) (f w) SimpleGraph.Adj G v w
                                                                                                        theorem SimpleGraph.Embedding.apply_mem_neighborSet_iff {V : Type u} {W : Type v} {G : SimpleGraph V} {G' : SimpleGraph W} (f : G ↪g G') {v : V} {w : V} :
                                                                                                        def SimpleGraph.Embedding.mapEdgeSet {V : Type u} {W : Type v} {G : SimpleGraph V} {G' : SimpleGraph W} (f : G ↪g G') :

                                                                                                        A graph embedding induces an embedding of edge sets.

                                                                                                        Instances For
                                                                                                          @[simp]
                                                                                                          theorem SimpleGraph.Embedding.mapNeighborSet_apply_coe {V : Type u} {W : Type v} {G : SimpleGraph V} {G' : SimpleGraph W} (f : G ↪g G') (v : V) (w : ↑(SimpleGraph.neighborSet G v)) :
                                                                                                          ↑(↑(SimpleGraph.Embedding.mapNeighborSet f v) w) = f w
                                                                                                          def SimpleGraph.Embedding.mapNeighborSet {V : Type u} {W : Type v} {G : SimpleGraph V} {G' : SimpleGraph W} (f : G ↪g G') (v : V) :

                                                                                                          A graph embedding induces an embedding of neighbor sets.

                                                                                                          Instances For
                                                                                                            def SimpleGraph.Embedding.comap {V : Type u} {W : Type v} (f : V W) (G : SimpleGraph W) :

                                                                                                            Given an injective function, there is an embedding from the comapped graph into the original graph.

                                                                                                            Instances For
                                                                                                              @[simp]
                                                                                                              theorem SimpleGraph.Embedding.comap_apply {V : Type u} {W : Type v} (f : V W) (G : SimpleGraph W) (v : V) :
                                                                                                              ↑(SimpleGraph.Embedding.comap f G) v = f v
                                                                                                              def SimpleGraph.Embedding.map {V : Type u} {W : Type v} (f : V W) (G : SimpleGraph V) :

                                                                                                              Given an injective function, there is an embedding from a graph into the mapped graph.

                                                                                                              Instances For
                                                                                                                @[simp]
                                                                                                                theorem SimpleGraph.Embedding.map_apply {V : Type u} {W : Type v} (f : V W) (G : SimpleGraph V) (v : V) :
                                                                                                                ↑(SimpleGraph.Embedding.map f G) v = f v
                                                                                                                @[reducible]

                                                                                                                Induced graphs embed in the original graph.

                                                                                                                Note that if G.induce s = ⊤ (i.e., if s is a clique) then this gives the embedding of a complete graph.

                                                                                                                Instances For
                                                                                                                  @[reducible]

                                                                                                                  Graphs on a set of vertices embed in their spanningCoe.

                                                                                                                  Instances For
                                                                                                                    def SimpleGraph.Embedding.completeGraph {α : Type u_3} {β : Type u_4} (f : α β) :

                                                                                                                    Embeddings of types induce embeddings of complete graphs on those types.

                                                                                                                    Instances For
                                                                                                                      @[inline, reducible]
                                                                                                                      abbrev SimpleGraph.Embedding.comp {V : Type u} {W : Type v} {X : Type w} {G : SimpleGraph V} {G' : SimpleGraph W} {G'' : SimpleGraph X} (f' : G' ↪g G'') (f : G ↪g G') :
                                                                                                                      G ↪g G''

                                                                                                                      Composition of graph embeddings.

                                                                                                                      Instances For
                                                                                                                        @[simp]
                                                                                                                        theorem SimpleGraph.Embedding.coe_comp {V : Type u} {W : Type v} {X : Type w} {G : SimpleGraph V} {G' : SimpleGraph W} {G'' : SimpleGraph X} (f' : G' ↪g G'') (f : G ↪g G') :
                                                                                                                        ↑(SimpleGraph.Embedding.comp f' f) = f' f
                                                                                                                        def SimpleGraph.induceHom {V : Type u} {W : Type v} {G : SimpleGraph V} {G' : SimpleGraph W} {s : Set V} {t : Set W} (φ : G →g G') (φst : Set.MapsTo (φ) s t) :

                                                                                                                        The restriction of a morphism of graphs to induced subgraphs.

                                                                                                                        Instances For
                                                                                                                          @[simp]
                                                                                                                          theorem SimpleGraph.coe_induceHom {V : Type u} {W : Type v} {G : SimpleGraph V} {G' : SimpleGraph W} {s : Set V} {t : Set W} (φ : G →g G') (φst : Set.MapsTo (φ) s t) :
                                                                                                                          ↑(SimpleGraph.induceHom φ φst) = Set.MapsTo.restrict (φ) s t φst
                                                                                                                          @[simp]
                                                                                                                          theorem SimpleGraph.induceHom_id {V : Type u} (G : SimpleGraph V) (s : Set V) :
                                                                                                                          SimpleGraph.induceHom SimpleGraph.Hom.id (_ : Set.MapsTo id s s) = SimpleGraph.Hom.id
                                                                                                                          @[simp]
                                                                                                                          theorem SimpleGraph.induceHom_comp {V : Type u} {W : Type v} {X : Type w} {G : SimpleGraph V} {G' : SimpleGraph W} {G'' : SimpleGraph X} {s : Set V} {t : Set W} {r : Set X} (φ : G →g G') (φst : Set.MapsTo (φ) s t) (ψ : G' →g G'') (ψtr : Set.MapsTo (ψ) t r) :
                                                                                                                          theorem SimpleGraph.induceHom_injective {V : Type u} {W : Type v} {G : SimpleGraph V} {G' : SimpleGraph W} {s : Set V} {t : Set W} (φ : G →g G') (φst : Set.MapsTo (φ) s t) (hi : Set.InjOn (φ) s) :
                                                                                                                          def SimpleGraph.induceHomOfLE {V : Type u} (G : SimpleGraph V) {s : Set V} {s' : Set V} (h : s s') :

                                                                                                                          Given an inclusion of vertex subsets, the induced embedding on induced graphs. This is not an abbreviation for induceHom since we get an embedding in this case.

                                                                                                                          Instances For
                                                                                                                            @[simp]
                                                                                                                            theorem SimpleGraph.induceHomOfLE_apply {V : Type u} (G : SimpleGraph V) {s : Set V} {s' : Set V} (h : s s') (v : s) :
                                                                                                                            @[simp]
                                                                                                                            theorem SimpleGraph.induceHomOfLE_toHom {V : Type u} (G : SimpleGraph V) {s : Set V} {s' : Set V} (h : s s') :
                                                                                                                            @[inline, reducible]
                                                                                                                            abbrev SimpleGraph.Iso.refl {V : Type u} {G : SimpleGraph V} :
                                                                                                                            G ≃g G

                                                                                                                            The identity isomorphism of a graph with itself.

                                                                                                                            Instances For
                                                                                                                              @[inline, reducible]
                                                                                                                              abbrev SimpleGraph.Iso.toEmbedding {V : Type u} {W : Type v} {G : SimpleGraph V} {G' : SimpleGraph W} (f : G ≃g G') :
                                                                                                                              G ↪g G'

                                                                                                                              An isomorphism of graphs gives rise to an embedding of graphs.

                                                                                                                              Instances For
                                                                                                                                @[inline, reducible]
                                                                                                                                abbrev SimpleGraph.Iso.toHom {V : Type u} {W : Type v} {G : SimpleGraph V} {G' : SimpleGraph W} (f : G ≃g G') :
                                                                                                                                G →g G'

                                                                                                                                An isomorphism of graphs gives rise to a homomorphism of graphs.

                                                                                                                                Instances For
                                                                                                                                  @[inline, reducible]
                                                                                                                                  abbrev SimpleGraph.Iso.symm {V : Type u} {W : Type v} {G : SimpleGraph V} {G' : SimpleGraph W} (f : G ≃g G') :
                                                                                                                                  G' ≃g G

                                                                                                                                  The inverse of a graph isomorphism.

                                                                                                                                  Instances For
                                                                                                                                    theorem SimpleGraph.Iso.map_adj_iff {V : Type u} {W : Type v} {G : SimpleGraph V} {G' : SimpleGraph W} (f : G ≃g G') {v : V} {w : V} :
                                                                                                                                    SimpleGraph.Adj G' (f v) (f w) SimpleGraph.Adj G v w
                                                                                                                                    theorem SimpleGraph.Iso.apply_mem_neighborSet_iff {V : Type u} {W : Type v} {G : SimpleGraph V} {G' : SimpleGraph W} (f : G ≃g G') {v : V} {w : V} :
                                                                                                                                    def SimpleGraph.Iso.mapEdgeSet {V : Type u} {W : Type v} {G : SimpleGraph V} {G' : SimpleGraph W} (f : G ≃g G') :

                                                                                                                                    An isomorphism of graphs induces an equivalence of edge sets.

                                                                                                                                    Instances For
                                                                                                                                      @[simp]
                                                                                                                                      theorem SimpleGraph.Iso.mapNeighborSet_symm_apply_coe {V : Type u} {W : Type v} {G : SimpleGraph V} {G' : SimpleGraph W} (f : G ≃g G') (v : V) (w : ↑(SimpleGraph.neighborSet G' (f v))) :
                                                                                                                                      ↑((SimpleGraph.Iso.mapNeighborSet f v).symm w) = ↑(SimpleGraph.Iso.symm f) w
                                                                                                                                      @[simp]
                                                                                                                                      theorem SimpleGraph.Iso.mapNeighborSet_apply_coe {V : Type u} {W : Type v} {G : SimpleGraph V} {G' : SimpleGraph W} (f : G ≃g G') (v : V) (w : ↑(SimpleGraph.neighborSet G v)) :
                                                                                                                                      ↑(↑(SimpleGraph.Iso.mapNeighborSet f v) w) = f w
                                                                                                                                      def SimpleGraph.Iso.mapNeighborSet {V : Type u} {W : Type v} {G : SimpleGraph V} {G' : SimpleGraph W} (f : G ≃g G') (v : V) :

                                                                                                                                      A graph isomorphism induces an equivalence of neighbor sets.

                                                                                                                                      Instances For
                                                                                                                                        theorem SimpleGraph.Iso.card_eq_of_iso {V : Type u} {W : Type v} {G : SimpleGraph V} {G' : SimpleGraph W} [Fintype V] [Fintype W] (f : G ≃g G') :
                                                                                                                                        def SimpleGraph.Iso.comap {V : Type u} {W : Type v} (f : V W) (G : SimpleGraph W) :

                                                                                                                                        Given a bijection, there is an embedding from the comapped graph into the original graph.

                                                                                                                                        Instances For
                                                                                                                                          @[simp]
                                                                                                                                          theorem SimpleGraph.Iso.comap_apply {V : Type u} {W : Type v} (f : V W) (G : SimpleGraph W) (v : V) :
                                                                                                                                          ↑(SimpleGraph.Iso.comap f G) v = f v
                                                                                                                                          @[simp]
                                                                                                                                          theorem SimpleGraph.Iso.comap_symm_apply {V : Type u} {W : Type v} (f : V W) (G : SimpleGraph W) (w : W) :
                                                                                                                                          def SimpleGraph.Iso.map {V : Type u} {W : Type v} (f : V W) (G : SimpleGraph V) :

                                                                                                                                          Given an injective function, there is an embedding from a graph into the mapped graph.

                                                                                                                                          Instances For
                                                                                                                                            @[simp]
                                                                                                                                            theorem SimpleGraph.Iso.map_apply {V : Type u} {W : Type v} (f : V W) (G : SimpleGraph V) (v : V) :
                                                                                                                                            ↑(SimpleGraph.Iso.map f G) v = f v
                                                                                                                                            @[simp]
                                                                                                                                            theorem SimpleGraph.Iso.map_symm_apply {V : Type u} {W : Type v} (f : V W) (G : SimpleGraph V) (w : W) :
                                                                                                                                            ↑(SimpleGraph.Iso.symm (SimpleGraph.Iso.map f G)) w = f.symm w
                                                                                                                                            def SimpleGraph.Iso.completeGraph {α : Type u_3} {β : Type u_4} (f : α β) :

                                                                                                                                            Equivalences of types induce isomorphisms of complete graphs on those types.

                                                                                                                                            Instances For
                                                                                                                                              @[inline, reducible]
                                                                                                                                              abbrev SimpleGraph.Iso.comp {V : Type u} {W : Type v} {X : Type w} {G : SimpleGraph V} {G' : SimpleGraph W} {G'' : SimpleGraph X} (f' : G' ≃g G'') (f : G ≃g G') :
                                                                                                                                              G ≃g G''

                                                                                                                                              Composition of graph isomorphisms.

                                                                                                                                              Instances For
                                                                                                                                                @[simp]
                                                                                                                                                theorem SimpleGraph.Iso.coe_comp {V : Type u} {W : Type v} {X : Type w} {G : SimpleGraph V} {G' : SimpleGraph W} {G'' : SimpleGraph X} (f' : G' ≃g G'') (f : G ≃g G') :
                                                                                                                                                ↑(SimpleGraph.Iso.comp f' f) = f' f
                                                                                                                                                @[simp]
                                                                                                                                                theorem SimpleGraph.induceUnivIso_apply {V : Type u} (G : SimpleGraph V) (self : { x // x Set.univ }) :
                                                                                                                                                ↑(SimpleGraph.induceUnivIso G) self = self

                                                                                                                                                The graph induced on Set.univ is isomorphic to the original graph.

                                                                                                                                                Instances For