@Test public void testCompare() { DefaultVertexCompareFunction cf = new DefaultVertexCompareFunction(10); LVertex v1 = new LVertex(null, new Vector(10, 10), -1, null, new Vector(5, 0)); LVertex v2 = new LVertex(null, new Vector(10, 10), -1, null, new Vector(-5, 0)); LVertex v3 = new LVertex(null, new Vector(10, 10), -1, null, new Vector(6, 0)); Assert.assertEquals(1, cf.compare(v1, v1), 0.0000001); Assert.assertEquals(0, cf.compare(v1, v2), 0.0000001); Assert.assertTrue(cf.compare(v1, v3) > 0.5); LVertex v4 = new LVertex(null, new Vector(10, 20), -1, null, new Vector(5, 0)); LVertex v5 = new LVertex(null, new Vector(10, 30), -1, null, new Vector(5, 0)); LVertex v6 = new LVertex(null, new Vector(10, 15), -1, null, new Vector(5, 0)); Assert.assertEquals(1, cf.compare(v1, v4), 0.0000001); Assert.assertEquals(1, cf.compare(v1, v6), 0.0000001); Assert.assertEquals(0, cf.compare(v1, v5), 0.0000001); LVertex v7 = new LVertex(null, new Vector(10, 10), -1, Arrays.asList(GradoopId.get(), GradoopId.get(), GradoopId.get()), new Vector(50, 0)); Assert.assertEquals(1, cf.compare(v7, v7), 0.0000001); Assert.assertEquals(0, cf.compare(v7, v2), 0.0000001); Assert.assertTrue(cf.compare(v7, v3) > 0.5); }
@Override public double compare(LVertex v1, LVertex v2) { double positionSimilarity = Math.min(1, Math.max(0, 1 - ((v1.getPosition().distance(v2.getPosition()) - k) / k))); Vector force1 = v1.getForce().div(v1.getCount()); Vector force2 = v2.getForce().div(v2.getCount()); double forceSimilarity = 1 - (force1.distance(force2) / (force1.magnitude() + force2.magnitude())); return positionSimilarity * forceSimilarity; }
DefaultVertexCompareFunction implements VertexCompareFunction { @Override public double compare(LVertex v1, LVertex v2) { double positionSimilarity = Math.min(1, Math.max(0, 1 - ((v1.getPosition().distance(v2.getPosition()) - k) / k))); Vector force1 = v1.getForce().div(v1.getCount()); Vector force2 = v2.getForce().div(v2.getCount()); double forceSimilarity = 1 - (force1.distance(force2) / (force1.magnitude() + force2.magnitude())); return positionSimilarity * forceSimilarity; } }
DefaultVertexCompareFunction implements VertexCompareFunction { @Override public double compare(LVertex v1, LVertex v2) { double positionSimilarity = Math.min(1, Math.max(0, 1 - ((v1.getPosition().distance(v2.getPosition()) - k) / k))); Vector force1 = v1.getForce().div(v1.getCount()); Vector force2 = v2.getForce().div(v2.getCount()); double forceSimilarity = 1 - (force1.distance(force2) / (force1.magnitude() + force2.magnitude())); return positionSimilarity * forceSimilarity; } DefaultVertexCompareFunction(double k); }
DefaultVertexCompareFunction implements VertexCompareFunction { @Override public double compare(LVertex v1, LVertex v2) { double positionSimilarity = Math.min(1, Math.max(0, 1 - ((v1.getPosition().distance(v2.getPosition()) - k) / k))); Vector force1 = v1.getForce().div(v1.getCount()); Vector force2 = v2.getForce().div(v2.getCount()); double forceSimilarity = 1 - (force1.distance(force2) / (force1.magnitude() + force2.magnitude())); return positionSimilarity * forceSimilarity; } DefaultVertexCompareFunction(double k); @Override double compare(LVertex v1, LVertex v2); }
DefaultVertexCompareFunction implements VertexCompareFunction { @Override public double compare(LVertex v1, LVertex v2) { double positionSimilarity = Math.min(1, Math.max(0, 1 - ((v1.getPosition().distance(v2.getPosition()) - k) / k))); Vector force1 = v1.getForce().div(v1.getCount()); Vector force2 = v2.getForce().div(v2.getCount()); double forceSimilarity = 1 - (force1.distance(force2) / (force1.magnitude() + force2.magnitude())); return positionSimilarity * forceSimilarity; } DefaultVertexCompareFunction(double k); @Override double compare(LVertex v1, LVertex v2);  }