use of org.openscience.cdk.ringsearch.cyclebasis.SimpleCycle in project Smiles2Monomers by yoann-dufresne.
the class Planarity method testCycles.
private boolean testCycles(Biconnected bc) {
Set<SimpleCycle> cycles = bc.getSeparatedCycles();
Iterator<SimpleCycle> i = cycles.iterator();
if (!i.hasNext())
return true;
SimpleCycle mainCycle = i.next();
List<Segment> segments = bc.getSegments(mainCycle);
switch(segments.size()) {
case 0:
return true;
case 1:
Segment s = segments.get(0);
if (s.isStringIn(mainCycle))
return true;
else {
System.err.println("TODO : find separated cycle");
return false;
}
default:
SimpleGraph comp = new CompatibilityGraph(mainCycle, segments);
if (!this.tc.isTwoColorable(comp))
return false;
else {
for (Segment s2 : segments) if (!this.isPlanar(s2))
return false;
return true;
}
}
}
use of org.openscience.cdk.ringsearch.cyclebasis.SimpleCycle in project Smiles2Monomers by yoann-dufresne.
the class Biconnected method getSeparatedCycles.
public Set<SimpleCycle> getSeparatedCycles() {
Set<SimpleCycle> sepCycles = new HashSet<>();
Iterator<SimpleCycle> i = cycles.iterator();
while (i.hasNext()) {
SimpleCycle c = i.next();
if (this.getSegments(c).size() >= 2)
sepCycles.add(c);
}
return sepCycles;
}
Aggregations