### Question:
NeighborNetImpl implements CircularOrderingCreator { protected Pair<Identifier, Identifier> selectionStep2(Pair<Identifier, Identifier> selectedClusters) { Pair<Identifier, Identifier> bestPair = null; double minQ = Double.MAX_VALUE; DistanceMatrix v2v = this.mx.getV2V(); IdentifierList vertices1 = this.mx.getVertices(selectedClusters.getLeft()); IdentifierList vertices2 = this.mx.getVertices(selectedClusters.getRight()); if (vertices1.size() == 1 && vertices2.size() == 1) { return new ImmutablePair<>(vertices1.get(0), vertices2.get(0)); } IdentifierList vertexUnion = new IdentifierList(); vertexUnion.addAll(vertices1); vertexUnion.addAll(vertices2); final double mhat = this.mx.getNbClusters() + vertexUnion.size() - 2; for (Identifier v1 : vertices1) { for (Identifier v2 : vertices2) { double q = 0.0; if (false) { final double sumV1 = this.mx.sumVertex2Clusters(v1) - this.mx.getDistance(selectedClusters.getRight(), v1); final double sumV2 = this.mx.sumVertex2Clusters(v2) - this.mx.getDistance(selectedClusters.getLeft(), v2); double sumVId1 = 0.0; double sumVId2 = 0.0; for (Identifier v : vertexUnion) { sumVId1 += v2v.getDistance(v1, v); sumVId2 += v2v.getDistance(v2, v); } final double dist = v2v.getDistance(v1, v2); final double mult = mhat - 2; q = (mult * dist) - sumV1 - sumV2 - sumVId1 - sumVId2; } else { final double sumV1 = this.mx.sumVertex2Clusters(v1); final double sumV2 = this.mx.sumVertex2Clusters(v2); final double dist = v2v.getDistance(v1, v2); final double mult = mhat - 2; q = (mult * dist) - sumV1 - sumV2; } if (q < minQ) { minQ = q; bestPair = new ImmutablePair<>(v1, v2); } } } return bestPair; } NeighborNetImpl(); @Override IdentifierList createCircularOrdering(DistanceMatrix distanceMatrix); @Override boolean createsTreeSplits(); @Override SplitSystem getTreeSplits(); IdentifierList expand(Stack<VertexTriplet> stackedVertexTriplets);  }### Answer:
@Test public void testSelectionStep2() { DistanceMatrix c2c = new FlexibleDistanceMatrix(new IdentifierList(taxa), distances1); NeighborNetImpl nn = new NeighborNetImpl(); Pair<Identifier, Identifier> selectedComponents = nn.selectionStep1(c2c); assertTrue(selectedComponents.getLeft().getName().equals("C")); assertTrue(selectedComponents.getRight().getName().equals("D")); }