code: private void dfs(int v, int[] cc, int id) {
          cc[v] = id;
          for (Edge edge : graph[v]) {
              int t = edge.v2;
              if (!digraph && t == v) {
                  t = edge.v1;
              }
  
              if (cc[t] == -1) {
                  dfs(t, cc, id);
              }
          }
      }
docs: Depth-first search connected components of graph.
  @param v the start vertex.
  @param cc the array to store the connected component id of vertices.
  @param id the current component id.