public ConnectedComponents(Graph<?> G) {

        this.initId = 0;

        this.id = new ListOrderedMap<>();

        this.marked = new ListOrderedMap<>();

        for (Object x : G.getAllVertices()) {
            this.marked.put(x, false);
        }

        for (Object x : marked.keySet()) {

            if (!this.marked.get(x)) {
                dfs(G, x);
                this.initId++;
            }
        }

    }