Maps between graphs #
This file defines two functions and three structures relating graphs. The structures directly correspond to the classification of functions as injective, surjective and bijective, and have corresponding notation.
Main definitions #
SimpleGraph.map
: the graph obtained by pushing the adjacency relation through an injective function between vertex types.SimpleGraph.comap
: the graph obtained by pulling the adjacency relation behind an arbitrary function between vertex types.SimpleGraph.induce
: the subgraph induced by the given vertex set, a wrapper aroundcomap
.SimpleGraph.spanningCoe
: the supergraph without any additional edges, a wrapper aroundmap
.SimpleGraph.Hom
,G →g H
: a graph homomorphism fromG
toH
.SimpleGraph.Embedding
,G ↪g H
: a graph embedding ofG
inH
.SimpleGraph.Iso
,G ≃g H
: a graph isomorphism betweenG
andH
.
Note that a graph embedding is a stronger notion than an injective graph homomorphism, since its image is an induced subgraph.
Implementation notes #
Morphisms of graphs are abbreviations for RelHom
, RelEmbedding
and RelIso
.
To make use of pre-existing simp lemmas, definitions involving morphisms are
abbreviations as well.
Map and comap #
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
).
Equations
- SimpleGraph.map f G = { Adj := Relation.Map G.Adj ⇑f ⇑f, symm := ⋯, loopless := ⋯ }
Instances For
Equations
- G.instDecidableMapAdj = inst
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
).
Equations
- SimpleGraph.comap f G = { Adj := fun (u v : V) => G.Adj (f u) (f v), symm := ⋯, loopless := ⋯ }
Instances For
Equations
- SimpleGraph.instDecidableComapAdj f G x✝ x = inst (f x✝) (f x)
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.
Equations
- SimpleGraph.completeMultipartiteGraph V = SimpleGraph.comap Sigma.fst ⊤
Instances For
Equivalent types have equivalent simple graphs.
Equations
- e.simpleGraph = { toFun := SimpleGraph.comap ⇑e.symm, invFun := SimpleGraph.comap ⇑e, left_inv := ⋯, right_inv := ⋯ }
Instances For
Induced graphs #
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
.
Equations
- SimpleGraph.induce s G = SimpleGraph.comap (⇑(Function.Embedding.subtype fun (x : V) => x ∈ s)) G
Instances For
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
.
Equations
- G.spanningCoe = SimpleGraph.map (Function.Embedding.subtype fun (x : V) => x ∈ s) G
Instances For
Homomorphisms, embeddings and isomorphisms #
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
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
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
A graph homomorphism is a map on vertex sets that respects adjacency relations.
The notation G →g G'
represents the type of graph homomorphisms.
Equations
- SimpleGraph.«term_→g_» = Lean.ParserDescr.trailingNode `SimpleGraph.«term_→g_» 50 50 (Lean.ParserDescr.binary `andthen (Lean.ParserDescr.symbol " →g ") (Lean.ParserDescr.cat `term 51))
Instances For
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.
Equations
- SimpleGraph.«term_↪g_» = Lean.ParserDescr.trailingNode `SimpleGraph.«term_↪g_» 50 50 (Lean.ParserDescr.binary `andthen (Lean.ParserDescr.symbol " ↪g ") (Lean.ParserDescr.cat `term 51))
Instances For
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.
Equations
- SimpleGraph.«term_≃g_» = Lean.ParserDescr.trailingNode `SimpleGraph.«term_≃g_» 50 50 (Lean.ParserDescr.binary `andthen (Lean.ParserDescr.symbol " ≃g ") (Lean.ParserDescr.cat `term 51))
Instances For
The identity homomorphism from a graph to itself.
Instances For
Equations
- ⋯ = ⋯
Equations
- SimpleGraph.Hom.instUniqueOfIsEmpty = { default := { toFun := fun (a : V) => isEmptyElim a, map_rel' := ⋯ }, uniq := ⋯ }
Equations
- ⋯ = ⋯
The map between edge sets induced by a homomorphism.
The underlying map on edges is given by Sym2.map
.
Instances For
The map between neighbor sets induced by a homomorphism.
Equations
- f.mapNeighborSet v w = ⟨f ↑w, ⋯⟩
Instances For
The map between darts induced by a homomorphism.
Instances For
The induced map for spanning subgraphs, which is the identity on vertices.
Equations
- SimpleGraph.Hom.mapSpanningSubgraphs h = { toFun := fun (x : V) => x, map_rel' := ⋯ }
Instances For
Every graph homomorphism from a complete graph is injective.
There is a homomorphism to a graph from a comapped graph.
When the function is injective, this is an embedding (see SimpleGraph.Embedding.comap
).
Equations
- SimpleGraph.Hom.comap f G = { toFun := f, map_rel' := ⋯ }
Instances For
Composition of graph homomorphisms.
Equations
- f'.comp f = RelHom.comp f' f
Instances For
The graph homomorphism from a smaller graph to a bigger one.
Equations
- SimpleGraph.Hom.ofLE h = { toFun := id, map_rel' := h }
Instances For
The identity embedding from a graph to itself.
Equations
- SimpleGraph.Embedding.refl = RelEmbedding.refl G.Adj
Instances For
An embedding of graphs gives rise to a homomorphism of graphs.
Equations
- f.toHom = RelEmbedding.toRelHom f
Instances For
A graph embedding induces an embedding of edge sets.
Equations
- f.mapEdgeSet = { toFun := SimpleGraph.Hom.mapEdgeSet (RelEmbedding.toRelHom f), inj' := ⋯ }
Instances For
A graph embedding induces an embedding of neighbor sets.
Equations
- f.mapNeighborSet v = { toFun := fun (w : ↑(G.neighborSet v)) => ⟨f ↑w, ⋯⟩, inj' := ⋯ }
Instances For
Given an injective function, there is an embedding from the comapped graph into the original graph.
Equations
- SimpleGraph.Embedding.comap f G = { toEmbedding := f, map_rel_iff' := ⋯ }
Instances For
Given an injective function, there is an embedding from a graph into the mapped graph.
Equations
- SimpleGraph.Embedding.map f G = { toEmbedding := f, map_rel_iff' := ⋯ }
Instances For
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.
Equations
- SimpleGraph.Embedding.induce s = SimpleGraph.Embedding.comap (Function.Embedding.subtype fun (x : V) => x ∈ s) G
Instances For
Graphs on a set of vertices embed in their spanningCoe
.
Equations
- SimpleGraph.Embedding.spanningCoe G = SimpleGraph.Embedding.map (Function.Embedding.subtype fun (x : V) => x ∈ s) G
Instances For
Embeddings of types induce embeddings of complete graphs on those types.
Equations
- SimpleGraph.Embedding.completeGraph f = { toEmbedding := f, map_rel_iff' := ⋯ }
Instances For
Composition of graph embeddings.
Equations
- f'.comp f = RelEmbedding.trans f f'
Instances For
The restriction of a morphism of graphs to induced subgraphs.
Equations
- SimpleGraph.induceHom φ φst = { toFun := Set.MapsTo.restrict (⇑φ) s t φst, map_rel' := ⋯ }
Instances For
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.
Equations
- G.induceHomOfLE h = { toEmbedding := s.embeddingOfSubset s' h, map_rel_iff' := ⋯ }
Instances For
The identity isomorphism of a graph with itself.
Equations
- SimpleGraph.Iso.refl = RelIso.refl G.Adj
Instances For
An isomorphism of graphs gives rise to an embedding of graphs.
Equations
- f.toEmbedding = RelIso.toRelEmbedding f
Instances For
An isomorphism of graphs gives rise to a homomorphism of graphs.
Equations
- f.toHom = f.toEmbedding.toHom
Instances For
The inverse of a graph isomorphism.
Equations
- f.symm = RelIso.symm f
Instances For
An isomorphism of graphs induces an equivalence of edge sets.
Equations
- One or more equations did not get rendered due to their size.
Instances For
A graph isomorphism induces an equivalence of neighbor sets.
Equations
- f.mapNeighborSet v = { toFun := fun (w : ↑(G.neighborSet v)) => ⟨f ↑w, ⋯⟩, invFun := fun (w : ↑(G'.neighborSet (f v))) => ⟨f.symm ↑w, ⋯⟩, left_inv := ⋯, right_inv := ⋯ }
Instances For
Given a bijection, there is an embedding from the comapped graph into the original graph.
Equations
- SimpleGraph.Iso.comap f G = { toEquiv := f, map_rel_iff' := ⋯ }
Instances For
Given an injective function, there is an embedding from a graph into the mapped graph.
Equations
- SimpleGraph.Iso.map f G = { toEquiv := f, map_rel_iff' := ⋯ }
Instances For
Equivalences of types induce isomorphisms of complete graphs on those types.
Equations
- SimpleGraph.Iso.completeGraph f = { toEquiv := f, map_rel_iff' := ⋯ }
Instances For
Composition of graph isomorphisms.
Equations
- f'.comp f = RelIso.trans f f'
Instances For
The graph induced on Set.univ
is isomorphic to the original graph.
Equations
- G.induceUnivIso = { toEquiv := Equiv.Set.univ V, map_rel_iff' := ⋯ }
Instances For
Given a graph over a finite vertex type V
and a proof hc
that Fintype.card V = n
,
G.overFin n
is an isomorphic (as shown in overFinIso
) graph over Fin n
.
Equations
- G.overFin hc = { Adj := fun (x y : Fin n) => G.Adj ((Fintype.equivFinOfCardEq hc).symm x) ((Fintype.equivFinOfCardEq hc).symm y), symm := ⋯, loopless := ⋯ }
Instances For
The isomorphism between G
and G.overFin hc
.
Equations
- G.overFinIso hc = { toEquiv := Fintype.equivFinOfCardEq hc, map_rel_iff' := ⋯ }