Multigraphs #
Shared graph-theoretic infrastructure reused across papers (e.g. multigraphs, usage matrices)
that isn't already in Mathlib. Mathlib's SimpleGraph doesn't allow parallel edges or loops, so
multigraphs need their own structure.
The simple graph obtained from a set of edges by forgetting multiplicities,
loops, and edge identities, remembering only which pairs of vertices are
joined by some edge in F.
Equations
- G.toSimpleGraph F = SimpleGraph.fromEdgeSet (G.endpoints '' F)
Instances For
If F is a finite set of edges, then the support of the simple graph on F is finite.
A set of edges F is a forest if it has no loops, no two edges of F
share the same endpoints (parallel edges would form a 2-cycle), and the
underlying simple graph on F is acyclic.
Equations
Instances For
A set of edges T is a spanning tree if it is a forest whose underlying
simple graph is connected, i.e. it touches and joins every vertex of V.
Equations
- G.IsSpanningTree T = (G.IsForest T ∧ (G.toSimpleGraph T).Connected)
Instances For
If F is a forest and F' is a subset of F, then F' is also a forest.
If F is a forest and e={u,v} is an edge not in F with the property
that u and v are not reachable in the graph induced by F, then F ∪ {e} is also a forest.
The number of connected components of the simple graph on edge set F that meet
the vertex set S. Counted as the number of distinct ConnectedComponents hit by S,
so a vertex of S untouched by any edge of F contributes its own singleton
component.
Equations
- G.numComponents F S = ((G.toSimpleGraph F).connectedComponentMk '' S).ncard
Instances For
A nonempty, finite vertex set always splits into at least one component.
Rank–nullity for forests: a finite forest's edge count equals the number of
vertices it touches (or any finite vertex set S containing them) minus the number of
components those vertices fall into. This is the key counting fact behind the
augmentation property of the cycle matroid (GraphicMatroid): it lets us compare the
edge counts of two forests component-by-component.
A finite forest restricted to a finite vertex set S has strictly fewer edges than
S has vertices, as long as S is nonempty. The forest need not touch all of S, nor
be connected; this is the inequality used for the "smaller" side of the augmentation
argument, while IsForest.ncard_add_numComponents gives the exact count needed for the
"larger" (already-spanning) side.