@@ -0,0 +1,1892 @@
+package me.alivecode.algs4;%0A%0Aimport edu.princeton.cs.algs4.In;%0Aimport edu.princeton.cs.algs4.StdOut;%0A%0A/**%0A * The %7B@code NonrecursiceDFS%7D class represents a data type%0A * for determining if the specified vertex connected to any other%0A * vertices in the specified graph using nonrecursive method.%0A */%0Apublic class NonrecursiveDFS %7B%0A    private boolean%5B%5D marked;%0A%0A    /**%0A     * Finds vertices connected to source vertex %7B@code s%7D.%0A     *%0A     * @param G the graph.%0A     * @param s the source vertex.%0A     */%0A    public NonrecursiveDFS(Graph G, int s) %7B%0A        marked = new boolean%5BG.V()%5D;%0A%0A        dfs(G, s);%0A    %7D%0A%0A    private void dfs(Graph G, int s) %7B%0A        marked%5Bs%5D = true;%0A        Stack%3CInteger%3E stack = new Stack%3C%3E();%0A        stack.push(s);%0A%0A        while(!stack.isEmpty()) %7B%0A            int v = stack.pop();%0A            for(int w: G.adj(v)) %7B%0A                if(!marked%5Bw%5D) %7B%0A                    marked%5Bw%5D = true;%0A                    stack.push(w);%0A                %7D%0A            %7D%0A        %7D%0A    %7D%0A%0A    /**%0A     * Is vertex %7B@code v%7D connected to the source vertex.%0A     *%0A     * @param v the vertex%0A     * @return %7B@code true%7D if %7B@code v%7D connected the source vertex,%0A     * %7B@code false%7D otherwise%0A     */%0A    public boolean connected(int v) %7B%0A        validateVertex(v);%0A        return marked%5Bv%5D;%0A    %7D%0A%0A    private void validateVertex(int v) %7B%0A        int V = marked.length;%0A        if (v %3C 0 %7C%7C v %3E= V) %7B%0A            throw new IllegalArgumentException();%0A        %7D%0A    %7D%0A%0A    // unit test code%0A    public static void main(String%5B%5D args) %7B%0A        In in = new In(args%5B0%5D);%0A        Graph G = new Graph(in);%0A        int s = Integer.parseInt(args%5B1%5D);%0A        NonrecursiveDFS dfs = new NonrecursiveDFS(G, s);%0A%0A        for(int v = 0; v %3C G.V(); v++) %7B%0A            if(dfs.connected(v)) %7B%0A                StdOut.print(v + %22 %22);%0A            %7D%0A        %7D%0A        StdOut.println();%0A%0A    %7D%0A%7D%0A

Add NonrecursiveDFS class, a data type for determining if any other vertices in the specified graph connected to the source vertex.