use of org.gradoop.flink.model.impl.operators.layouting.functions.LVertexEPGMVertexJoinFunction in project gradoop by dbs-leipzig.
the class FRLayouter method execute.
@Override
public LogicalGraph execute(LogicalGraph g) {
g = createInitialLayout(g);
DataSet<EPGMVertex> gradoopVertices = g.getVertices();
DataSet<EPGMEdge> gradoopEdges = g.getEdges();
DataSet<LVertex> vertices = gradoopVertices.map((v) -> new LVertex(v));
DataSet<LEdge> edges = gradoopEdges.map((e) -> new LEdge(e));
IterativeDataSet<LVertex> loop = vertices.iterate(iterations);
LGraph graph = new LGraph(loop, edges);
layout(graph);
vertices = loop.closeWith(graph.getVertices());
gradoopVertices = vertices.join(gradoopVertices).where(LVertex.ID_POSITION).equalTo("id").with(new LVertexEPGMVertexJoinFunction());
return g.getFactory().fromDataSets(gradoopVertices, gradoopEdges);
}
use of org.gradoop.flink.model.impl.operators.layouting.functions.LVertexEPGMVertexJoinFunction in project gradoop by dbs-leipzig.
the class CentroidFRLayouter method execute.
@Override
public LogicalGraph execute(LogicalGraph g) {
g = createInitialLayout(g);
DataSet<EPGMVertex> gradoopVertices = g.getVertices();
DataSet<EPGMEdge> gradoopEdges = g.getEdges();
DataSet<LVertex> vertices = gradoopVertices.map(LVertex::new);
DataSet<LEdge> edges = gradoopEdges.map(LEdge::new);
centroids = chooseInitialCentroids(vertices);
// flink can only iterate over one dataset at once. Create a dataset containing both
// centroids and vertices. Split them again at the begin of every iteration
DataSet<SimpleGraphElement> graphElements = vertices.map(x -> x);
graphElements = graphElements.union(centroids.map(x -> x));
IterativeDataSet<SimpleGraphElement> loop = graphElements.iterate(iterations);
vertices = loop.filter(x -> x instanceof LVertex).map(x -> (LVertex) x);
centroids = loop.filter(x -> x instanceof Centroid).map(x -> (Centroid) x);
centroids = calculateNewCentroids(centroids, vertices);
center = calculateLayoutCenter(vertices);
LGraph graph = new LGraph(vertices, edges);
// we have overridden repulsionForces() so layout() will use or new centroid-based solution
layout(graph);
graphElements = graph.getVertices().map(x -> x);
graphElements = graphElements.union(centroids.map(x -> x));
graphElements = loop.closeWith(graphElements);
vertices = graphElements.filter(x -> x instanceof LVertex).map(x -> (LVertex) x);
gradoopVertices = vertices.join(gradoopVertices).where(LVertex.ID_POSITION).equalTo(new Id<>()).with(new LVertexEPGMVertexJoinFunction());
return g.getFactory().fromDataSets(gradoopVertices, gradoopEdges);
}
use of org.gradoop.flink.model.impl.operators.layouting.functions.LVertexEPGMVertexJoinFunction in project gradoop by dbs-leipzig.
the class FusingFRLayouter method buildPostLayoutGraph.
/**
* Extract all subverties/subedges from the super-vertices/super-edges and place them at the
* location of the super-vertex (and add some random jitter to the positions).
* Then some more layouting-iteraions are performed.
*
* @param input Original input graph
* @param graph Result of the layouting
* @return The final graph, containing all vertices and edges from the original graph.
*/
protected LogicalGraph buildPostLayoutGraph(LogicalGraph input, LGraph graph) {
DataSet<LVertex> vertices = graph.getVertices().flatMap(new LVertexFlattener(true, getK()));
DataSet<LEdge> edges = input.getEdges().map(LEdge::new);
graph.setEdges(edges);
// use a new applicator for all following layouting iterations. The new applicator will
// behave as if iteration x of n is actually iterations+x of n+POST_ITERATIONS
applicator = new FRForceApplicator(getWidth(), getHeight(), getK(), iterations + POST_ITERATIONS);
applicator.setPreviousIterations(iterations);
// do some more layouting iterations
IterativeDataSet<LVertex> loop = vertices.iterate(POST_ITERATIONS);
graph.setVertices(loop);
layout(graph);
vertices = loop.closeWith(graph.getVertices());
DataSet<EPGMVertex> gradoopVertices = vertices.join(input.getVertices()).where(LVertex.ID_POSITION).equalTo("id").with(new LVertexEPGMVertexJoinFunction());
return input.getFactory().fromDataSets(gradoopVertices, input.getEdges());
}
Aggregations