Search in sources :

Example 1 with Segment

use of algorithms.utils.planarity.Segment 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;
            }
    }
}
Also used : SimpleGraph(org._3pq.jgrapht.graph.SimpleGraph) SimpleCycle(org.openscience.cdk.ringsearch.cyclebasis.SimpleCycle) CompatibilityGraph(algorithms.utils.planarity.CompatibilityGraph) Segment(algorithms.utils.planarity.Segment)

Aggregations

CompatibilityGraph (algorithms.utils.planarity.CompatibilityGraph)1 Segment (algorithms.utils.planarity.Segment)1 SimpleGraph (org._3pq.jgrapht.graph.SimpleGraph)1 SimpleCycle (org.openscience.cdk.ringsearch.cyclebasis.SimpleCycle)1