/** * Recursively visit 'v' and all vertices adjacent to it (excluding 'p') * adding them to the result array. * * @param visited visit flags array, should be cleared before search * @param result visited vertices * @param p previous vertex * @param v start vertex * @param n current number of visited vertices * @return new number of visited vertices */ private int visit(boolean[] visited, int[] result, int p, int v, int n) { visited[v] = true; result[n++] = v; for (int w : adjList[v]) { if (w != p && !visited[w]) { n = visit(visited, result, v, w, n); } } return n; }
/** * Recursively visit 'v' and all vertices adjacent to it (excluding 'p') * adding them to the result array. * * @param visited visit flags array, should be cleared before search * @param result visited vertices * @param p previous vertex * @param v start vertex * @param n current number of visited vertices * @return new number of visited vertices */ private int visit(boolean[] visited, int[] result, int p, int v, int n) { visited[v] = true; result[n++] = v; for (int w : adjList[v]) { if (w != p && !visited[w]) { n = visit(visited, result, v, w, n); } } return n; }
/** * Recursively visit 'v' and all vertices adjacent to it (excluding 'p') * adding all except 'v' to the result array. * * @param visited visit flags array, should be cleared before search * @param result visited vertices * @param p previous vertex * @param v start vertex * @return number of visited vertices */ private int visitAdj(boolean[] visited, int[] result, int p, int v) { int n = 0; Arrays.fill(visited, false); visited[v] = true; for (int w : adjList[v]) { if (w != p && !visited[w]) { n = visit(visited, result, v, w, n); } } visited[v] = false; return n; }
/** * Recursively visit 'v' and all vertices adjacent to it (excluding 'p') * adding all except 'v' to the result array. * * @param visited visit flags array, should be cleared before search * @param result visited vertices * @param p previous vertex * @param v start vertex * @return number of visited vertices */ private int visitAdj(boolean[] visited, int[] result, int p, int v) { int n = 0; Arrays.fill(visited, false); visited[v] = true; for (int w : adjList[v]) { if (w != p && !visited[w]) { n = visit(visited, result, v, w, n); } } visited[v] = false; return n; }
continue; Arrays.fill(visited, false); stackBackup.len = visit(visited, stackBackup.xs, v, idxs.get(bond.getOther(atom)), 0);
continue; Arrays.fill(visited, false); stackBackup.len = visit(visited, stackBackup.xs, v, idxs.get(bond.getOther(atom)), 0);