Subgraphs of a simple graph #
THIS FILE IS SYNCHRONIZED WITH MATHLIB4. Any changes to this file require a corresponding PR to mathlib4.
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 : simple_graph
-
subgraph.neighbor_set
,subgraph.incidence_set
, andsubgraph.degree
are like theirsimple_graph
counterparts, but they refer to vertices fromG
to avoid subtype coercions. -
subgraph.coe
is the coercion from aG' : subgraph G
to asimple_graph G'.verts
. (This cannot be ahas_coe
instance since the destination type depends onG'
.) -
subgraph.is_spanning
for whether a subgraph is a spanning subgraph andsubgraph.is_induced
for whether a subgraph is an induced subgraph. -
Instances for
lattice (subgraph G)
andbounded_order (subgraph G)
. -
simple_graph.to_subgraph
: If asimple_graph
is a subgraph of another, then you can turn it into a member of the larger graph'ssimple_graph.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
set_like
does not apply to this kind of subobject.
Todo #
- Images of graph homomorphisms as subgraphs.
- 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 . "obviously"
A subgraph of a simple_graph
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
.
Instances for simple_graph.subgraph
- simple_graph.subgraph.has_sizeof_inst
- simple_graph.subgraph.has_sup
- simple_graph.subgraph.has_inf
- simple_graph.subgraph.has_top
- simple_graph.subgraph.has_bot
- simple_graph.subgraph.has_Sup
- simple_graph.subgraph.has_Inf
- simple_graph.subgraph.distrib_lattice
- simple_graph.subgraph.bounded_order
- simple_graph.subgraph.complete_distrib_lattice
- simple_graph.subgraph.subgraph_inhabited
The one-vertex subgraph.
Coercion from G' : subgraph G
to a simple_graph ↥G'.verts
.
A subgraph is called a spanning subgraph if it contains all the vertices of G
.
Equations
- G'.is_spanning = ∀ (v : V), v ∈ G'.verts
Coercion from subgraph G
to simple_graph V
. If G'
is a spanning
subgraph, then G'.spanning_coe
yields an isomorphic graph.
In general, this adds in all vertices from V
as isolated vertices.
spanning_coe
is equivalent to coe
for a subgraph that is_spanning
.
H.support
is the set of vertices that form edges in the subgraph H
.
G'.neighbor_set v
is the set of vertices adjacent to v
in G'
.
Equations
- G'.neighbor_set v = set_of (G'.adj v)
Instances for ↥simple_graph.subgraph.neighbor_set
A subgraph as a graph has equivalent neighbor sets.
The edge set of G'
consists of a subset of edges of G
.
Equations
- G'.edge_set = sym2.from_rel _
The incidence_set
is the set of edges incident to a given vertex.
Equations
- G'.incidence_set v = {e ∈ G'.edge_set | v ∈ e}
Create an equal copy of a subgraph (see copy_eq
) with possibly different definitional equalities.
See Note [range copy pattern].
The union of two subgraphs.
The intersection of two subgraphs.
For subgraphs G₁
, G₂
, G₁ ≤ G₂
iff G₁.verts ⊆ G₂.verts
and
∀ a b, G₁.adj a b → G₂.adj a b
.
Equations
- simple_graph.subgraph.distrib_lattice = {sup := distrib_lattice.sup (show distrib_lattice G.subgraph, from function.injective.distrib_lattice (λ (G' : G.subgraph), (G'.verts, G'.spanning_coe)) simple_graph.subgraph.distrib_lattice._proof_1 simple_graph.subgraph.distrib_lattice._proof_2 simple_graph.subgraph.distrib_lattice._proof_3), le := λ (x y : G.subgraph), x.verts ⊆ y.verts ∧ ∀ ⦃v w : V⦄, x.adj v w → y.adj v w, lt := distrib_lattice.lt (show distrib_lattice G.subgraph, from function.injective.distrib_lattice (λ (G' : G.subgraph), (G'.verts, G'.spanning_coe)) simple_graph.subgraph.distrib_lattice._proof_1 simple_graph.subgraph.distrib_lattice._proof_2 simple_graph.subgraph.distrib_lattice._proof_3), le_refl := _, le_trans := _, lt_iff_le_not_le := _, le_antisymm := _, le_sup_left := _, le_sup_right := _, sup_le := _, inf := distrib_lattice.inf (show distrib_lattice G.subgraph, from function.injective.distrib_lattice (λ (G' : G.subgraph), (G'.verts, G'.spanning_coe)) simple_graph.subgraph.distrib_lattice._proof_1 simple_graph.subgraph.distrib_lattice._proof_2 simple_graph.subgraph.distrib_lattice._proof_3), inf_le_left := _, inf_le_right := _, le_inf := _, le_sup_inf := _}
Equations
- simple_graph.subgraph.complete_distrib_lattice = {sup := has_sup.sup simple_graph.subgraph.has_sup, le := has_le.le (preorder.to_has_le G.subgraph), lt := distrib_lattice.lt simple_graph.subgraph.distrib_lattice, le_refl := _, le_trans := _, lt_iff_le_not_le := _, le_antisymm := _, le_sup_left := _, le_sup_right := _, sup_le := _, inf := has_inf.inf simple_graph.subgraph.has_inf, inf_le_left := _, inf_le_right := _, le_inf := _, Sup := has_Sup.Sup simple_graph.subgraph.has_Sup, le_Sup := _, Sup_le := _, Inf := has_Inf.Inf simple_graph.subgraph.has_Inf, Inf_le := _, le_Inf := _, top := ⊤, bot := ⊥, le_top := _, bot_le := _, inf_Sup_le_supr_inf := _, infi_sup_le_sup_Inf := _}
Equations
Turn a subgraph of a simple_graph
into a member of its subgraph type.
The top of the subgraph G
lattice is equivalent to the graph itself.
The bottom of the subgraph G
lattice is equivalent to the empty graph on the empty
vertex type.
Graph homomorphisms induce a covariant function on subgraphs.
Graph homomorphisms induce a contravariant function on subgraphs.
Given two subgraphs, one a subgraph of the other, there is an induced injective homomorphism of the subgraphs as graphs.
There is an induced injective homomorphism of a subgraph of G
as
a spanning subgraph into G
.
Equations
If a graph is locally finite at a vertex, then so is a subgraph of that graph.
Equations
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
Equations
The degree of a vertex in a subgraph. It's zero for vertices outside the subgraph.
Equations
- G'.degree v = fintype.card ↥(G'.neighbor_set v)
Properties of singleton_subgraph
and subgraph_of_adj
#
Subgraphs of subgraphs #
Given a subgraph of a subgraph of G
, construct a subgraph of G
.
Equations
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
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: simple_graph.delete_edges
.
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'
.
Given a subgraph and a set of vertices, delete all the vertices from the subgraph, if present. Any edges indicent to the deleted vertices are deleted as well.
Equations
- G'.delete_verts s = G'.induce (G'.verts \ s)