EccentricConnectivityIndexDescriptor extends AbstractMolecularDescriptor implements IMolecularDescriptor { @Override public DescriptorValue calculate(IAtomContainer container) { IAtomContainer local = AtomContainerManipulator.removeHydrogens(container); int natom = local.getAtomCount(); int[][] admat = AdjacencyMatrix.getMatrix(local); int[][] distmat = PathTools.computeFloydAPSP(admat); int eccenindex = 0; for (int i = 0; i < natom; i++) { int max = -1; for (int j = 0; j < natom; j++) { if (distmat[i][j] > max) max = distmat[i][j]; } int degree = local.getConnectedBondsCount(i); eccenindex += max * degree; } IntegerResult retval = new IntegerResult(eccenindex); return new DescriptorValue(getSpecification(), getParameterNames(), getParameters(), retval, getDescriptorNames(), null); } EccentricConnectivityIndexDescriptor(); @Override DescriptorSpecification getSpecification(); @Override void setParameters(Object[] params); @Override Object[] getParameters(); @Override String[] getDescriptorNames(); @Override String[] getParameterNames(); @Override Object getParameterType(String name); @Override DescriptorValue calculate(IAtomContainer container); @Override IDescriptorResult getDescriptorResultType();  }
@Test public void testEccentricConnectivityIndex() throws ClassNotFoundException, CDKException, java.lang.Exception { String filename = "data/hin/gravindex.hin"; InputStream ins = this.getClass().getClassLoader().getResourceAsStream(filename); ISimpleChemObjectReader reader = new HINReader(ins); ChemFile content = (ChemFile) reader.read((ChemObject) new ChemFile()); List cList = ChemFileManipulator.getAllAtomContainers(content); IAtomContainer ac = (IAtomContainer) cList.get(0); addImplicitHydrogens(ac); IntegerResult retval = (IntegerResult) descriptor.calculate(ac).getValue(); Assert.assertEquals(254, retval.intValue(), 0); }