AtomRefinable implements Refinable { @Override public Invariant neighboursInBlock(Set<Integer> block, int vertexIndex) { if (ignoreBondOrders || maxBondOrder == 1) { return getSimpleInvariant(block, vertexIndex); } else { return getMultipleInvariant(block, vertexIndex); } } AtomRefinable(IAtomContainer atomContainer);  AtomRefinable(IAtomContainer atomContainer, boolean ignoreElements, boolean ignoreBondOrders); @Override Invariant neighboursInBlock(Set<Integer> block, int vertexIndex); @Override int getVertexCount(); @Override int getConnectivity(int vertexI, int vertexJ); @Override Partition getInitialPartition();  }
@Test public void neighboursInBlockForSingleBonds() { String acpString = "C0C1C2C3 0:1(1),0:3(1),1:2(1),2:3(1)"; IAtomContainer ac = AtomContainerPrinter.fromString(acpString, builder); AtomRefinable refinable = new AtomRefinable(ac); Invariant invariant = refinable.neighboursInBlock(set(0, 2), 1); assertTrue(invariant instanceof IntegerInvariant); assertEquals(new IntegerInvariant(2), invariant); }
@Test public void neighboursInBlockForMultipleBonds() { String acpString = "C0C1C2C3C4 0:1(1),0:2(2),0:3(1),1:4(1),2:4(1),3:4(2)"; IAtomContainer ac = AtomContainerPrinter.fromString(acpString, builder); AtomRefinable refinable = new AtomRefinable(ac); Invariant invariant = refinable.neighboursInBlock(set(1, 2), 0); assertTrue(invariant instanceof IntegerListInvariant); assertEquals(new IntegerListInvariant(new int[] {1, 1}), invariant); }
@Test public void neighboursInBlockForMultipleBondsIgnoringBondOrders() { String acpString = "C0C1C2C3C4 0:1(1),0:2(2),0:3(1),1:4(1),2:4(1),3:4(2)"; IAtomContainer ac = AtomContainerPrinter.fromString(acpString, builder); AtomRefinable refinable = new AtomRefinable(ac, false, true); Invariant invariant = refinable.neighboursInBlock(set(1, 2), 0); assertTrue(invariant instanceof IntegerInvariant); assertEquals(new IntegerInvariant(2), invariant); }