protected void encodePaths(IAtomContainer mol, int depth, BitSet fp, int size) throws CDKException { State state = new State(mol, fp, size, depth+1); for (IAtom atom : mol.atoms()) { state.numPaths = 0; state.visit(atom); traversePaths(state, atom, null); state.unvisit(atom); } }
private void traversePaths(State state, IAtom beg, IBond prev) throws CDKException { if (!hashPseudoAtoms && isPseudo(beg)) return; state.push(beg, prev); state.addHash(encodeUniquePath(state.apath, state.bpath, state.buffer)); if (state.numPaths > pathLimit) throw new CDKException("Too many paths! Structure is likely a cage, reduce path length or increase path limit"); if (state.apath.size() < state.maxDepth) { for (IBond bond : state.getBonds(beg)) { if (bond.equals(prev)) continue; final IAtom nbr = bond.getOther(beg); if (state.visit(nbr)) { traversePaths(state, nbr, bond); state.unvisit(nbr); // traverse all paths } } } state.pop(); }