d = numConnectedGraphComponents G
This function returns the number of connected components of a graph. A connected component of a graph is any maximal set of vertices which are pairwise connected by a path. Isolated vertices, which are those not appearing in any edge, count as connected components. This is in contrast to numConnectedComponents in which isolated vertices are not counted as connected components. See the Connected Components Tutorial for more information.
The algorithm used by numConnectedGraphComponents turns G into a simplicial complex, and then computes the rank of the 0^{th} reduced homology group. This number plus 1 plus the number of isolated vertices of G gives the number of connected components of G.
This method is intended to match the most common meaning for the number of connected components of a graph. This method can also be used on hypergraphs.







The object numConnectedGraphComponents is a method function.