use of nl.uu.cs.treewidth.timing.Stopwatch in project Smiles2Monomers by yoann-dufresne.
the class MolTreeWidth method calculateTreeWidth.
public int calculateTreeWidth(IMolecule m) {
NGraph<InputData> g;
AtomContainerToNgraph converter = new AtomContainerToNgraph();
IAtomContainer mol = m;
if (!ConnectivityChecker.isConnected(mol)) {
IMoleculeSet comps = ConnectivityChecker.partitionIntoMolecules(mol);
int maxIndex = 0;
int maxCount = -9999;
for (int i = 0; i < comps.getAtomContainerCount(); i++) {
if (comps.getAtomContainer(i).getAtomCount() > maxCount) {
maxCount = comps.getAtomContainer(i).getAtomCount();
maxIndex = i;
}
}
mol = comps.getAtomContainer(maxIndex);
}
g = converter.convert(mol);
Stopwatch stopwatch = new Stopwatch(new JavaNanoTime());
Permutation<InputData> p = new LexBFS<InputData>();
PermutationToTreeDecomposition<InputData> pttd = new PermutationToTreeDecomposition<InputData>(p);
stopwatch.reset();
stopwatch.start();
pttd.setInput(g);
pttd.run();
stopwatch.stop();
return pttd.getUpperBound();
}
Aggregations