public <N,E> List<Graph<N,E>> getComponents(Graph<N,E> graph)
Finds all connected components in a graph and returns an array of these components. Each component is itself an array that contains the ids of nodes in the component.
This function takes O(|V|) time.