@Override public DataSet<WithCount<T>> execute(LogicalGraph graph) { return compute(graph.getEdges()); } }
@Override public DataSet<Long> execute(LogicalGraph graph) { return Count.count(graph.getEdges()); } }
@Override protected DataSet<Tuple2<String, Set<PropertyValue>>> extractValuePairs(LogicalGraph graph) { return graph.getEdges().flatMap(new ExtractPropertyValues<>()); } }
@Override protected DataSet<Tuple2<Tuple2<String, String>, Set<PropertyValue>>> extractValuePairs( LogicalGraph graph) { return graph.getEdges().flatMap(new ExtractPropertyValuesByLabel<>()); }
@Override protected DataSet<Tuple2<Tuple2<String, String>, Set<PropertyValue>>> extractValuePairs( LogicalGraph graph) { return graph.getEdges().flatMap(new ExtractPropertyValuesByLabel<>()); } }
@Override protected DataSet<Tuple2<String, Set<PropertyValue>>> extractValuePairs(LogicalGraph graph) { return graph.getEdges().flatMap(new ExtractPropertyValues<>()); }
/** * Creates the meta data for the given graph. * * @param graph logical graph * @return meta data information */ default DataSet<Tuple3<String, String, String>> tuplesFromGraph(LogicalGraph graph) { return tuplesFromElements(graph.getVertices()) .union(tuplesFromElements(graph.getEdges())); }
@Override public DataSet<Long> execute(LogicalGraph graph) { return Count.count( graph.getEdges() .map(new TargetId<>()) .distinct() ); }
/** * Initializes the debug mappings between vertices/edges and their debug id. * * @param graph data graph */ private void initDebugMappings(LogicalGraph graph) { vertexMapping = graph.getVertices() .map(new PairElementWithPropertyValue<>("id")); edgeMapping = graph.getEdges() .map(new PairElementWithPropertyValue<>("id")); } }
/** * Initializes the debug mappings between vertices/edges and their debug id. * * @param graph data graph */ private void initDebugMappings(LogicalGraph graph) { vertexMapping = graph.getVertices() .map(new PairElementWithPropertyValue<>("id")); edgeMapping = graph.getEdges() .map(new PairElementWithPropertyValue<>("id")); } }
/** * Default transformation from a Gradoop Graph to a Gelly Graph. * * @param graph Gradoop Graph. * @return Gelly Graph. */ public Graph<GradoopId, VV, EV> transformToGelly(LogicalGraph graph) { DataSet<Vertex<GradoopId, VV>> gellyVertices = graph.getVertices().map(toGellyVertex); DataSet<Edge<GradoopId, EV>> gellyEdges = graph.getEdges().map(toGellyEdge); return Graph.fromDataSet(gellyVertices, gellyEdges, graph.getConfig().getExecutionEnvironment()); }
@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 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 DataSet<WithCount<String>> execute(LogicalGraph graph) { return graph.getEdges() .map(new ToSourceIdWithLabel<>()) .groupBy(0, 1) .first(1) .<Tuple1<String>>project(1) .map(new Tuple2FromTupleWithObjectAnd1L<>()) .groupBy(0) .sum(1) .map(new Tuple2ToWithCount<>()); }
@Override public DataSet<WithCount<String>> execute(LogicalGraph graph) { return graph.getEdges() .map(new ToTargetIdWithLabel<>()) .groupBy(0, 1) .first(1) .<Tuple1<String>>project(1) .map(new Tuple2FromTupleWithObjectAnd1L<>()) .groupBy(0) .sum(1) .map(new Tuple2ToWithCount<>()); }
@Override public DataSet<WithCount<Tuple2<String, String>>> execute(LogicalGraph graph) { return Count.groupBy(graph.getVertices() .map(new ToIdWithLabel<>()) .join(graph.getEdges().map(new ToTargetIdWithLabel<>())) .where(0).equalTo(0) .with(new BothLabels())) .map(new Tuple2ToWithCount<>()); }
@Override public DataSet<WithCount<Tuple2<String, String>>> execute(LogicalGraph graph) { return Count.groupBy(graph.getVertices() .map(new ToIdWithLabel<>()) .join(graph.getEdges().map(new ToSourceIdWithLabel<>())) .where(0).equalTo(0) .with(new BothLabels())) .map(new Tuple2ToWithCount<>()); }
@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()); }
@Test public void testGetEdges() throws Exception { FlinkAsciiGraphLoader loader = getSocialNetworkLoader(); Collection<Edge> inputEdges = loader.getEdges(); List<Edge> outputEdges = loader.getLogicalGraph(false).getEdges().collect(); validateEPGMElementCollections(inputEdges, outputEdges); validateEPGMGraphElementCollections(inputEdges, outputEdges); } }