/** * Convert a graph with atom-based double-bond stereo configuration to * bond-based specification (direction UP and DOWN bonds). * * @param g chemical graph graph * @return a copy of the original graph but with bond-based * stereo-chemistry */ public static Graph bondBasedDBStereo(Graph g) { return eti.apply(ftt.apply(ite.apply(g))); }
public Graph apply(Graph g) { Graph h = new Graph(g.order()); // copy atom/topology information this is unchanged for (int u = 0; u < g.order(); u++) { if (g.topologyOf(u).type() == DoubleBond) { h.addAtom(reducedAtom(g, u)); } else { h.addAtom(g.atom(u)); h.addTopology(g.topologyOf(u)); } } Map<Edge, Edge> replacements = new Traversal(g).replacement; // append the edges, replacing any which need to be changed for (int u = 0; u < g.order(); u++) { for (Edge e : g.edges(u)) { if (e.other(u) > u) { Edge replacement = replacements.get(e); if (replacement != null) e = replacement; h.addEdge(e); } } } return h; }