Definitions for finite and locally finite graphs #
This file defines finite versions of edgeSet
, neighborSet
and incidenceSet
and proves some
of their basic properties. It also defines the notion of a locally finite graph, which is one
whose vertices have finite degree.
The design for finiteness is that each definition takes the smallest finiteness assumption
necessary. For example, SimpleGraph.neighborFinset v
only requires that v
have
finitely many neighbors.
Main definitions #
SimpleGraph.edgeFinset
is theFinset
of edges in a graph, ifedgeSet
is finiteSimpleGraph.neighborFinset
is theFinset
of vertices adjacent to a given vertex, ifneighborSet
is finiteSimpleGraph.incidenceFinset
is theFinset
of edges containing a given vertex, ifincidenceSet
is finite
Naming conventions #
If the vertex type of a graph is finite, we refer to its cardinality as CardVerts
or card_verts
.
Implementation notes #
- A locally finite graph is one with instances
Π v, Fintype (G.neighborSet v)
. - Given instances
DecidableRel G.Adj
andFintype V
, then the graph is locally finite, too.
The edgeSet
of the graph as a Finset
.
Equations
Instances For
Alias of the reverse direction of SimpleGraph.edgeFinset_subset_edgeFinset
.
Alias of the reverse direction of SimpleGraph.edgeFinset_ssubset_edgeFinset
.
The complete graph on n
vertices has n.choose 2
edges.
Any graph on n
vertices has at most n.choose 2
edges.
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
.
Equations
- SimpleGraph.DeleteFar G p r = ∀ ⦃s : Finset (Sym2 V)⦄, s ⊆ SimpleGraph.edgeFinset G → p (SimpleGraph.deleteEdges G ↑s) → r ≤ ↑s.card
Instances For
Alias of the forward direction of SimpleGraph.deleteFar_iff
.
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
.
Equations
Instances For
G.degree v
is the number of vertices adjacent to v
.
Equations
- SimpleGraph.degree G v = (SimpleGraph.neighborFinset G v).card
Instances For
Equations
- SimpleGraph.incidenceSetFintype G v = Fintype.ofEquiv (↑(SimpleGraph.neighborSet G v)) (SimpleGraph.incidenceSetEquivNeighborSet G v).symm
This is the Finset
version of incidenceSet
.
Equations
Instances For
A graph is locally finite if every vertex has a finite neighbor set.
Equations
- SimpleGraph.LocallyFinite G = ((v : V) → Fintype ↑(SimpleGraph.neighborSet G v))
Instances For
A locally finite simple graph is regular of degree d
if every vertex has degree d
.
Equations
- SimpleGraph.IsRegularOfDegree G d = ∀ (v : V), SimpleGraph.degree G v = d
Instances For
Equations
- SimpleGraph.neighborSetFintype G v = Subtype.fintype fun (x : V) => x ∈ SimpleGraph.neighborSet G v
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
.
Equations
- SimpleGraph.minDegree G = WithTop.untop' 0 (Finset.min (Finset.image (fun (v : V) => SimpleGraph.degree G v) Finset.univ))
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
.
Equations
- SimpleGraph.maxDegree G = Option.getD (Finset.max (Finset.image (fun (v : V) => SimpleGraph.degree G v) Finset.univ)) 0
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.