connected_components

connected_components(C, groups, unvisited)

connected_components() - Returns the connected components of a graph.

[GROUPS, ISOLATED] = CONNECTED_COMPONENTS(C)

Returns the connected components of a directed graph, specified by
a node-branch incidence matrix C, where C(I, J) = -1 if node J is
connected to the beginning of branch I, 1 if it is connected to
the end of branch I, and zero otherwise. The return value GROUPS
is a cell array of vectors of the node indices for each component.
The second return value ISOLATED is a vector of indices of isolated
nodes that have no connecting branches.