Matchings #
A matching for a simple graph is a set of disjoint pairs of adjacent vertices, and the set of all the vertices in a matching is called its support (and sometimes the vertices in the support are said to be saturated by the matching). A perfect matching is a matching whose support contains every vertex of the graph.
In this module, we represent a matching as a subgraph whose vertices are each incident to at most one edge, and the edges of the subgraph represent the paired vertices.
Main definitions #
SimpleGraph.Subgraph.IsMatching
:M.IsMatching
means thatM
is a matching of its underlying graph.SimpleGraph.Subgraph.IsPerfectMatching
defines when a subgraphM
of a simple graph is a perfect matching, denotedM.IsPerfectMatching
.SimpleGraph.IsMatchingFree
means that a graphG
has no perfect matchings.SimpleGraph.IsCycles
means that a graph consists of cycles (including cycles of length 0, also known as isolated vertices)SimpleGraph.IsAlternating
means that edges in a graphG
are alternatingly included and not included in some other graphG'
TODO #
Define an
other
function and prove useful results about it (https://leanprover.zulipchat.com/#narrow/stream/252551-graph-theory/topic/matchings/near/266205863)Provide a bicoloring for matchings (https://leanprover.zulipchat.com/#narrow/stream/252551-graph-theory/topic/matchings/near/265495120)
Tutte's Theorem
Hall's Marriage Theorem (see
Mathlib.Combinatorics.Hall.Basic
)
The subgraph M
of G
is a matching if every vertex of M
is incident to exactly one edge in M
.
We say that the vertices in M.support
are matched or saturated.
Instances For
Given a vertex, returns the unique edge of the matching it is incident to.
Equations
- h.toEdge v = ⟨s(↑v, Exists.choose ⋯), ⋯⟩
Instances For
The subgraph M
of G
is a perfect matching on G
if it's a matching and every vertex G
is
matched.
Instances For
A graph is matching free if it has no perfect matching. It does not make much sense to consider a graph being free of just matchings, because any non-trivial graph has those.
Instances For
A graph G
consists of a set of cycles, if each vertex is either isolated or connected to
exactly two vertices. This is used to create new matchings by taking the symmDiff
with cycles.
The definition of symmDiff
that makes sense is the one for SimpleGraph
. The symmDiff
for SimpleGraph.Subgraph
deriving from the lattice structure also affects the vertices included,
which we do not want in this case. This is why this property is defined for SimpleGraph
, rather
than SimpleGraph.Subgraph
.
Instances For
Given a vertex with one edge in a graph of cycles this gives the other edge incident to the same vertex.
A graph G
is alternating with respect to some other graph G'
, if exactly every other edge in
G
is in G'
. Note that the degree of each vertex needs to be at most 2 for this to be
possible. This property is used to create new matchings using symmDiff
.
The definition of symmDiff
that makes sense is the one for SimpleGraph
. The symmDiff
for SimpleGraph.Subgraph
deriving from the lattice structure also affects the vertices included,
which we do not want in this case. This is why this property, just like IsCycles
, is defined
for SimpleGraph
rather than SimpleGraph.Subgraph
.