# Counting the number of unconnected subgraphs

If I have a Graph, how can I count how many disconnected pieces it has? Mathematica must know this since it is able to separate them out when it displays the graph, but I can't find any function which gives the number.

You can use Length@WeaklyConnectedComponents[graph]. This will work on directed graphs as well, assuming that you are looking for the components of the underlying undirected graph.
IGraph/M also has a fast function for measuring the sizes of connected components without actually returning them: IGWeaklyConnectedComponentSizes.
Length@ConnectedGraphComponents