/** * Collapse a graph with specified atom properties to one with organic * subset atoms. * * @param g a chemical graph * @return the chemical graph expanded */ public static Graph collapse(Graph g) { return eti.apply(tsa.apply(ite.apply(g))); }
private Atom reducedAtom(Graph g, int u) { Atom a = g.atom(u); int sum = 0; for (Edge e : g.edges(u)) { sum += e.bond().order(); } return ToSubsetAtoms.toSubset(g.atom(u), g, u); }
public Graph apply(Graph g) { Graph h = new Graph(g.order()); for (int u = 0; u < g.order(); u++) { // only attempt subset conversion if no known topology Topology t = g.topologyOf(u); if (t.type() == None) { h.addAtom(toSubset(g.atom(u), g, u)); } else { h.addAtom(g.atom(u)); h.addTopology(t); } } // edges are unchanged for (Edge e : g.edges()) h.addEdge(e); return h; }