code: public List<N> getConnectedComponents() {
          setMarkedAllNodes(false);
          ArrayList<N> roots = new ArrayList<N>();
          //for (int i=0; i<nodes.size(); i++) {
          for (N n : nodes) {
              if (!n.isMarked()) {
                  roots.add(n);
                  dfs(n);
              }
          }
          return roots;
      }
docs: Gets the connected components of the graph.
  @return A list containing an arbitrary node in each each connected component.