use of org.apache.flink.api.java.tuple.Tuple2 in project flink by apache.
the class ReduceOnNeighborMethodsITCase method testSumOfOutNeighborsIdGreaterThanThree.
@Test
public void testSumOfOutNeighborsIdGreaterThanThree() throws Exception {
/*
* Get the sum of out-neighbor values
* for each vertex with id greater than three.
*/
final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
Graph<Long, Long, Long> graph = Graph.fromDataSet(TestGraphUtils.getLongLongVertexData(env), TestGraphUtils.getLongLongEdgeData(env), env);
DataSet<Tuple2<Long, Long>> verticesWithSumOfOutNeighborValues = graph.groupReduceOnNeighbors(new SumOutNeighborsIdGreaterThanThree(), EdgeDirection.OUT);
List<Tuple2<Long, Long>> result = verticesWithSumOfOutNeighborValues.collect();
expectedResult = "4,5\n" + "5,1\n";
compareResultAsTuples(result, expectedResult);
}
use of org.apache.flink.api.java.tuple.Tuple2 in project flink by apache.
the class ReduceOnNeighborMethodsITCase method testSumOfOAllNeighborsAddFive.
@Test
public void testSumOfOAllNeighborsAddFive() throws Exception {
/*
* Get the sum of all neighbor values
* including own vertex value
* for each vertex as well as the same sum plus five.
*/
final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
Graph<Long, Long, Long> graph = Graph.fromDataSet(TestGraphUtils.getLongLongVertexData(env), TestGraphUtils.getLongLongEdgeData(env), env);
DataSet<Tuple2<Long, Long>> verticesWithSumOfOutNeighborValues = graph.groupReduceOnNeighbors(new SumAllNeighborsAddFive(), EdgeDirection.ALL);
List<Tuple2<Long, Long>> result = verticesWithSumOfOutNeighborValues.collect();
expectedResult = "1,11\n" + "1,16\n" + "2,6\n" + "2,11\n" + "3,15\n" + "3,20\n" + "4,12\n" + "4,17\n" + "5,13\n" + "5,18";
compareResultAsTuples(result, expectedResult);
}
use of org.apache.flink.api.java.tuple.Tuple2 in project flink by apache.
the class ReduceOnNeighborMethodsITCase method testSumOfOutNeighborsNoValue.
@Test
public void testSumOfOutNeighborsNoValue() throws Exception {
/*
* Get the sum of out-neighbor values
* for each vertex
*/
final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
Graph<Long, Long, Long> graph = Graph.fromDataSet(TestGraphUtils.getLongLongVertexData(env), TestGraphUtils.getLongLongEdgeData(env), env);
DataSet<Tuple2<Long, Long>> verticesWithSumOfOutNeighborValues = graph.reduceOnNeighbors(new SumNeighbors(), EdgeDirection.OUT);
List<Tuple2<Long, Long>> result = verticesWithSumOfOutNeighborValues.collect();
expectedResult = "1,5\n" + "2,3\n" + "3,9\n" + "4,5\n" + "5,1\n";
compareResultAsTuples(result, expectedResult);
}
use of org.apache.flink.api.java.tuple.Tuple2 in project flink by apache.
the class ReduceOnNeighborMethodsITCase method testSumOfOAllNeighbors.
@Test
public void testSumOfOAllNeighbors() throws Exception {
/*
* Get the sum of all neighbor values
* including own vertex value
* for each vertex
*/
final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
Graph<Long, Long, Long> graph = Graph.fromDataSet(TestGraphUtils.getLongLongVertexData(env), TestGraphUtils.getLongLongEdgeData(env), env);
DataSet<Tuple2<Long, Long>> verticesWithSumOfOutNeighborValues = graph.groupReduceOnNeighbors(new SumAllNeighbors(), EdgeDirection.ALL);
List<Tuple2<Long, Long>> result = verticesWithSumOfOutNeighborValues.collect();
expectedResult = "1,11\n" + "2,6\n" + "3,15\n" + "4,12\n" + "5,13\n";
compareResultAsTuples(result, expectedResult);
}
use of org.apache.flink.api.java.tuple.Tuple2 in project flink by apache.
the class ReduceOnNeighborMethodsITCase method testSumOfInNeighbors.
@Test
public void testSumOfInNeighbors() throws Exception {
/*
* Get the sum of in-neighbor values
* times the edge weights for each vertex
*/
final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
Graph<Long, Long, Long> graph = Graph.fromDataSet(TestGraphUtils.getLongLongVertexData(env), TestGraphUtils.getLongLongEdgeData(env), env);
DataSet<Tuple2<Long, Long>> verticesWithSum = graph.groupReduceOnNeighbors(new SumInNeighbors(), EdgeDirection.IN);
List<Tuple2<Long, Long>> result = verticesWithSum.collect();
expectedResult = "1,255\n" + "2,12\n" + "3,59\n" + "4,102\n" + "5,285\n";
compareResultAsTuples(result, expectedResult);
}
Aggregations