SingleNodeCrossover extends TreeCrossover<G, C> { @Override protected <A> int crossover(final TreeNode<A> that, final TreeNode<A> other) { return swap(that, other); } SingleNodeCrossover(double probability);  SingleNodeCrossover(); @Override String toString();  }
@Test public void crossover() throws IOException { final TreeNode<String> tree1 = TreeNode.of("0") .attach(TreeNode.of("1") .attach("4", "5")) .attach(TreeNode.of("2") .attach("6")) .attach(TreeNode.of("3") .attach(TreeNode.of("7") .attach("10", "11")) .attach(TreeNode.of("8")) .attach(TreeNode.of("9"))); final TreeNode<String> tree2 = TreeNode.of("a") .attach(TreeNode.of("b") .attach("e", "f")) .attach(TreeNode.of("c") .attach("g")) .attach(TreeNode.of("d") .attach(TreeNode.of("h") .attach("k", "l")) .attach(TreeNode.of("i")) .attach(TreeNode.of("j"))); final int size1 = tree1.size(); final int size2 = tree2.size(); SingleNodeCrossover.swap(tree1, tree2); Assert.assertEquals(tree1.size() + tree2.size(), size1 + size2); tree1.breadthFirstStream().forEach(n -> Objects.requireNonNull(n.value())); tree2.breadthFirstStream().forEach(n -> Objects.requireNonNull(n.value())); }