@Override public BaseGraphFactory<GraphHead, Vertex, Edge, LogicalGraph> getFactory() { return config.getLogicalGraphFactory(); }
/** * Creates a new logical graph by union the vertex and edge sets of all graph * contained in the given collection. * * @param collection input collection * @return combined graph */ @Override public LogicalGraph execute(GraphCollection collection) { return collection.getConfig().getLogicalGraphFactory().fromDataSets( collection.getVertices(), collection.getEdges()); }
/** * Builds a {@link LogicalGraph} from the graph referenced by the given * graph variable. * * @param variable graph variable used in GDL script * @return LogicalGraph */ public LogicalGraph getLogicalGraphByVariable(String variable) { GraphHead graphHead = getGraphHeadByVariable(variable); Collection<Vertex> vertices = getVerticesByGraphVariables(variable); Collection<Edge> edges = getEdgesByGraphVariables(variable); return config.getLogicalGraphFactory().fromCollections(graphHead, vertices, edges); }
/** * Builds a {@link LogicalGraph} from the graph referenced by the given * graph variable. * * @param variable graph variable used in GDL script * @return LogicalGraph */ public LogicalGraph getLogicalGraphByVariable(String variable) { GraphHead graphHead = getGraphHeadByVariable(variable); Collection<Vertex> vertices = getVerticesByGraphVariables(variable); Collection<Edge> edges = getEdgesByGraphVariables(variable); return config.getLogicalGraphFactory().fromCollections(graphHead, vertices, edges); }
@Override public LogicalGraph getLogicalGraph() { DataSet<Vertex> vertices = config.getExecutionEnvironment().readTextFile(jsonPath) .map(new MinimalJsonToVertex(config.getVertexFactory())); return config.getLogicalGraphFactory().fromDataSets(vertices); }
@Override public GraphCollection executeForGVELayout(GraphCollection collection) { // the resulting logical graph holds multiple graph heads LogicalGraph modifiedGraph = executeInternal( collection.getGraphHeads(), collection.getVertices(), collection.getEdges(), collection.getConfig().getLogicalGraphFactory()); return collection.getFactory().fromDataSets( modifiedGraph.getGraphHead(), modifiedGraph.getVertices(), modifiedGraph.getEdges()); }
/** * {@inheritDoc} */ @Override public LogicalGraph execute(LogicalGraph graph) { DataSet<GraphHead> newGraphHead = graph .aggregate(new VertexCount(), new EdgeCount()) .getGraphHead() .map(new CalculateDensity(SamplingEvaluationConstants.PROPERTY_KEY_DENSITY)); return graph.getConfig().getLogicalGraphFactory() .fromDataSets(newGraphHead, graph.getVertices(), graph.getEdges()); }
@Override public GraphCollection executeForGVELayout(GraphCollection collection) { // the resulting logical graph holds multiple graph heads LogicalGraph modifiedGraph = executeInternal( collection.getGraphHeads(), collection.getVertices(), collection.getEdges(), collection.getConfig().getLogicalGraphFactory()); return collection.getFactory().fromDataSets( modifiedGraph.getGraphHead(), modifiedGraph.getVertices(), modifiedGraph.getEdges()); }
@Override public LogicalGraph execute(LogicalGraph graph) { DataSet<GraphHead> newGraphHead = graph .aggregate(new VertexCount(), new EdgeCount()) .getGraphHead() .map(new CalculateDensity(SamplingEvaluationConstants.PROPERTY_KEY_DENSITY)); return graph.getConfig().getLogicalGraphFactory() .fromDataSets(newGraphHead, graph.getVertices(), graph.getEdges()); } }
@Override public LogicalGraph executeInGelly(Graph<GradoopId, NullValue, NullValue> graph) throws Exception { DataSet<Tuple3<GradoopId, GradoopId, GradoopId>> triangles = new org.apache.flink.graph.library.TriangleEnumerator<GradoopId, NullValue, NullValue>() .run(graph); DataSet<GraphHead> resultHead = currentGraph.getGraphHead() .map(new WritePropertyToGraphHeadMap( PROPERTY_KEY_TRIANGLES, PropertyValue.create(triangles.count()))); return currentGraph.getConfig().getLogicalGraphFactory().fromDataSets( resultHead, currentGraph.getVertices(), currentGraph.getEdges()); }
@Override public LogicalGraph executeInGelly(Graph<GradoopId, PropertyValue, NullValue> graph) { DataSet<Vertex> labeledVertices = executeInternal(graph) .join(currentGraph.getVertices()) .where(0).equalTo(new Id<>()) .with(new LPVertexJoin(propertyKey)); // return labeled graph return currentGraph.getConfig().getLogicalGraphFactory() .fromDataSets(labeledVertices, currentGraph.getEdges()); }
/** * {@inheritDoc} */ @Override public LogicalGraph executeInGelly(Graph<GradoopId, PropertyValue, NullValue> graph) { DataSet<Vertex> labeledVertices = executeInternal(graph) .join(currentGraph.getVertices()) .where(0).equalTo(new Id<>()) .with(new LPVertexJoin(propertyKey)); // return labeled graph return currentGraph.getConfig().getLogicalGraphFactory() .fromDataSets(labeledVertices, currentGraph.getEdges()); }
@Override public LogicalGraph executeInGelly(Graph<GradoopId, NullValue, NullValue> graph) throws Exception { DataSet<Vertex> newVertices = hits.runInternal(graph) .join(currentGraph.getVertices()) .where(new HitsResultKeySelector()).equalTo(new Id<>()) .with(new HITSToAttributes(authorityPropertyKey, hubPropertyKey)); return currentGraph.getConfig().getLogicalGraphFactory() .fromDataSets(newVertices, currentGraph.getEdges()); }
@Override public LogicalGraph executeInGelly(Graph<GradoopId, NullValue, NullValue> graph) throws Exception { DataSet<Vertex> newVertices = hits.runInternal(graph) .join(currentGraph.getVertices()) .where(new HitsResultKeySelector()).equalTo(new Id<>()) .with(new HITSToAttributes(authorityPropertyKey, hubPropertyKey)); return currentGraph.getConfig().getLogicalGraphFactory() .fromDataSets(newVertices, currentGraph.getEdges()); }
@Override public LogicalGraph getGraph(final GradoopId graphID) { // filter vertices and edges based on given graph id DataSet<GraphHead> graphHead = getGraphHeads() .filter(new BySameId<>(graphID)); DataSet<Vertex> vertices = getVertices() .filter(new InGraph<>(graphID)); DataSet<Edge> edges = getEdges() .filter(new InGraph<>(graphID)); return new LogicalGraph( config.getLogicalGraphFactory().fromDataSets(graphHead, vertices, edges), getConfig()); }
@Override public LogicalGraph executeInGelly(Graph<GradoopId, NullValue, Double> graph) throws Exception { DataSet<Vertex> newVertices = new org.apache.flink.graph.library.SingleSourceShortestPaths <GradoopId, NullValue>(srcVertexId, iterations) .run(graph) .join(currentGraph.getVertices()) .where(0) .equalTo(new Id<>()) .with(new SingleSourceShortestPathsAttribute(propertyKeyVertex)); return currentGraph.getConfig().getLogicalGraphFactory().fromDataSets(newVertices, currentGraph.getEdges()); }
@Override public LogicalGraph execute(LogicalGraph graph) { DataSet<Vertex> vertices = graph.getVertices(); DataSet<Edge> edges = graph.getEdges(); DataSet<Map<String, PropertyValue>> aggregate = aggregateVertices(vertices) .union(aggregateEdges(edges)) .reduceGroup(new CombinePartitionAggregates(aggregateFunctions)); DataSet<GraphHead> graphHead = graph.getGraphHead() .map(new SetAggregateProperty(aggregateFunctions)) .withBroadcastSet(aggregate, SetAggregateProperty.VALUE); return graph.getConfig().getLogicalGraphFactory() .fromDataSets(graphHead, vertices, edges); }
@Override public LogicalGraph executeInGelly(Graph<GradoopId, NullValue, NullValue> graph) throws Exception { DataSet<Vertex> newVertices = new org.apache.flink.graph.library.linkanalysis.PageRank<GradoopId, NullValue, NullValue>( dampingFactor, iterations).setIncludeZeroDegreeVertices(includeZeroDegrees).run(graph) .join(currentGraph.getVertices()) .where(new PageRankResultKey()).equalTo(new Id<>()) .with(new PageRankToAttribute(propertyKey)); return currentGraph.getConfig().getLogicalGraphFactory().fromDataSets( currentGraph.getGraphHead(), newVertices, currentGraph.getEdges()); }
@Override public LogicalGraph execute(LogicalGraph graph) { VertexCount vertexCountAggregate = new VertexCount(); SumVertexProperty localCCAggregate = new SumVertexProperty( ClusteringCoefficientBase.PROPERTY_KEY_LOCAL); graph = new GellyLocalClusteringCoefficientDirected().execute(graph) .aggregate(vertexCountAggregate, localCCAggregate); DataSet<GraphHead> graphHead = graph.getGraphHead().map(new AddAverageCCValueToGraphHeadMap( localCCAggregate.getAggregatePropertyKey(), vertexCountAggregate.getAggregatePropertyKey(), PROPERTY_KEY_AVERAGE)); return graph.getConfig().getLogicalGraphFactory().fromDataSets( graphHead, graph.getVertices(), graph.getEdges()); }
@Override public LogicalGraph executeInGelly(Graph<GradoopId, NullValue, NullValue> graph) throws Exception { DataSet<Vertex> newVertices = new org.apache.flink.graph.library.linkanalysis.PageRank<GradoopId, NullValue, NullValue>( dampingFactor, iterations).setIncludeZeroDegreeVertices(includeZeroDegrees).run(graph) .join(currentGraph.getVertices()) .where(new PageRankResultKey()).equalTo(new Id<>()) .with(new PageRankToAttribute(propertyKey)); return currentGraph.getConfig().getLogicalGraphFactory().fromDataSets( currentGraph.getGraphHead(), newVertices, currentGraph.getEdges()); } }