out.collect(new Tuple3<>(first.f0, first.f1, second.f1)); }).withForwardedFieldsFirst("f0;f1").withForwardedFieldsSecond("f1"); new Tuple3<>(vertex.getValue(), degrees.f1, degrees.f2))); }).withForwardedFieldsFirst("f0");
.groupBy(0, 2, 3) .aggregate(Aggregations.SUM, 1);
.join(this.vertices).where(0).equalTo(0) .with(new ProjectVertexIdJoin<>(1)) .withForwardedFieldsFirst("f1->f0").name("Edge with source vertex ID"); return edgesWithSources.groupBy(0).reduceGroup( new ApplyNeighborGroupReduceFunction<>(neighborsFunction)) .join(this.vertices).where(1).equalTo(0) .with(new ProjectVertexIdJoin<>(0)) .withForwardedFieldsFirst("f0").name("Edge with target vertex ID"); return edgesWithTargets.groupBy(0).reduceGroup( new ApplyNeighborGroupReduceFunction<>(neighborsFunction)) .flatMap(new EmitOneEdgeWithNeighborPerNode<>()) .join(this.vertices).where(1).equalTo(0) .with(new ProjectEdgeWithNeighbor<>()).name("Edge with vertex ID");
neighbors = iteration .getWorkset().join(edgeDataSet) .where(0).equalTo(0).with(new ProjectKeyWithNeighborOUT<>()).union(iteration .getWorkset().join(edgeDataSet) .where(0).equalTo(1).with(new ProjectKeyWithNeighborIN<>()));
neighbors = iteration .getWorkset().join(edgeDataSet) .where(0).equalTo(0).with(new ProjectKeyWithNeighborOUT<>()).union(iteration .getWorkset().join(edgeDataSet) .where(0).equalTo(1).with(new ProjectKeyWithNeighborIN<>()));
neighbors = iteration .getWorkset().join(edgeDataSet) .where(0).equalTo(0).with(new ProjectKeyWithNeighborOUT<K, VV, EV>()).union(iteration .getWorkset().join(edgeDataSet) .where(0).equalTo(1).with(new ProjectKeyWithNeighborIN<K, VV, EV>()));
.where(flinkKeys[0]).equalTo(flinkKeys[i]) .with(new TupleAppendJoiner(i)) .returns(tupleJoinListsTypeInfo) .withForwardedFieldsFirst(flinkKeys[0]) .setParallelism(probeSideDOP)
.where(0).equalTo(0) .with(new AppendVertexState<K, VV, Message>()) .returns(new TupleTypeInfo<Tuple2<Vertex<K, VV>, Either<NullValue, Message>>>( vertexType, nullableMsgTypeInfo));
.where(flinkKeys[0]).equalTo(flinkKeys[1]) .with(new BinaryHashJoinJoiner(node, inputFields[0], keyFields[0])) .withParameters(this.getFlinkNodeConfig(node)) .setParallelism(probeSideDOP) .returns(new TupleTypeInfo(outFields)) .where(flinkKeys[0]).equalTo(flinkKeys[i]) .with(new TupleAppendJoiner(i)) .returns(tupleJoinListsTypeInfo) .withForwardedFieldsFirst(flinkKeys[0]) .setParallelism(probeSideDOP) .where(flinkKeys[0]).equalTo(flinkKeys[numJoinInputs-1]) .with(new NaryHashJoinJoiner(node, numJoinInputs)) .withParameters(this.getFlinkNodeConfig(node)) .setParallelism(probeSideDOP) .returns(new TupleTypeInfo(outFields))
.where(0).equalTo(0) .with(new AppendVertexState<>()) .returns(new TupleTypeInfo<>( vertexType, nullableMsgTypeInfo));
.where(0).equalTo(0) .with(new AppendVertexState<>()) .returns(new TupleTypeInfo<>( vertexType, nullableMsgTypeInfo));
.where(new SourceId<>()).equalTo(new Id<>()) .with(new RightSide<>()) .union(tobeUnitedWith) .distinct(new Id<>());
/** * Returns the subgraph of the given supergraph that is induced by the * edges that fulfil the given filter function. * * @param superGraph supergraph * @return edge-induced subgraph */ private LG edgeInducedSubgraph(LG superGraph) { DataSet<E> filteredEdges = superGraph.getEdges().filter(edgeFilterFunction); DataSet<V> filteredVertices = filteredEdges .join(superGraph.getVertices()) .where(new SourceId<>()).equalTo(new Id<>()) .with(new RightSide<>()) .union(filteredEdges .join(superGraph.getVertices()) .where(new TargetId<>()).equalTo(new Id<>()) .with(new RightSide<>())) .distinct(new Id<>()); return superGraph.getFactory().fromDataSets(filteredVertices, filteredEdges); }
@Override public LogicalGraph executeInGelly(Graph<GradoopId, GradoopId, NullValue> graph) throws Exception { DataSet<Vertex> annotatedVertices = new org.apache.flink.graph.library.ConnectedComponents< GradoopId, GradoopId, NullValue>(maxIterations).run(graph) .join(currentGraph.getVertices()) .where(0).equalTo(new Id<>()) .with(new GellyVertexValueToVertexPropertyJoin(propertyKey)); DataSet<Edge> edges = currentGraph.getEdges(); if (annotateEdges) { edges = edges.join(annotatedVertices) .where(new SourceId<>()).equalTo(new Id<>()) .with(new VertexPropertyToEdgePropertyJoin(propertyKey)) .join(annotatedVertices) .where(new TargetId<>()).equalTo(new Id<>()) .with(new VertexPropertyToEdgePropertyJoin(propertyKey)); } return currentGraph.getConfig().getLogicalGraphFactory().fromDataSets( currentGraph.getGraphHead(), annotatedVertices, edges); } }
/** * Computes the intersection between the edge set and the given edge set. For all matching pairs, * only one edge will be in the resulting data set. * * @param edges edges to compute intersection with * @return edge set containing one edge for all matching pairs of the same edge */ private DataSet<Edge<K, EV>> getDistinctEdgeIntersection(DataSet<Edge<K, EV>> edges) { return this.getEdges() .join(edges) .where(0, 1, 2) .equalTo(0, 1, 2) .with(new JoinFunction<Edge<K, EV>, Edge<K, EV>, Edge<K, EV>>() { @Override public Edge<K, EV> join(Edge<K, EV> first, Edge<K, EV> second) throws Exception { return first; } }).withForwardedFieldsFirst("*").name("Intersect edges") .distinct() .name("Edges"); }
/** * Returns the subgraph of the given supergraph that is induced by the * edges that fulfil the given filter function. * * @param superGraph supergraph * @return edge-induced subgraph */ private LG edgeInducedSubgraph(LG superGraph) { DataSet<E> filteredEdges = superGraph.getEdges().filter(edgeFilterFunction); DataSet<V> filteredVertices = filteredEdges .join(superGraph.getVertices()) .where(new SourceId<>()).equalTo(new Id<>()) .with(new RightSide<>()) .union(filteredEdges .join(superGraph.getVertices()) .where(new TargetId<>()).equalTo(new Id<>()) .with(new RightSide<>())) .distinct(new Id<>()); return superGraph.getFactory().fromDataSets(filteredVertices, filteredEdges); }
@Override public LogicalGraph sample(LogicalGraph graph) { DataSet<Vertex> sampledVertices = graph.getVertices() .map(new VertexRandomMarkedMap(sampleSize, randomSeed, PROPERTY_KEY_SAMPLED)); DataSet<Edge> newEdges = graph.getEdges() .join(sampledVertices) .where(new SourceId<>()).equalTo(new Id<>()) .with(new EdgeSourceVertexJoin(PROPERTY_KEY_SAMPLED)) .join(sampledVertices) .where(1).equalTo(new Id<>()) .with(new EdgeTargetVertexJoin(PROPERTY_KEY_SAMPLED)) .filter(new EdgesWithSampledVerticesFilter(neighborType)) .map(new Value0Of3<>()); graph = graph.getFactory().fromDataSets(graph.getVertices(), newEdges); graph = new FilterVerticesWithDegreeOtherThanGiven(0L).execute(graph); return graph; } }
/** * Returns the subgraph of the given supergraph that is induced by the * vertices that fulfil the given filter function. * * @param superGraph supergraph * @return vertex-induced subgraph */ private LG vertexInducedSubgraph(LG superGraph) { DataSet<V> filteredVertices = superGraph.getVertices().filter(vertexFilterFunction); DataSet<E> newEdges = superGraph.getEdges() .join(filteredVertices) .where(new SourceId<>()).equalTo(new Id<>()) .with(new LeftSide<>()) .join(filteredVertices) .where(new TargetId<>()).equalTo(new Id<>()) .with(new LeftSide<>()); return superGraph.getFactory().fromDataSets(filteredVertices, newEdges); }
@Override public DataSet<Edge<K, Tuple2<EV, Degrees>>> runInternal(Graph<K, VV, EV> input) throws Exception { // s, d(s) DataSet<Vertex<K, Degrees>> vertexDegrees = input .run(new VertexDegrees<K, VV, EV>() .setParallelism(parallelism)); // s, t, d(s) return input.getEdges() .join(vertexDegrees, JoinHint.REPARTITION_HASH_SECOND) .where(0) .equalTo(0) .with(new JoinEdgeWithVertexDegree<>()) .setParallelism(parallelism) .name("Edge source degrees"); } }
/** * Returns the subgraph of the given supergraph that is induced by the * vertices that fulfil the given filter function. * * @param superGraph supergraph * @return vertex-induced subgraph */ private LG vertexInducedSubgraph(LG superGraph) { DataSet<V> filteredVertices = superGraph.getVertices().filter(vertexFilterFunction); DataSet<E> newEdges = superGraph.getEdges() .join(filteredVertices) .where(new SourceId<>()).equalTo(new Id<>()) .with(new LeftSide<>()) .join(filteredVertices) .where(new TargetId<>()).equalTo(new Id<>()) .with(new LeftSide<>()); return superGraph.getFactory().fromDataSets(filteredVertices, newEdges); }