BondRefinable implements Refinable { @Override public Invariant neighboursInBlock(Set<Integer> block, int vertexIndex) { int neighbours = 0; for (int connected : getConnectedIndices(vertexIndex)) { if (block.contains(connected)) { neighbours++; } } return new IntegerInvariant(neighbours); } BondRefinable(IAtomContainer atomContainer);  BondRefinable(IAtomContainer atomContainer, boolean ignoreBondOrders); @Override int getVertexCount(); @Override int getConnectivity(int vertexI, int vertexJ); @Override Invariant neighboursInBlock(Set<Integer> block, int vertexIndex); Partition getInitialPartition();  }
@Test public void neighboursInBlock() { String acpString = "C0C1C2C3 0:1(1),0:3(1),1:2(1),2:3(1)"; BondRefinable bondRefinable = refinable(acpString); Set<Integer> block = new HashSet<Integer>(); block.add(1); block.add(3); assertEquals(new IntegerInvariant(1), bondRefinable.neighboursInBlock(block, 0)); assertEquals(new IntegerInvariant(1), bondRefinable.neighboursInBlock(block, 2)); }