Method
isCyclic
(List<List<Integer>> adj, int[] visited, int curr)
Source from the content-addressed store, hash-verified
| 22 | } |
| 23 | |
| 24 | private boolean isCyclic(List<List<Integer>> adj, int[] visited, int curr) { |
| 25 | if (visited[curr] == 2) { |
| 26 | return true; |
| 27 | } |
| 28 | |
| 29 | visited[curr] = 2; |
| 30 | for (int i = 0; i < adj.get(curr).size(); i++) { |
| 31 | if (visited[adj.get(curr).get(i)] != 1) { |
| 32 | if (isCyclic(adj, visited, adj.get(curr).get(i))) { |
| 33 | return true; |
| 34 | } |
| 35 | } |
| 36 | } |
| 37 | visited[curr] = 1; |
| 38 | return false; |
| 39 | } |
| 40 | } |
Tested by
no test coverage detected