VFState extends AbstractVFState { @Override boolean feasible(int n, int m) { if (!atomMatcher.matches(container1.getAtom(n), container2.getAtom(m))) return false; int nTerminal1 = 0, nTerminal2 = 0; int nRemain1 = 0, nRemain2 = 0; for (int n_prime : g1[n]) { int m_prime = m1[n_prime]; if (m_prime != UNMAPPED) { IBond bond2 = bonds2.get(m, m_prime); if (bond2 == null) return false; if (!bondMatcher.matches(bonds1.get(n, n_prime), bond2)) return false; } else { if (t1[n_prime] > 0) nTerminal1++; else nRemain1++; } } for (int m_prime : g2[m]) { int n_prime = m2[m_prime]; if (n_prime != UNMAPPED) { IBond bond1 = bonds1.get(n, n_prime); if (bond1 == null) return false; if (!bondMatcher.matches(bond1, bonds2.get(m, m_prime))) return false; } else { if (t2[m_prime] > 0) nTerminal2++; else nRemain2++; } } return nTerminal1 == nTerminal2 && nRemain1 == nRemain2; } VFState(IAtomContainer container1, IAtomContainer container2, int[][] g1, int[][] g2, EdgeToBondMap bonds1,
            EdgeToBondMap bonds2, AtomMatcher atomMatcher, BondMatcher bondMatcher);   }
@Test public void infeasibleAtoms() throws Exception { AtomMatcher mock = mock(AtomMatcher.class); when(mock.matches(any(IAtom.class), any(IAtom.class))).thenReturn(false); VFState state = createBenzeneToNaphthalene(mock, mock(BondMatcher.class)); for (int i = 0; i < state.nMax(); i++) { for (int j = 0; j < state.mMax(); j++) { assertFalse(state.feasible(i, j)); } } }
@Test public void infeasibleBonds() throws Exception { BondMatcher mock = mock(BondMatcher.class); when(mock.matches(any(IBond.class), any(IBond.class))).thenReturn(false); VFState state = createBenzeneToNaphthalene(AtomMatcher.forAny(), mock); state.m1[0] = 0; state.m1[1] = 1; state.m1[2] = 2; state.m1[3] = 3; state.m1[4] = 4; for (int i = 0; i < 4; i++) { for (int j = 0; j < 4; j++) { assertFalse(state.feasible(i, j)); } } }
@Test public void infeasibleTerminalCount() throws Exception { VFState state = createBenzeneToNaphthalene(AtomMatcher.forAny(), BondMatcher.forAny()); assertTrue(state.feasible(4, 4)); state.add(0, 0); state.add(1, 1); state.add(2, 2); state.add(3, 3); assertFalse(state.feasible(4, 4)); }