Subgraphs of a simple graph #
A subgraph of a simple graph consists of subsets of the graph's vertices and edges such that the endpoints of each edge are present in the vertex subset. The edge subset is formalized as a sub-relation of the adjacency relation of the simple graph.
Main definitions #
Subgraph G
is the type of subgraphs of aG : SimpleGraph V
.Subgraph.neighborSet
,Subgraph.incidenceSet
, andSubgraph.degree
are like theirSimpleGraph
counterparts, but they refer to vertices fromG
to avoid subtype coercions.Subgraph.coe
is the coercion from aG' : Subgraph G
to aSimpleGraph G'.verts
. (In Lean 3 this could not be aCoe
instance since the destination type depends onG'
.)Subgraph.IsSpanning
for whether a subgraph is a spanning subgraph andSubgraph.IsInduced
for whether a subgraph is an induced subgraph.Instances for
Lattice (Subgraph G)
andBoundedOrder (Subgraph G)
.SimpleGraph.toSubgraph
: If aSimpleGraph
is a subgraph of another, then you can turn it into a member of the larger graph'sSimpleGraph.Subgraph
type.Graph homomorphisms from a subgraph to a graph (
Subgraph.map_top
) and between subgraphs (Subgraph.map
).
Implementation notes #
- Recall that subgraphs are not determined by their vertex sets, so
SetLike
does not apply to this kind of subobject.
TODO #
- Images of graph homomorphisms as subgraphs.
A subgraph of a SimpleGraph
is a subset of vertices along with a restriction of the adjacency
relation that is symmetric and is supported by the vertex subset. They also form a bounded lattice.
Thinking of V → V → Prop
as Set (V × V)
, a set of darts (i.e., half-edges), then
Subgraph.adj_sub
is that the darts of a subgraph are a subset of the darts of G
.
- verts : Set V
- Adj : V → V → Prop
- adj_sub : ∀ {v w : V}, self.Adj v w → G.Adj v w
- edge_vert : ∀ {v w : V}, self.Adj v w → v ∈ self.verts
- symm : Symmetric self.Adj
Instances For
The one-vertex subgraph.
Equations
Instances For
The one-edge subgraph.
Equations
Instances For
Coercion from G' : Subgraph G
to a SimpleGraph G'.verts
.
Equations
- G'.coe = { Adj := fun (v w : ↑G'.verts) => G'.Adj ↑v ↑w, symm := ⋯, loopless := ⋯ }
Instances For
A subgraph is called a spanning subgraph if it contains all the vertices of G
.
Instances For
Alias of the forward direction of SimpleGraph.Subgraph.isSpanning_iff
.
Coercion from Subgraph G
to SimpleGraph V
. If G'
is a spanning
subgraph, then G'.spanningCoe
yields an isomorphic graph.
In general, this adds in all vertices from V
as isolated vertices.
Equations
- G'.spanningCoe = { Adj := G'.Adj, symm := ⋯, loopless := ⋯ }
Instances For
spanningCoe
is equivalent to coe
for a subgraph that IsSpanning
.
Equations
- G'.spanningCoeEquivCoeOfSpanning h = { toFun := fun (v : V) => ⟨v, ⋯⟩, invFun := fun (v : ↑G'.verts) => ↑v, left_inv := ⋯, right_inv := ⋯, map_rel_iff' := ⋯ }
Instances For
A subgraph is called an induced subgraph if vertices of G'
are adjacent if
they are adjacent in G
.
Instances For
H.support
is the set of vertices that form edges in the subgraph H
.
Instances For
G'.neighborSet v
is the set of vertices adjacent to v
in G'
.
Equations
- G'.neighborSet v = {w : V | G'.Adj v w}
Instances For
A subgraph as a graph has equivalent neighbor sets.
Equations
- SimpleGraph.Subgraph.coeNeighborSetEquiv v = { toFun := fun (w : ↑(G'.coe.neighborSet v)) => ⟨↑↑w, ⋯⟩, invFun := fun (w : ↑(G'.neighborSet ↑v)) => ⟨⟨↑w, ⋯⟩, ⋯⟩, left_inv := ⋯, right_inv := ⋯ }
Instances For
The edge set of G'
consists of a subset of edges of G
.
Equations
- G'.edgeSet = Sym2.fromRel ⋯
Instances For
The incidenceSet
is the set of edges incident to a given vertex.
Instances For
Give a vertex as an element of the subgraph's vertex type.
Equations
- G'.vert v h = ⟨v, h⟩
Instances For
Create an equal copy of a subgraph (see copy_eq
) with possibly different definitional equalities.
See Note [range copy pattern].
Equations
- G'.copy V'' hV adj' hadj = { verts := V'', Adj := adj', adj_sub := ⋯, edge_vert := ⋯, symm := ⋯ }
Instances For
The union of two subgraphs.
The intersection of two subgraphs.
The top
subgraph is G
as a subgraph of itself.
Equations
- SimpleGraph.Subgraph.instTop = { top := { verts := Set.univ, Adj := G.Adj, adj_sub := ⋯, edge_vert := ⋯, symm := ⋯ } }
The bot
subgraph is the subgraph with no vertices or edges.
Equations
- One or more equations did not get rendered due to their size.
Equations
- One or more equations did not get rendered due to their size.
For subgraphs G₁
, G₂
, G₁ ≤ G₂
iff G₁.verts ⊆ G₂.verts
and
∀ a b, G₁.adj a b → G₂.adj a b
.
Equations
- SimpleGraph.Subgraph.distribLattice = let __src := let_fun this := Function.Injective.distribLattice (fun (G' : G.Subgraph) => (G'.verts, G'.spanningCoe)) ⋯ ⋯ ⋯; this; DistribLattice.mk ⋯
Equations
- SimpleGraph.Subgraph.instBoundedOrder = BoundedOrder.mk
Note that subgraphs do not form a Boolean algebra, because of verts
.
Equations
- SimpleGraph.Subgraph.completelyDistribLatticeMinimalAxioms = let __src := SimpleGraph.Subgraph.distribLattice; { toCompleteLattice := CompleteLattice.mk ⋯ ⋯ ⋯ ⋯ ⋯ ⋯, iInf_iSup_eq := ⋯ }
Instances For
Equations
- SimpleGraph.Subgraph.instCompletelyDistribLattice = CompletelyDistribLattice.ofMinimalAxioms SimpleGraph.Subgraph.completelyDistribLatticeMinimalAxioms
Turn a subgraph of a SimpleGraph
into a member of its subgraph type.
Equations
- SimpleGraph.toSubgraph H h = { verts := Set.univ, Adj := H.Adj, adj_sub := ⋯, edge_vert := ⋯, symm := ⋯ }
Instances For
The bottom of the Subgraph G
lattice is equivalent to the empty graph on the empty
vertex type.
Equations
- SimpleGraph.Subgraph.botEquiv = { toFun := fun (v : ↑⊥.verts) => False.elim ⋯, invFun := fun (v : Empty) => v.elim, left_inv := ⋯, right_inv := ⋯, map_rel_iff' := ⋯ }
Instances For
Graph homomorphisms induce a covariant function on subgraphs.
Equations
- SimpleGraph.Subgraph.map f H = { verts := ⇑f '' H.verts, Adj := Relation.Map H.Adj ⇑f ⇑f, adj_sub := ⋯, edge_vert := ⋯, symm := ⋯ }
Instances For
Graph homomorphisms induce a contravariant function on subgraphs.
Equations
- SimpleGraph.Subgraph.comap f H = { verts := ⇑f ⁻¹' H.verts, Adj := fun (u v : V) => G.Adj u v ∧ H.Adj (f u) (f v), adj_sub := ⋯, edge_vert := ⋯, symm := ⋯ }
Instances For
Given two subgraphs, one a subgraph of the other, there is an induced injective homomorphism of the subgraphs as graphs.
Equations
- SimpleGraph.Subgraph.inclusion h = { toFun := fun (v : ↑x.verts) => ⟨↑v, ⋯⟩, map_rel' := ⋯ }
Instances For
There is an induced injective homomorphism of a subgraph of G
into G
.
Equations
- x.hom = { toFun := fun (v : ↑x.verts) => ↑v, map_rel' := ⋯ }
Instances For
There is an induced injective homomorphism of a subgraph of G
as
a spanning subgraph into G
.
Equations
- x.spanningHom = { toFun := id, map_rel' := ⋯ }
Instances For
Equations
If a graph is locally finite at a vertex, then so is a subgraph of that graph.
Equations
- SimpleGraph.Subgraph.finiteAt v = (G.neighborSet ↑v).fintypeSubset ⋯
If a subgraph is locally finite at a vertex, then so are subgraphs of that subgraph.
This is not an instance because G''
cannot be inferred.
Equations
- SimpleGraph.Subgraph.finiteAtOfSubgraph h v = (G''.neighborSet ↑v).fintypeSubset ⋯
Instances For
Equations
- G'.instFintypeElemNeighborSetOfVertsOfDecidablePredMemSet v = G'.verts.fintypeSubset ⋯
Equations
- SimpleGraph.Subgraph.coeFiniteAt v = Fintype.ofEquiv (↑(G'.neighborSet ↑v)) (SimpleGraph.Subgraph.coeNeighborSetEquiv v).symm
The degree of a vertex in a subgraph. It's zero for vertices outside the subgraph.
Equations
- G'.degree v = Fintype.card ↑(G'.neighborSet v)
Instances For
Properties of singletonSubgraph
and subgraphOfAdj
#
Equations
- ⋯ = ⋯
Equations
- ⋯ = ⋯
Subgraphs of subgraphs #
Given a subgraph of a subgraph of G
, construct a subgraph of G
.
Equations
- SimpleGraph.Subgraph.coeSubgraph = SimpleGraph.Subgraph.map G'.hom
Instances For
Given a subgraph of G
, restrict it to being a subgraph of another subgraph G'
by
taking the portion of G
that intersects G'
.
Equations
- SimpleGraph.Subgraph.restrict = SimpleGraph.Subgraph.comap G'.hom
Instances For
Edge deletion #
Given a subgraph G'
and a set of vertex pairs, remove all of the corresponding edges
from its edge set, if present.
See also: SimpleGraph.deleteEdges
.
Equations
- G'.deleteEdges s = { verts := G'.verts, Adj := G'.Adj \ Sym2.ToRel s, adj_sub := ⋯, edge_vert := ⋯, symm := ⋯ }
Instances For
Induced subgraphs #
The induced subgraph of a subgraph. The expectation is that s ⊆ G'.verts
for the usual
notion of an induced subgraph, but, in general, s
is taken to be the new vertex set and edges
are induced from the subgraph G'
.
Equations
Instances For
Given a subgraph and a set of vertices, delete all the vertices from the subgraph, if present. Any edges incident to the deleted vertices are deleted as well.