/** * Return the degree of all vertices in the graph. * * @return A DataSet of {@code Tuple2<vertexId, degree>} */ public DataSet<Tuple2<K, LongValue>> getDegrees() { return outDegrees() .union(inDegrees()).name("In- and out-degree") .groupBy(0).sum(1).name("Sum"); }
.groupBy(0, 1) .reduceGroup(new GroupReduceFunction<Tuple2<Long, Long>, Tuple2<Long, Long>>() { @Override
.groupBy((KeySelector<Tuple3<Double, StringValue, LongValue>, String>) value -> "") .reduceGroup((GroupReduceFunction<Tuple3<Double, StringValue, LongValue>, String>) (values, out) -> {}) .returns(String.class)
.groupBy((KeySelector<Tuple3<Double, StringValue, LongValue>, String>) value -> "") .sortGroup((KeySelector<Tuple3<Double, StringValue, LongValue>, String>) value -> "", Order.ASCENDING) .reduceGroup((GroupReduceFunction<Tuple3<Double, StringValue, LongValue>, String>) (values, out) -> {})
DataSet<Long> redB = sourceB.groupBy("*").reduceGroup(new IdentityGroupReducer<Long>()); redA.union(redB).groupBy("*").reduceGroup(new IdentityGroupReducer<Long>()) .output(new DiscardingOutputFormat<Long>());
/** * Return the degree of all vertices in the graph. * * @return A DataSet of {@code Tuple2<vertexId, degree>} */ public DataSet<Tuple2<K, LongValue>> getDegrees() { return outDegrees() .union(inDegrees()).name("In- and out-degree") .groupBy(0).sum(1).name("Sum"); }
/** * Return the degree of all vertices in the graph * * @return A DataSet of {@code Tuple2<vertexId, degree>} */ public DataSet<Tuple2<K, LongValue>> getDegrees() { return outDegrees() .union(inDegrees()).name("In- and out-degree") .groupBy(0).sum(1).name("Sum"); }
/** * Return the degree of all vertices in the graph. * * @return A DataSet of {@code Tuple2<vertexId, degree>} */ public DataSet<Tuple2<K, LongValue>> getDegrees() { return outDegrees() .union(inDegrees()).name("In- and out-degree") .groupBy(0).sum(1).name("Sum"); }
/** * Computes new subgraphs by grouping both graph collections by graph * identifier and returning those graphs where the group contains more * than one element. * * @return subgraph dataset of the resulting collection */ @Override protected DataSet<GraphHead> computeNewGraphHeads() { return firstCollection.getGraphHeads() .union(secondCollection.getGraphHeads()) .groupBy(new Id<GraphHead>()) .reduceGroup(new GroupCountEquals<GraphHead>(2)); }
/** * Computes new subgraphs by grouping both graph collections by graph * identifier and returning those graphs where the group contains more * than one element. * * @return subgraph dataset of the resulting collection */ @Override protected DataSet<GraphHead> computeNewGraphHeads() { return firstCollection.getGraphHeads() .union(secondCollection.getGraphHeads()) .groupBy(new Id<GraphHead>()) .reduceGroup(new GroupCountEquals<GraphHead>(2)); } }
/** * Computes the logical graph dataset for the resulting collection. * * @return logical graph dataset of the resulting collection */ @Override protected DataSet<GraphHead> computeNewGraphHeads() { // assign 1L to each logical graph in the first collection DataSet<Tuple2<GraphHead, Long>> thisGraphs = firstCollection .getGraphHeads() .map(new CreateTuple2WithLong<GraphHead>(1L)); // assign 2L to each logical graph in the second collection DataSet<Tuple2<GraphHead, Long>> otherGraphs = secondCollection .getGraphHeads() .map(new CreateTuple2WithLong<GraphHead>(2L)); // union the logical graphs, group them by their identifier and check that // there is no graph in the group that belongs to the second collection return thisGraphs .union(otherGraphs) .groupBy(new IdOf0InTuple2<GraphHead, Long>()) .reduceGroup(new RemoveCut<GraphHead>()); }
/** * Computes the logical graph dataset for the resulting collection. * * @return logical graph dataset of the resulting collection */ @Override protected DataSet<GraphHead> computeNewGraphHeads() { // assign 1L to each logical graph in the first collection DataSet<Tuple2<GraphHead, Long>> thisGraphs = firstCollection .getGraphHeads() .map(new CreateTuple2WithLong<GraphHead>(1L)); // assign 2L to each logical graph in the second collection DataSet<Tuple2<GraphHead, Long>> otherGraphs = secondCollection .getGraphHeads() .map(new CreateTuple2WithLong<GraphHead>(2L)); // union the logical graphs, group them by their identifier and check that // there is no graph in the group that belongs to the second collection return thisGraphs .union(otherGraphs) .groupBy(new IdOf0InTuple2<GraphHead, Long>()) .reduceGroup(new RemoveCut<GraphHead>()); } }
.groupBy(0) .combineGroup(new GraphVerticesEdges()) .groupBy(0)
.groupBy(0, 1) .reduceGroup(new GroupReduceFunction<Tuple2<Long, Long>, Tuple2<Long, Long>>() { @Override
.groupBy(0) .combineGroup(new GraphVerticesEdges()) .groupBy(0)
.groupBy(0, 1) .reduceGroup(new GroupReduceFunction<Tuple2<Long, Long>, Tuple2<Long, Long>>() { @Override
@Override public GraphCollection executeForGVELayout(GraphCollection collection) { DataSet<GraphHead> graphHeads = collection.getGraphHeads(); DataSet<GradoopId> graphIds = graphHeads.map(new Id<>()); DataSet<Tuple2<GradoopId, Map<String, PropertyValue>>> aggregate = aggregateVertices(collection.getVertices(), graphIds) .union(aggregateEdges(collection.getEdges(), graphIds)) .groupBy(0) .reduceGroup(new CombinePartitionApplyAggregates(aggregateFunctions)); graphHeads = graphHeads .coGroup(aggregate) .where(new Id<>()).equalTo(0) .with(new SetAggregateProperties(aggregateFunctions)); return collection.getConfig().getGraphCollectionFactory() .fromDataSets(graphHeads, collection.getVertices(), collection.getEdges()); }
@Override public GraphCollection executeForGVELayout(GraphCollection collection) { DataSet<GraphHead> graphHeads = collection.getGraphHeads(); DataSet<GradoopId> graphIds = graphHeads.map(new Id<>()); DataSet<Tuple2<GradoopId, Map<String, PropertyValue>>> aggregate = aggregateVertices(collection.getVertices(), graphIds) .union(aggregateEdges(collection.getEdges(), graphIds)) .groupBy(0) .reduceGroup(new CombinePartitionApplyAggregates(aggregateFunctions)); graphHeads = graphHeads .coGroup(aggregate) .where(new Id<>()).equalTo(0) .with(new SetAggregateProperties(aggregateFunctions)); return collection.getConfig().getGraphCollectionFactory() .fromDataSets(graphHeads, collection.getVertices(), collection.getEdges()); }
@Override public DataSet<GraphTransaction> getGraphTransactions() { DataSet<Tuple2<GradoopId, GraphElement>> graphVertexTuples = getVertices() .map(new Cast<>(GraphElement.class)) .returns(TypeExtractor.getForClass(GraphElement.class)) .flatMap(new GraphElementExpander<>()); DataSet<Tuple2<GradoopId, GraphElement>> graphEdgeTuples = getEdges() .map(new Cast<>(GraphElement.class)) .returns(TypeExtractor.getForClass(GraphElement.class)) .flatMap(new GraphElementExpander<>()); DataSet<Tuple3<GradoopId, Set<Vertex>, Set<Edge>>> transactions = graphVertexTuples .union(graphEdgeTuples) .groupBy(0) .combineGroup(new GraphVerticesEdges()) .groupBy(0) .reduceGroup(new GraphVerticesEdges()); return getGraphHeads() .leftOuterJoin(transactions) .where(new Id<>()).equalTo(0) .with(new TransactionFromSets()); }
@Override public DataSet<GraphTransaction> getGraphTransactions() { DataSet<Tuple2<GradoopId, GraphElement>> graphVertexTuples = getVertices() .map(new Cast<>(GraphElement.class)) .returns(TypeExtractor.getForClass(GraphElement.class)) .flatMap(new GraphElementExpander<>()); DataSet<Tuple2<GradoopId, GraphElement>> graphEdgeTuples = getEdges() .map(new Cast<>(GraphElement.class)) .returns(TypeExtractor.getForClass(GraphElement.class)) .flatMap(new GraphElementExpander<>()); DataSet<Tuple3<GradoopId, Set<Vertex>, Set<Edge>>> transactions = graphVertexTuples .union(graphEdgeTuples) .groupBy(0) .combineGroup(new GraphVerticesEdges()) .groupBy(0) .reduceGroup(new GraphVerticesEdges()); return getGraphHeads() .leftOuterJoin(transactions) .where(new Id<>()).equalTo(0) .with(new TransactionFromSets()); }