d = numConnectedComponents H
This function returns the number of connected components of a hypergraph. A connected component of a hypergraph is any maximal set of vertices which are pairwise connected by a nontrivial path. Isolated vertices, which are those not appearing in any edge, do not count as connected components. This is in contrast to numConnectedGraphComponents in which isolated vertices are counted as connected components. See the Connected Components Tutorial for more information.
The algorithm used by numConnectedComponents turns H into a simplicial complex, and then computes the rank of the 0^{th} reduced homology group. This number plus 1 gives the number of connected components of H.
We depart from this method in two cases: We define the hypergraph with only the empty edge (corresponding to the irrelevant simplicial complex) and the hypergraph with empty edge set (corresponding to the void simplicial complex) to have 0 connected components.
Although this method can be applied to graphs, its output does not match the most common meaning for the number of connected components of a graph. Instead, one should use numConnectedGraphComponents.





The following example contains a hypergraph with an edge of size one. The vertex in this edge is not considered isolated and does count as a connected component.





The object numConnectedComponents is a method function.