@@ -0,0 +1,1185 @@
+import java.util.*;%0A%0A%0Apublic class DFS %7B%0A%0A    public static void dfs(node  start)%7B%0A        ArrayDeque%3Cnode%3E s = new ArrayDeque%3Cnode%3E();%0A%0A        s.push(start);%0A        while(s.isEmpty() == false)%7B%0A            node top = s.pop();%0A            %0A            if(top.visited == false)%7B%0A                top.visited = true;%0A                System.out.println(%22Visit %22 + top.name);%0A            %7D%0A            ArrayList%3Cnode%3E n;%0A            n = top.neighbors;%0A            for (node a: n)%7B%0A                s.push(a);%0A            %7D%0A%0A        %7D%0A    %7D%0A    %0A    public static void main(String args%5B%5D)%7B%0A        node a = new node(%22A%22);%0A        node b = new node(%22B%22);%0A        node c = new node(%22C%22);%0A        node d = new node(%22D%22);%0A%0A        ArrayList%3Cnode%3E la = new ArrayList%3Cnode%3E();%0A        la.add(b);%0A        la.add(c);%0A        ArrayList%3Cnode%3E lc = new ArrayList%3Cnode%3E();%0A        lc.add(d);%0A%0A        a.neighbors = la;%0A        c.neighbors = lc;%0A        %0A        dfs(a);%0A    %7D%0A%0A%7D%0A%0Aclass node %7B%0A   ArrayList%3Cnode%3E neighbors;%0A   String name;%0A   boolean visited ;%0A   public node(String name)%7B%0A        this.name = name; %0A        this.visited = false;%0A        this.neighbors = new ArrayList%3Cnode%3E();%0A   %7D%0A%7D;%0A

Add version of depth first search in java.