code: public static <T> Set<Set<Node<T>>> compute(final Graph<T> graph) {
      final Set<Set<Node<T>>> connectedComponents = new LinkedHashSet<>();
      final Set<Node<T>> unmarkedNodes = new LinkedHashSet<>(graph.nodes());
  
      while (!unmarkedNodes.isEmpty()) {
        Set<Node<T>> connectedComp = new LinkedHashSet<>();
        deepFirstSearch(unmarkedNodes.iterator().next(), connectedComp, unmarkedNodes);
        connectedComponents.add(connectedComp);
      }
  
      return connectedComponents;
    }
docs: Computes the set of connected components of a graph, where each component is represented by a set of nodes.
  @param graph the graph
  @param <T>   the type of the graph content
  @return the set of sets of nodes representing the connected components