ExplicitToImplicit extends AbstractFunction<Graph, Graph> { public Graph apply(final Graph g) { Graph h = new Graph(g.order()); for (int u = 0; u < g.order(); u++) { h.addAtom(g.atom(u)); h.addTopology(g.topologyOf(u)); } for (int u = 0; u < g.order(); u++) { for (final Edge e : g.edges(u)) { if (e.other(u) > u) h.addEdge(toImplicitEdge(g, e)); } } return h; }  Graph apply(final Graph g);  }
@Test public void phenylbenzene() throws Exception { Graph g = Parser.parse("c:1:c:c:c(c:c1)-c:2:c:c:c:c:c2"); Assert.assertThat(Generator.generate(g), CoreMatchers.is("c:1:c:c:c(c:c1)-c:2:c:c:c:c:c2")); Assert.assertThat(Generator.generate(f.apply(g)), CoreMatchers.is("c1ccc(cc1)-c2ccccc2")); }
@Test public void benzene() throws Exception { Graph g = Parser.parse("c:1:c:c:c:c:c1"); Assert.assertThat(Generator.generate(g), CoreMatchers.is("c:1:c:c:c:c:c1")); Assert.assertThat(Generator.generate(f.apply(g)), CoreMatchers.is("c1ccccc1")); }
@Test public void benzeneMixed() throws Exception { Graph g = Parser.parse("C:1:C:C:C:C:C1"); Assert.assertThat(Generator.generate(g), CoreMatchers.is("C:1:C:C:C:C:C1")); Assert.assertThat(Generator.generate(f.apply(g)), CoreMatchers.is("C:1:C:C:C:C:C1")); }