public TopologicalSort(Digraph<?> G) {

        this.marked = new ListOrderedMap<>();

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

        this.reversePost = new Stack<>();

        for (Object x : G.getAllVertices()) {
            if (!this.marked.get(x))
                dfs(G, x);
        }

    }