use of org.gradoop.flink.model.impl.operators.layouting.util.LVertex in project gradoop by dbs-leipzig.
the class FRForceApplicatorTest method testForceApplicator.
@Test
public void testForceApplicator() {
FRForceApplicator fa = new FRForceApplicator(1000, 1000, 10, 25);
Assert.assertEquals(707.1, fa.speedForIteration(0), 0.1);
Assert.assertEquals(537.96, fa.speedForIteration(1), 0.1);
Assert.assertEquals(1.0, fa.speedForIteration(24), 0.1);
Vector pos = new Vector(950, 0);
LVertex v = new LVertex();
v.setPosition(pos);
Force force = new Force(null, new Vector(0, 300));
fa.apply(v, force, 200);
Assert.assertEquals(pos, new Vector(950, 200));
Force force2 = new Force(null, new Vector(1000, 1000));
fa.apply(v, force2, 10000);
Assert.assertEquals(pos, new Vector(999, 999));
v.addSubVertex(GradoopId.get());
v.setPosition(new Vector(100, 100));
Force force3 = new Force(null, new Vector(50, 50));
fa.apply(v, force3, 10000);
Assert.assertEquals(new Vector(125, 125), v.getPosition());
Assert.assertEquals(new Vector(50, 50), v.getForce());
}
use of org.gradoop.flink.model.impl.operators.layouting.util.LVertex in project gradoop by dbs-leipzig.
the class FRRepulsionFunctionTest method testRepulseJoinFunction.
@Test
public void testRepulseJoinFunction() throws Exception {
JoinFunction<LVertex, LVertex, Force> jf = new FRRepulsionFunction(1, 20);
LVertex v1 = getDummyVertex(1, 1);
LVertex v2 = getDummyVertex(2, 3);
LVertex v3 = getDummyVertex(7, 5);
LVertex v4 = getDummyVertex(1, 1);
LVertex v5 = getDummyVertex(30, 30);
Vector vec12 = jf.join(v1, v2).getValue().copy();
Vector vec13 = jf.join(v1, v3).getValue().copy();
Vector vec14 = jf.join(v1, v4).getValue().copy();
Vector vec11 = jf.join(v1, v1).getValue().copy();
Vector vec15 = jf.join(v1, v5).getValue().copy();
Assert.assertTrue(vec12.getX() < 0 && vec12.getY() < 0);
Assert.assertTrue(vec12.magnitude() > vec13.magnitude());
Assert.assertTrue(vec14.magnitude() > 0);
Assert.assertTrue(vec11.magnitude() == 0);
Assert.assertTrue(vec15.magnitude() == 0);
}
use of org.gradoop.flink.model.impl.operators.layouting.util.LVertex in project gradoop by dbs-leipzig.
the class FRRepulsionFunctionTest method testRepulseFlatJoin.
@Test
public void testRepulseFlatJoin() throws Exception {
FRRepulsionFunction jf = new FRRepulsionFunction(1);
LVertex v1 = getDummyVertex(1, 1);
LVertex v2 = getDummyVertex(2, 3);
Vector vec12join = jf.join(v1, v2).getValue().copy();
v1 = getDummyVertex(1, 1);
v2 = getDummyVertex(2, 3);
List<Force> collectorList = new ArrayList<>();
ListCollector<Force> collector = new ListCollector<>(collectorList);
jf.join(v1, v2, collector);
Vector vec12 = collectorList.get(0).getValue().copy();
Vector vec21 = collectorList.get(1).getValue().copy();
v1 = getDummyVertex(1, 1);
v2 = getDummyVertex(2, 3);
v1.setSubVertices(generateSubVertices(1));
v2.setSubVertices(generateSubVertices(2));
Vector vec12joinf6 = jf.join(v1, v2).getValue().copy();
Assert.assertEquals(vec12join, vec12);
Assert.assertEquals(vec12, vec21.mul(-1));
Assert.assertNotEquals(collectorList.get(0).getId(), collectorList.get(1).getId());
Assert.assertEquals(vec12join.mul(6), vec12joinf6);
}
use of org.gradoop.flink.model.impl.operators.layouting.util.LVertex in project gradoop by dbs-leipzig.
the class VertexFusorTest method testCandidateGenerator.
@Test
public void testCandidateGenerator() throws Exception {
LEdge dummyEdge = new LEdge();
Tuple2<LEdge, Tuple2<LVertex, Boolean>> source = new Tuple2<>(dummyEdge, new Tuple2<>());
Tuple2<LVertex, Boolean> target = new Tuple2<>();
List<Tuple3<LVertex, LVertex, Double>> collectorList = new ArrayList<>();
ListCollector<Tuple3<LVertex, LVertex, Double>> collector = new ListCollector<>(collectorList);
VertexFusor.CandidateGenerator gen = new VertexFusor.CandidateGenerator(null, 0.5);
source.f1.f1 = true;
target.f1 = true;
gen.join(source, target, collector);
Assert.assertEquals(0, collectorList.size());
source.f1.f1 = false;
target.f1 = false;
gen.join(source, target, collector);
Assert.assertEquals(0, collectorList.size());
source.f1.f1 = true;
source.f1.f0 = new LVertex();
target.f1 = false;
target.f0 = new LVertex();
gen.cf = (a, b) -> 0.6;
gen.join(source, target, collector);
Assert.assertEquals(1, collectorList.size());
Assert.assertEquals(0.6, (double) collectorList.get(0).f2, 0.0000001);
Assert.assertEquals(source.f1.f0, collectorList.get(0).f1);
collectorList.clear();
source.f1.f1 = false;
target.f1 = true;
gen.join(source, target, collector);
Assert.assertEquals(1, collectorList.size());
Assert.assertEquals(0.6, (double) collectorList.get(0).f2, 0.0000001);
Assert.assertEquals(target.f0, collectorList.get(0).f1);
collectorList.clear();
gen.cf = (a, b) -> 0.4;
gen.join(source, target, collector);
Assert.assertEquals(0, collectorList.size());
}
use of org.gradoop.flink.model.impl.operators.layouting.util.LVertex in project gradoop by dbs-leipzig.
the class VertexFusorTest method testSuperVertexGenerator.
@Test
public void testSuperVertexGenerator() throws Exception {
VertexFusor.SuperVertexGenerator gen = new VertexFusor.SuperVertexGenerator();
LVertex receiver = new LVertex(GradoopId.get(), new Vector(10, 10), -1, generateSubVertices(4), new Vector(10, 10));
LVertex donor1 = new LVertex(GradoopId.get(), new Vector(100, 100), -1, null, new Vector(10, 10));
LVertex donor2 = new LVertex(GradoopId.get(), new Vector(1000, 1000), -1, generateSubVertices(2), new Vector(10, 10));
LVertex donor3 = new LVertex(GradoopId.get(), new Vector(10000, 10000), -1, null, new Vector(10, 10));
List<Tuple2<LVertex, LVertex>> vertices = new ArrayList<>();
vertices.add(new Tuple2<>(donor1, receiver));
vertices.add(new Tuple2<>(donor2, receiver));
vertices.add(new Tuple2<>(donor3, receiver));
List<LVertex> collectorList = new ArrayList<>();
ListCollector<LVertex> collector = new ListCollector<>(collectorList);
Vector expectedPosition = receiver.getPosition().mul(5).add(donor1.getPosition()).add(donor2.getPosition().mul(3)).add(donor3.getPosition()).div(10);
gen.reduce(vertices, collector);
Assert.assertEquals(1, collectorList.size());
LVertex superVertex = collectorList.get(0);
Assert.assertEquals(receiver.getId(), superVertex.getId());
Assert.assertEquals(10, superVertex.getCount());
Assert.assertEquals(expectedPosition, superVertex.getPosition());
}
Aggregations