@Test public void testAttractionFunction() throws Exception { FRAttractionFunction af = new FRAttractionFunction(10); LVertex v1 = getDummyVertex(1, 1); LVertex v2 = getDummyVertex(2, 3); LVertex v3 = getDummyVertex(7, 5); LVertex v4 = getDummyVertex(1, 1); List<Force> collectorList = new ArrayList<>(); ListCollector<Force> collector = new ListCollector<>(collectorList); af.flatMap(new Tuple3<>(v1, v2, 1), collector); Vector vec12 = collectorList.get(0).getValue().copy(); Vector vec21 = collectorList.get(1).getValue().copy(); Assert.assertNotEquals(collectorList.get(0).getId(), collectorList.get(1).getId()); collectorList.clear(); af.flatMap(new Tuple3<>(v1, v3, 1), collector); Vector vec13 = collectorList.get(0).getValue().copy(); collectorList.clear(); af.flatMap(new Tuple3<>(v1, v4, 1), collector); Vector vec14 = collectorList.get(0).getValue().copy(); collectorList.clear(); af.flatMap(new Tuple3<>(v1, v1, 1), collector); Vector vec11 = collectorList.get(0).getValue().copy(); collectorList.clear(); v1 = getDummyVertex(1, 1); v3 = getDummyVertex(7, 5); af.flatMap(new Tuple3<>(v1, v3, 5), collector); Vector vec13f5 = collectorList.get(0).getValue().copy(); collectorList.clear(); Assert.assertEquals(vec12, vec21.mul(-1)); Assert.assertTrue(vec12.getX() > 0 && vec12.getY() > 0); Assert.assertTrue(vec12.magnitude() < vec13.magnitude()); Assert.assertEquals(vec14, new Vector()); Assert.assertTrue(vec11.magnitude() == 0); Assert.assertEquals(vec13.mul(5), vec13f5); }
@Override public void flatMap(Tuple3<LVertex, LVertex, Integer> vertices, Collector<Force> collector) { Force f = map(vertices); secondForce.set(vertices.f1.getId(), f.getValue().mul(-1)); collector.collect(f); collector.collect(secondForce); }
FRAttractionFunction implements
  FlatMapFunction<Tuple3<LVertex, LVertex, Integer>, Force>,
  MapFunction<Tuple3<LVertex, LVertex, Integer>, Force> { @Override public void flatMap(Tuple3<LVertex, LVertex, Integer> vertices, Collector<Force> collector) { Force f = map(vertices); secondForce.set(vertices.f1.getId(), f.getValue().mul(-1)); collector.collect(f); collector.collect(secondForce); } }
FRAttractionFunction implements
  FlatMapFunction<Tuple3<LVertex, LVertex, Integer>, Force>,
  MapFunction<Tuple3<LVertex, LVertex, Integer>, Force> { @Override public void flatMap(Tuple3<LVertex, LVertex, Integer> vertices, Collector<Force> collector) { Force f = map(vertices); secondForce.set(vertices.f1.getId(), f.getValue().mul(-1)); collector.collect(f); collector.collect(secondForce); } FRAttractionFunction(double k); }
FRAttractionFunction implements
  FlatMapFunction<Tuple3<LVertex, LVertex, Integer>, Force>,
  MapFunction<Tuple3<LVertex, LVertex, Integer>, Force> { @Override public void flatMap(Tuple3<LVertex, LVertex, Integer> vertices, Collector<Force> collector) { Force f = map(vertices); secondForce.set(vertices.f1.getId(), f.getValue().mul(-1)); collector.collect(f); collector.collect(secondForce); } FRAttractionFunction(double k); @Override void flatMap(Tuple3<LVertex, LVertex, Integer> vertices, Collector<Force> collector); @Override Force map(Tuple3<LVertex, LVertex, Integer> vertices); }
FRAttractionFunction implements
  FlatMapFunction<Tuple3<LVertex, LVertex, Integer>, Force>,
  MapFunction<Tuple3<LVertex, LVertex, Integer>, Force> { @Override public void flatMap(Tuple3<LVertex, LVertex, Integer> vertices, Collector<Force> collector) { Force f = map(vertices); secondForce.set(vertices.f1.getId(), f.getValue().mul(-1)); collector.collect(f); collector.collect(secondForce); } FRAttractionFunction(double k); @Override void flatMap(Tuple3<LVertex, LVertex, Integer> vertices, Collector<Force> collector); @Override Force map(Tuple3<LVertex, LVertex, Integer> vertices);  }