Connected components of multigraphs #
A connected component of a multigraph is a minimal nonempty closed subgraph. This formulation retains every loop and parallel-edge identity in a component, while the component partition of the actual vertices agrees with the connected components of the underlying simple graph.
The definitions of Graph.IsConnectedComponentOf and Graph.Connected, together with their
elementary order API, follow Peter Nelson and Jun Kwon's Mathlib proposal
mathlib4#37861. The comparison with
SimpleGraph.ConnectedComponent and the finite component count are developed here.
Main definitions #
Graph.IsConnectedComponentOf H Gsays thatHis a minimal nonempty closed subgraph ofG.Graph.Connected Gsays thatGis its own connected component.Graph.ConnectedComponent Gis the type of connected-component subgraphs ofG.Graph.connectedComponentOf G x hxis the connected component containing the vertexx.Graph.connectedComponentEquividentifies these subgraphs with the connected components ofG.toSimpleGraph.Graph.componentCount Gcounts the components viaNat.card, so it is0if there are infinitely many; it is exact whenever there are finitely many components.Graph.ConnectedComponent.mapOfLEmaps native components along a subgraph inclusion.
Component membership is described by the walk-based Graph.Reachable, which agrees with
reachability in the underlying simple graph.
Component subgraphs and connectedness #
A connected component of G is a nonempty closed subgraph of G that contains no smaller
nonempty closed subgraph of G.
A connected component is closed in its ambient graph.
A connected component is induced in its ambient graph.
A connected component is a subgraph of its ambient graph.
A connected component has an actual vertex.
A component of G contained in an intermediate graph is a component of that graph.
A multigraph is connected exactly when it is a connected component of itself.
A nonempty closed subgraph of a connected graph is the whole graph.
Every connected-component subgraph is connected.
Comparison with the underlying simple graph #
The actual vertices belonging to a component of the underlying simple graph.
Instances For
A point belongs to the lifted vertex set exactly when it has a proof of membership in the ambient graph whose corresponding actual vertex lies in the simple component.
The multigraph induced on a component of its underlying simple graph. It retains all loops and all parallel-edge identities whose endpoints lie in the component.
Instances For
Links of a component subgraph are precisely the ambient links with both endpoints in its component vertex set.
The edges of a component subgraph are the ambient edges with both endpoints in its component vertex set.
The component subgraph induced by a simple connected component is a subgraph of the multigraph.
The component subgraph induced by a simple connected component is closed in the multigraph.
The component subgraph induced by a simple connected component is nonempty.
A closed subgraph sharing a vertex with a simple component contains the whole component subgraph.
Lifting an underlying simple component gives a connected component of the multigraph.
Regard an underlying simple component as a connected-component subgraph.
Instances For
The subgraph underlying the lifted simple component is its induced component subgraph.
The underlying simple component containing a connected-component subgraph.
Instances For
A connected-component subgraph is the induced graph on the support of its underlying simple component.
The support of the underlying simple component is exactly the actual vertex set of the component subgraph.
A vertex lies in the underlying simple component of a connected-component subgraph exactly when it is a vertex of that subgraph.
Passing from an underlying simple component to its component subgraph and back recovers the simple component.
Connected-component subgraphs are equivalent to connected components of the underlying simple graph.
Instances For
The component equivalence sends a component subgraph to its underlying simple component.
The inverse component equivalence induces the ambient multigraph on a simple component.
Two connected components sharing a vertex are equal.
Two actual vertices have the same simple component exactly when they are reachable from each other.
A connected-component subgraph is the component of each of its vertices.
A subgraph is a connected component exactly when it is induced on a component of the underlying simple graph.
Connectedness and the component count #
Multigraph connectedness agrees with connectedness of the underlying simple graph.
A multigraph is connected exactly when it has an actual vertex and any two actual vertices are reachable from each other.
The component count is the cardinality of the native component-subgraph type.
The component count is the number of connected components of the underlying simple graph.
The component count of a simple graph regarded as a multigraph is its usual number of connected components.
A multigraph with finitely many components has no components exactly when it has no actual vertices.
A multigraph has one component exactly when it is connected.
Subgraph inclusions #
Along a subgraph inclusion H ≤ G, the simple component of z in H maps to the simple
component of w in G exactly when w is reachable from z in G.
A subgraph inclusion maps each native connected component to the ambient connected component containing it.
Instances For
Every vertex of a component remains in the ambient component obtained by mapping along a subgraph inclusion.
A component maps along a subgraph inclusion to exactly the ambient component containing all of its vertices.
If deleting a finite set of vertices leaves finitely many connected components, then the original graph also has finitely many connected components.
Basic examples #
The empty graph has no connected components.
A single isolated vertex is one connected component.
Two vertices joined by a nonempty set of edges form one component. When x = y the edges
are loops at a single vertex; otherwise they are parallel edges joining x to y.