ListenableGraph extends
    ForwardingGraph<E> { @Override public void merge(Graph<E> other) { for (final Connection<E> connection : other.getConnections()) { addConnection(connection); } } ListenableGraph(Graph<E> delegateGraph); EventAPI getEventAPI(); @Override Set<Connection<E>> getConnections(); @Override void addConnection(Point from, Point to, E connData); @Override void addConnection(Point from, Point to); @Override void addConnection(Connection<E> connection); @Override void addConnections(Iterable<? extends Connection<E>> connections); @Override Optional<E> setConnectionData(Point from, Point to, E connectionData); @Override Optional<E> removeConnectionData(Point from, Point to); @Override void removeNode(Point node); @Override void removeConnection(Point from, Point to); @Override void merge(Graph<E> other); static Supplier<ListenableGraph<E>> supplier(
      Supplier<? extends Graph<E>> sup);  }
@Test public void testMerge() { ListenableGraph<LengthData> graph1 = new ListenableGraph<>( new MultimapGraph<LengthData>()); ListenableGraph<LengthData> graph2 = new ListenableGraph<>( new MultimapGraph<LengthData>()); graph1.addConnection(a, b); graph1.addConnection(b, a); graph2.addConnection(a, c); graph2.addConnection(c, a); graph1.getEventAPI().addListener(new GraphModificationChecker()); ListenerEventHistory history = new ListenerEventHistory(); graph1.getEventAPI().addListener(history); graph1.merge(graph2); assertEquals(asList(ADD_CONNECTION, ADD_CONNECTION), history.getEventTypeHistory()); assertEquals(2, history.getHistory().size()); assertEquals( new GraphEvent(ADD_CONNECTION, graph1, Connection.create(a, c, Optional.<ConnectionData>absent())), history .getHistory().get(0)); assertEquals( new GraphEvent(ADD_CONNECTION, graph1, Connection.create(c, a, Optional.<ConnectionData>absent())), history .getHistory().get(1)); }