WeaklyConnectedComponents
WeaklyConnectedComponents[g] gives the weakly connected components of the graph g.
WeaklyConnectedComponents[g, {v1, v2, ...}] gives the weakly connected components that include at least one of the specified vertices.
Examples
Find weakly connected components:
g = Graph[{1 -> 2, 2 -> 3, 4 -> 5}];
WeaklyConnectedComponents[g]
(* {{1, 2, 3}, {4, 5}} *)Please visit the official Wolfram Language Reference for more details.