use of org.gradoop.flink.model.impl.operators.layouting.functions.FRRepulsionFunction in project gradoop by dbs-leipzig.
the class FRLayouter method repulsionForces.
/**
* Calculates the repulsive forces between the given vertices.
*
* @param vertices A dataset of vertices
* @return Dataset of applied forces. May (and will) contain multiple forces for each vertex.
*/
protected DataSet<Force> repulsionForces(DataSet<LVertex> vertices) {
vertices = vertices.map(new FRCellIdMapper(getMaxRepulsionDistance()));
KeySelector<LVertex, Integer> selfselector = new FRCellIdSelector(FRCellIdSelector.NeighborType.SELF);
FRRepulsionFunction repulsionFunction = new FRRepulsionFunction(getK(), getMaxRepulsionDistance());
DataSet<Force> self = vertices.join(vertices).where(new FRCellIdSelector(FRCellIdSelector.NeighborType.SELF)).equalTo(selfselector).with((JoinFunction<LVertex, LVertex, Force>) repulsionFunction);
DataSet<Force> up = vertices.join(vertices).where(new FRCellIdSelector(FRCellIdSelector.NeighborType.UP)).equalTo(selfselector).with((FlatJoinFunction<LVertex, LVertex, Force>) repulsionFunction);
DataSet<Force> left = vertices.join(vertices).where(new FRCellIdSelector(FRCellIdSelector.NeighborType.LEFT)).equalTo(selfselector).with((FlatJoinFunction<LVertex, LVertex, Force>) repulsionFunction);
DataSet<Force> uright = vertices.join(vertices).where(new FRCellIdSelector(FRCellIdSelector.NeighborType.UPRIGHT)).equalTo(selfselector).with((FlatJoinFunction<LVertex, LVertex, Force>) repulsionFunction);
DataSet<Force> uleft = vertices.join(vertices).where(new FRCellIdSelector(FRCellIdSelector.NeighborType.UPLEFT)).equalTo(selfselector).with((FlatJoinFunction<LVertex, LVertex, Force>) repulsionFunction);
return self.union(up).union(left).union(uright).union(uleft);
}
use of org.gradoop.flink.model.impl.operators.layouting.functions.FRRepulsionFunction in project gradoop by dbs-leipzig.
the class SamplingFRLayouter method repulsionForces.
@Override
protected DataSet<Force> repulsionForces(DataSet<LVertex> vertices) {
vertices = vertices.map(new FRCellIdMapper(getMaxRepulsionDistance()));
KeySelector<LVertex, Integer> selfselector = new FRCellIdSelector(FRCellIdSelector.NeighborType.SELF);
FRRepulsionFunction repulsionFunction = new FRRepulsionFunction(getK(), getMaxRepulsionDistance());
final double samplingRateF = this.samplingRate;
DataSet<LVertex> sampledVertices = vertices.filter((FilterFunction<LVertex>) lVertex -> ThreadLocalRandom.current().nextDouble(1) < samplingRateF);
DataSet<Force> self = vertices.join(sampledVertices).where(new FRCellIdSelector(FRCellIdSelector.NeighborType.SELF)).equalTo(selfselector).with((JoinFunction<LVertex, LVertex, Force>) repulsionFunction);
DataSet<Force> up = vertices.join(sampledVertices).where(new FRCellIdSelector(FRCellIdSelector.NeighborType.UP)).equalTo(selfselector).with((JoinFunction<LVertex, LVertex, Force>) repulsionFunction);
DataSet<Force> down = vertices.join(sampledVertices).where(new FRCellIdSelector(FRCellIdSelector.NeighborType.DOWN)).equalTo(selfselector).with((JoinFunction<LVertex, LVertex, Force>) repulsionFunction);
DataSet<Force> left = vertices.join(sampledVertices).where(new FRCellIdSelector(FRCellIdSelector.NeighborType.LEFT)).equalTo(selfselector).with((JoinFunction<LVertex, LVertex, Force>) repulsionFunction);
DataSet<Force> right = vertices.join(sampledVertices).where(new FRCellIdSelector(FRCellIdSelector.NeighborType.RIGHT)).equalTo(selfselector).with((JoinFunction<LVertex, LVertex, Force>) repulsionFunction);
DataSet<Force> uright = vertices.join(sampledVertices).where(new FRCellIdSelector(FRCellIdSelector.NeighborType.UPRIGHT)).equalTo(selfselector).with((JoinFunction<LVertex, LVertex, Force>) repulsionFunction);
DataSet<Force> dright = vertices.join(sampledVertices).where(new FRCellIdSelector(FRCellIdSelector.NeighborType.DOWNRIGHT)).equalTo(selfselector).with((JoinFunction<LVertex, LVertex, Force>) repulsionFunction);
DataSet<Force> uleft = vertices.join(sampledVertices).where(new FRCellIdSelector(FRCellIdSelector.NeighborType.UPLEFT)).equalTo(selfselector).with((JoinFunction<LVertex, LVertex, Force>) repulsionFunction);
DataSet<Force> dleft = vertices.join(sampledVertices).where(new FRCellIdSelector(FRCellIdSelector.NeighborType.DOWNLEFT)).equalTo(selfselector).with((JoinFunction<LVertex, LVertex, Force>) repulsionFunction);
return self.union(up).union(left).union(uright).union(uleft).union(down).union(right).union(dright).union(dleft).map(f -> {
f.getValue().mDiv(samplingRateF);
return f;
});
}
Aggregations