private static int dfs(Graph graph, boolean[] marked, Stack<Integer> stack, int[] low, 
      int pre, int v, Set<Graph> graphs) { 
    marked[v] = true;
    low[v] = pre++;
    int min = low[v];
    stack.push(v);
    
    for (int w : graph.getOutEdges(v)) {
        if (!marked[w]) pre = dfs(graph, marked, stack, low, pre, w, graphs);
        if (low[w] < min) min = low[w];
    }
    if (min < low[v]) { low[v] = min; return pre; }
    
    
    List<String> vertices = graph.getVertices();
    List<String> component = new ArrayList<String>();
    int w;
    do {
        w = stack.pop();
        component.add(vertices.get(w));
        low[w] = graph.size();
    } while (w != v);
    graphs.add(GraphMaker.makeGraph(component, "Component" + graphs.size()));
    return pre;
}