BondRefinable implements Refinable { public Partition getInitialPartition() { int bondCount = atomContainer.getBondCount(); Map<String, SortedSet<Integer>> cellMap = new HashMap<String, SortedSet<Integer>>(); for (int bondIndex = 0; bondIndex < bondCount; bondIndex++) { IBond bond = atomContainer.getBond(bondIndex); String el0 = bond.getAtom(0).getSymbol(); String el1 = bond.getAtom(1).getSymbol(); String boS; if (ignoreBondOrders) { boS = "1"; } else { boolean isArom = bond.getFlag(CDKConstants.ISAROMATIC); int orderNumber = (isArom) ? 5 : bond.getOrder().numeric(); boS = String.valueOf(orderNumber); } String bondString; if (el0.compareTo(el1) < 0) { bondString = el0 + boS + el1; } else { bondString = el1 + boS + el0; } SortedSet<Integer> cell; if (cellMap.containsKey(bondString)) { cell = cellMap.get(bondString); } else { cell = new TreeSet<Integer>(); cellMap.put(bondString, cell); } cell.add(bondIndex); } List<String> bondStrings = new ArrayList<String>(cellMap.keySet()); Collections.sort(bondStrings); Partition bondPartition = new Partition(); for (String key : bondStrings) { SortedSet<Integer> cell = cellMap.get(key); bondPartition.addCell(cell); } bondPartition.order(); return bondPartition; } 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 getBondPartitionTest() { String acpString = "C0C1C2C3O4 0:1(2),0:4(1),1:2(1),2:3(2),3:4(1)"; IAtomContainer ac = AtomContainerPrinter.fromString(acpString, builder); BondRefinable refinable = new BondRefinable(ac); Partition bondPartition = refinable.getInitialPartition(); Partition expected = Partition.fromString("0,3|1,4|2"); assertEquals(expected, bondPartition); }