@@ -0,0 +1,1047 @@
+package me.alivecode.algs4;%0A%0Aimport edu.princeton.cs.algs4.In;%0Aimport edu.princeton.cs.algs4.StdOut;%0A%0Apublic class Cycle %7B%0A    private boolean isCyclic;%0A    private boolean%5B%5D marked;%0A%0A    public Cycle(Graph G) %7B%0A        isCyclic = false;%0A        marked = new boolean%5BG.V()%5D;%0A%0A        for(int s = 0; s %3C G.V(); s++) %7B%0A            if (!marked%5Bs%5D) %7B%0A                dfs(G, s, s);%0A            %7D%0A        %7D%0A    %7D%0A%0A    private void dfs(Graph G, int v, int s) %7B%0A        StdOut.printf(%22dfs v:%25d, s:%25d%5Cn%22, v, s);%0A        marked%5Bv%5D = true;%0A        for(int w : G.adj(v)) %7B%0A            if (!marked%5Bw%5D) %7B%0A                dfs(G, w, v);%0A            %7D%0A            else if (w != s) %7B%0A                StdOut.printf(%22v:%25d, w:%25d, s:%25d%5Cn%22, v, w, s);%0A                isCyclic = true;%0A            %7D%0A        %7D%0A    %7D%0A%0A    public boolean isCyclic() %7B%0A        return isCyclic;%0A    %7D%0A%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        Cycle c = new Cycle(G);%0A        StdOut.println(c.isCyclic());%0A    %7D%0A%7D%0A%0A%0A

Add Cycle class, for detecting if the specified graph has cycle.