use of org.apache.flink.api.java.tuple.Tuple2 in project flink by apache.
the class ReduceOnEdgesMethodsITCase method testLowestWeightOutNeighbor.
@Test
public void testLowestWeightOutNeighbor() throws Exception {
/*
* Get the lowest-weight out-neighbor
* 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>> verticesWithLowestOutNeighbor = graph.groupReduceOnEdges(new SelectMinWeightNeighbor(), EdgeDirection.OUT);
List<Tuple2<Long, Long>> result = verticesWithLowestOutNeighbor.collect();
expectedResult = "1,2\n" + "2,3\n" + "3,4\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 ReduceOnEdgesMethodsITCase method testAllInNeighborsWithValueGreaterThanTwo.
@Test
public void testAllInNeighborsWithValueGreaterThanTwo() throws Exception {
/*
* Get the all the in-neighbors for each vertex that have a value greater than two.
*/
final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
Graph<Long, Long, Long> graph = Graph.fromDataSet(TestGraphUtils.getLongLongVertexData(env), TestGraphUtils.getLongLongEdgeData(env), env);
DataSet<Tuple2<Long, Long>> verticesWithAllInNeighbors = graph.groupReduceOnEdges(new SelectInNeighborsValueGreaterThanTwo(), EdgeDirection.IN);
List<Tuple2<Long, Long>> result = verticesWithAllInNeighbors.collect();
expectedResult = "3,1\n" + "3,2\n" + "4,3\n" + "5,3\n" + "5,4";
compareResultAsTuples(result, expectedResult);
}
use of org.apache.flink.api.java.tuple.Tuple2 in project flink by apache.
the class ReduceOnEdgesMethodsITCase method testMaxWeightEdge.
@Test
public void testMaxWeightEdge() throws Exception {
/*
* Get the maximum weight among all edges
* of a vertex
*/
final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
Graph<Long, Long, Long> graph = Graph.fromDataSet(TestGraphUtils.getLongLongVertexData(env), TestGraphUtils.getLongLongEdgeData(env), env);
DataSet<Tuple2<Long, Long>> verticesWithMaxEdgeWeight = graph.groupReduceOnEdges(new SelectMaxWeightNeighbor(), EdgeDirection.ALL);
List<Tuple2<Long, Long>> result = verticesWithMaxEdgeWeight.collect();
expectedResult = "1,51\n" + "2,23\n" + "3,35\n" + "4,45\n" + "5,51\n";
compareResultAsTuples(result, expectedResult);
}
use of org.apache.flink.api.java.tuple.Tuple2 in project flink by apache.
the class ReduceOnEdgesMethodsITCase method testLowestWeightOutNeighborNoValue.
@Test
public void testLowestWeightOutNeighborNoValue() throws Exception {
/*
* Get the lowest-weight out of all the out-neighbors
* of 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>> verticesWithLowestOutNeighbor = graph.reduceOnEdges(new SelectMinWeightNeighborNoValue(), EdgeDirection.OUT);
List<Tuple2<Long, Long>> result = verticesWithLowestOutNeighbor.collect();
expectedResult = "1,12\n" + "2,23\n" + "3,34\n" + "4,45\n" + "5,51\n";
compareResultAsTuples(result, expectedResult);
}
use of org.apache.flink.api.java.tuple.Tuple2 in project flink by apache.
the class ReduceOnEdgesMethodsITCase method testAllNeighborsNoValue.
@Test
public void testAllNeighborsNoValue() throws Exception {
/*
* Get the all the neighbors for each vertex except for vertices with id 5 and 2.
*/
final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
Graph<Long, Long, Long> graph = Graph.fromDataSet(TestGraphUtils.getLongLongVertexData(env), TestGraphUtils.getLongLongEdgeData(env), env);
DataSet<Tuple2<Long, Long>> verticesWithAllNeighbors = graph.groupReduceOnEdges(new SelectNeighborsExceptFiveAndTwo(), EdgeDirection.ALL);
List<Tuple2<Long, Long>> result = verticesWithAllNeighbors.collect();
expectedResult = "1,2\n" + "1,3\n" + "1,5\n" + "3,1\n" + "3,2\n" + "3,4\n" + "3,5\n" + "4,3\n" + "4,5";
compareResultAsTuples(result, expectedResult);
}
Aggregations