(int vertex)
| 20 | } |
| 21 | |
| 22 | void DFS(int vertex) { |
| 23 | visited[vertex] = true; /* Mark the current node as visited */ |
| 24 | System.out.print(vertex + " "); |
| 25 | |
| 26 | // Iterator<Integer> it = adj[vertex].listIterator(); |
| 27 | ListIterator<Integer> ti = adj[vertex].listIterator(); |
| 28 | while (ti.hasNext()) { |
| 29 | int n = ti.next(); |
| 30 | if (!visited[n]) |
| 31 | DFS(n); |
| 32 | } |
| 33 | } |
| 34 | |
| 35 | public static void main(String args[]) { |
| 36 | Scanner sc = new Scanner(System.in); |