@Test public void testSelectionStep1() { 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")); }
protected Pair<Identifier, Identifier> selectionStep1(final DistanceMatrix c2c) { Pair<Identifier, Identifier> bestPair = null; double minQ = Double.MAX_VALUE; for (Map.Entry<Pair<Identifier, Identifier>, Double> entry : c2c.getMap().entrySet()) { Identifier id1 = entry.getKey().getLeft(); Identifier id2 = entry.getKey().getRight(); final double id1_2_id2 = c2c.getDistance(id1, id2); final double sumId1 = c2c.getDistances(id1, null).sum() - id1_2_id2; final double sumId2 = c2c.getDistances(id2, null).sum() - id1_2_id2; final double q = (c2c.size() - 2) * id1_2_id2 - sumId1 - sumId2; if (q < minQ) { minQ = q; bestPair = entry.getKey(); } } return bestPair; }
NeighborNetImpl implements CircularOrderingCreator { protected Pair<Identifier, Identifier> selectionStep1(final DistanceMatrix c2c) { Pair<Identifier, Identifier> bestPair = null; double minQ = Double.MAX_VALUE; for (Map.Entry<Pair<Identifier, Identifier>, Double> entry : c2c.getMap().entrySet()) { Identifier id1 = entry.getKey().getLeft(); Identifier id2 = entry.getKey().getRight(); final double id1_2_id2 = c2c.getDistance(id1, id2); final double sumId1 = c2c.getDistances(id1, null).sum() - id1_2_id2; final double sumId2 = c2c.getDistances(id2, null).sum() - id1_2_id2; final double q = (c2c.size() - 2) * id1_2_id2 - sumId1 - sumId2; if (q < minQ) { minQ = q; bestPair = entry.getKey(); } } return bestPair; } }
NeighborNetImpl implements CircularOrderingCreator { protected Pair<Identifier, Identifier> selectionStep1(final DistanceMatrix c2c) { Pair<Identifier, Identifier> bestPair = null; double minQ = Double.MAX_VALUE; for (Map.Entry<Pair<Identifier, Identifier>, Double> entry : c2c.getMap().entrySet()) { Identifier id1 = entry.getKey().getLeft(); Identifier id2 = entry.getKey().getRight(); final double id1_2_id2 = c2c.getDistance(id1, id2); final double sumId1 = c2c.getDistances(id1, null).sum() - id1_2_id2; final double sumId2 = c2c.getDistances(id2, null).sum() - id1_2_id2; final double q = (c2c.size() - 2) * id1_2_id2 - sumId1 - sumId2; if (q < minQ) { minQ = q; bestPair = entry.getKey(); } } return bestPair; } NeighborNetImpl(); }
NeighborNetImpl implements CircularOrderingCreator { protected Pair<Identifier, Identifier> selectionStep1(final DistanceMatrix c2c) { Pair<Identifier, Identifier> bestPair = null; double minQ = Double.MAX_VALUE; for (Map.Entry<Pair<Identifier, Identifier>, Double> entry : c2c.getMap().entrySet()) { Identifier id1 = entry.getKey().getLeft(); Identifier id2 = entry.getKey().getRight(); final double id1_2_id2 = c2c.getDistance(id1, id2); final double sumId1 = c2c.getDistances(id1, null).sum() - id1_2_id2; final double sumId2 = c2c.getDistances(id2, null).sum() - id1_2_id2; final double q = (c2c.size() - 2) * id1_2_id2 - sumId1 - sumId2; if (q < minQ) { minQ = q; bestPair = entry.getKey(); } } return bestPair; } NeighborNetImpl(); @Override IdentifierList createCircularOrdering(DistanceMatrix distanceMatrix); @Override boolean createsTreeSplits(); @Override SplitSystem getTreeSplits(); IdentifierList expand(Stack<VertexTriplet> stackedVertexTriplets); }
NeighborNetImpl implements CircularOrderingCreator { protected Pair<Identifier, Identifier> selectionStep1(final DistanceMatrix c2c) { Pair<Identifier, Identifier> bestPair = null; double minQ = Double.MAX_VALUE; for (Map.Entry<Pair<Identifier, Identifier>, Double> entry : c2c.getMap().entrySet()) { Identifier id1 = entry.getKey().getLeft(); Identifier id2 = entry.getKey().getRight(); final double id1_2_id2 = c2c.getDistance(id1, id2); final double sumId1 = c2c.getDistances(id1, null).sum() - id1_2_id2; final double sumId2 = c2c.getDistances(id2, null).sum() - id1_2_id2; final double q = (c2c.size() - 2) * id1_2_id2 - sumId1 - sumId2; if (q < minQ) { minQ = q; bestPair = entry.getKey(); } } return bestPair; } NeighborNetImpl(); @Override IdentifierList createCircularOrdering(DistanceMatrix distanceMatrix); @Override boolean createsTreeSplits(); @Override SplitSystem getTreeSplits(); IdentifierList expand(Stack<VertexTriplet> stackedVertexTriplets);  }