org.apache.flink.graph.EdgeDirection Java Examples
The following examples show how to use
org.apache.flink.graph.EdgeDirection.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ReduceOnNeighborMethodsITCase.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
@Test public void testSumOfInNeighborsNoValue() 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 SumInNeighborsNoValue(), 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); }
Example #2
Source File: ReduceOnNeighborMethodsITCase.java From flink with Apache License 2.0 | 6 votes |
@Test public void testSumOfInNeighborsIdGreaterThanThree() throws Exception { /* * Get the sum of in-neighbor values * times the edge weights 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>> verticesWithSum = graph.groupReduceOnNeighbors(new SumInNeighborsIdGreaterThanThree(), EdgeDirection.IN); List<Tuple2<Long, Long>> result = verticesWithSum.collect(); expectedResult = "4,102\n" + "5,285\n"; compareResultAsTuples(result, expectedResult); }
Example #3
Source File: ReduceOnEdgesWithExceptionITCase.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
/** * Test groupReduceOnEdges() with an edge having a srcId that does not exist in the vertex DataSet. */ @Test public void testGroupReduceOnEdgesInvalidEdgeSrcId() throws Exception { final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); env.setParallelism(PARALLELISM); env.getConfig().disableSysoutLogging(); Graph<Long, Long, Long> graph = Graph.fromDataSet(TestGraphUtils.getLongLongVertexData(env), TestGraphUtils.getLongLongEdgeInvalidSrcData(env), env); try { DataSet<Tuple2<Long, Long>> verticesWithAllNeighbors = graph.groupReduceOnEdges(new SelectNeighborsValueGreaterThanFour(), EdgeDirection.ALL); verticesWithAllNeighbors.output(new DiscardingOutputFormat<>()); env.execute(); fail("Expected an exception."); } catch (Exception e) { // We expect the job to fail with an exception } }
Example #4
Source File: ReduceOnEdgesMethodsITCase.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
@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); }
Example #5
Source File: ReduceOnEdgesMethodsITCase.java From flink with Apache License 2.0 | 6 votes |
@Test public void testAllInNeighbors() throws Exception { /* * Get the all the in-neighbors 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>> verticesWithAllInNeighbors = graph.groupReduceOnEdges(new SelectInNeighbors(), EdgeDirection.IN); List<Tuple2<Long, Long>> result = verticesWithAllInNeighbors.collect(); expectedResult = "1,5\n" + "2,1\n" + "3,1\n" + "3,2\n" + "4,3\n" + "5,3\n" + "5,4"; compareResultAsTuples(result, expectedResult); }
Example #6
Source File: ReduceOnEdgesMethodsITCase.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
@Test public void testAllNeighborsWithValueGreaterThanFour() throws Exception { /* * Get the all the neighbors for each vertex that have a value greater than four. */ 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 SelectNeighborsValueGreaterThanFour(), EdgeDirection.ALL); List<Tuple2<Long, Long>> result = verticesWithAllNeighbors.collect(); expectedResult = "5,1\n" + "5,3\n" + "5,4"; compareResultAsTuples(result, expectedResult); }
Example #7
Source File: ReduceOnEdgesMethodsITCase.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
@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); }
Example #8
Source File: ReduceOnEdgesMethodsITCase.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
@Test public void testLowestWeightInNeighborNoValue() throws Exception { /* * Get the lowest-weight out of all the in-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.IN); List<Tuple2<Long, Long>> result = verticesWithLowestOutNeighbor.collect(); expectedResult = "1,51\n" + "2,12\n" + "3,13\n" + "4,34\n" + "5,35\n"; compareResultAsTuples(result, expectedResult); }
Example #9
Source File: ReduceOnEdgesMethodsITCase.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
@Test public void testMaxWeightAllNeighbors() 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.reduceOnEdges(new SelectMaxWeightNeighborNoValue(), 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); }
Example #10
Source File: ReduceOnNeighborMethodsITCase.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
@Test public void testSumOfOutNeighbors() 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.groupReduceOnNeighbors(new SumOutNeighbors(), 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); }
Example #11
Source File: ReduceOnEdgesMethodsITCase.java From flink with Apache License 2.0 | 6 votes |
@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); }
Example #12
Source File: ReduceOnNeighborMethodsITCase.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
@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); }
Example #13
Source File: ReduceOnEdgesMethodsITCase.java From flink with Apache License 2.0 | 6 votes |
@Test public void testMaxWeightAllNeighbors() 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.reduceOnEdges(new SelectMaxWeightNeighborNoValue(), 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); }
Example #14
Source File: ReduceOnEdgesMethodsITCase.java From flink with Apache License 2.0 | 6 votes |
@Test public void testAllNeighborsWithValueGreaterThanFour() throws Exception { /* * Get the all the neighbors for each vertex that have a value greater than four. */ 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 SelectNeighborsValueGreaterThanFour(), EdgeDirection.ALL); List<Tuple2<Long, Long>> result = verticesWithAllNeighbors.collect(); expectedResult = "5,1\n" + "5,3\n" + "5,4"; compareResultAsTuples(result, expectedResult); }
Example #15
Source File: ReduceOnNeighborMethodsITCase.java From flink with Apache License 2.0 | 6 votes |
@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); }
Example #16
Source File: ReduceOnNeighborMethodsITCase.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
@Test public void testSumOfInNeighborsIdGreaterThanThree() throws Exception { /* * Get the sum of in-neighbor values * times the edge weights 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>> verticesWithSum = graph.groupReduceOnNeighbors(new SumInNeighborsIdGreaterThanThree(), EdgeDirection.IN); List<Tuple2<Long, Long>> result = verticesWithSum.collect(); expectedResult = "4,102\n" + "5,285\n"; compareResultAsTuples(result, expectedResult); }
Example #17
Source File: ReduceOnNeighborMethodsITCase.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
@Test public void testSumOfOutNeighborsNoValueMultipliedByTwoIdGreaterThanTwo() throws Exception { /* * Get the sum of out-neighbor values * for each vertex with id greater than two as well as the same sum multiplied by two. */ 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 SumOutNeighborsNoValueMultipliedByTwoIdGreaterThanTwo(), EdgeDirection.OUT); List<Tuple2<Long, Long>> result = verticesWithSumOfOutNeighborValues.collect(); expectedResult = "3,9\n" + "3,18\n" + "4,5\n" + "4,10\n" + "5,1\n" + "5,2"; compareResultAsTuples(result, expectedResult); }
Example #18
Source File: ReduceOnEdgesMethodsITCase.java From flink with Apache License 2.0 | 6 votes |
@Test public void testAllInNeighborsNoValue() throws Exception { /* * Get the all the in-neighbors for each vertex except for the vertex with id 5. */ 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 SelectInNeighborsExceptFive(), EdgeDirection.IN); List<Tuple2<Long, Long>> result = verticesWithAllInNeighbors.collect(); expectedResult = "1,5\n" + "2,1\n" + "3,1\n" + "3,2\n" + "4,3"; compareResultAsTuples(result, expectedResult); }
Example #19
Source File: ReduceOnNeighborMethodsITCase.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
@Test public void testSumOfAllNeighborsNoValueMultipliedByTwoIdGreaterThanTwo() throws Exception { /* * Get the sum of all neighbor values * for each vertex with id greater than two as well as the same sum multiplied by two. */ final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); Graph<Long, Long, Long> graph = Graph.fromDataSet(TestGraphUtils.getLongLongVertexData(env), TestGraphUtils.getLongLongEdgeData(env), env); DataSet<Tuple2<Long, Long>> verticesWithSumOfAllNeighborValues = graph.groupReduceOnNeighbors(new SumAllNeighborsNoValueMultipliedByTwoIdGreaterThanTwo(), EdgeDirection.ALL); List<Tuple2<Long, Long>> result = verticesWithSumOfAllNeighborValues.collect(); expectedResult = "3,12\n" + "3,24\n" + "4,8\n" + "4,16\n" + "5,8\n" + "5,16"; compareResultAsTuples(result, expectedResult); }
Example #20
Source File: ReduceOnEdgesMethodsITCase.java From flink with Apache License 2.0 | 6 votes |
@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); }
Example #21
Source File: ReduceOnNeighborMethodsITCase.java From flink with Apache License 2.0 | 6 votes |
@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); }
Example #22
Source File: ReduceOnEdgesMethodsITCase.java From flink with Apache License 2.0 | 6 votes |
@Test public void testAllOutNeighborsWithValueGreaterThanTwo() throws Exception { /* * Get the all the out-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>> verticesWithAllOutNeighbors = graph.groupReduceOnEdges(new SelectOutNeighborsValueGreaterThanTwo(), EdgeDirection.OUT); List<Tuple2<Long, Long>> result = verticesWithAllOutNeighbors.collect(); expectedResult = "3,4\n" + "3,5\n" + "4,5\n" + "5,1"; compareResultAsTuples(result, expectedResult); }
Example #23
Source File: ReduceOnNeighborsWithExceptionITCase.java From flink with Apache License 2.0 | 6 votes |
/** * Test groupReduceOnNeighbors() -NeighborsFunctionWithVertexValue- * with an edge having a srcId that does not exist in the vertex DataSet. */ @Test public void testGroupReduceOnNeighborsWithVVInvalidEdgeSrcId() throws Exception { final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); env.setParallelism(PARALLELISM); env.getConfig().disableSysoutLogging(); Graph<Long, Long, Long> graph = Graph.fromDataSet(TestGraphUtils.getLongLongVertexData(env), TestGraphUtils.getLongLongEdgeInvalidSrcData(env), env); try { DataSet<Tuple2<Long, Long>> verticesWithSumOfOutNeighborValues = graph.groupReduceOnNeighbors(new SumAllNeighbors(), EdgeDirection.ALL); verticesWithSumOfOutNeighborValues.output(new DiscardingOutputFormat<>()); env.execute(); fail("Expected an exception."); } catch (Exception e) { // We expect the job to fail with an exception } }
Example #24
Source File: ReduceOnNeighborsWithExceptionITCase.java From flink with Apache License 2.0 | 6 votes |
/** * Test groupReduceOnNeighbors() -NeighborsFunctionWithVertexValue- * with an edge having a trgId that does not exist in the vertex DataSet. */ @Test public void testGroupReduceOnNeighborsWithVVInvalidEdgeTrgId() throws Exception { final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); env.setParallelism(PARALLELISM); env.getConfig().disableSysoutLogging(); Graph<Long, Long, Long> graph = Graph.fromDataSet(TestGraphUtils.getLongLongVertexData(env), TestGraphUtils.getLongLongEdgeInvalidTrgData(env), env); try { DataSet<Tuple2<Long, Long>> verticesWithSumOfOutNeighborValues = graph.groupReduceOnNeighbors(new SumAllNeighbors(), EdgeDirection.ALL); verticesWithSumOfOutNeighborValues.output(new DiscardingOutputFormat<>()); env.execute(); fail("Expected an exception."); } catch (Exception e) { // We expect the job to fail with an exception } }
Example #25
Source File: ReduceOnNeighborsWithExceptionITCase.java From flink with Apache License 2.0 | 6 votes |
/** * Test groupReduceOnNeighbors() -NeighborsFunction- * with an edge having a srcId that does not exist in the vertex DataSet. */ @Test public void testGroupReduceOnNeighborsInvalidEdgeSrcId() throws Exception { final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); env.setParallelism(PARALLELISM); env.getConfig().disableSysoutLogging(); Graph<Long, Long, Long> graph = Graph.fromDataSet(TestGraphUtils.getLongLongVertexData(env), TestGraphUtils.getLongLongEdgeInvalidTrgData(env), env); try { DataSet<Tuple2<Long, Long>> verticesWithSumOfAllNeighborValues = graph.reduceOnNeighbors(new SumNeighbors(), EdgeDirection.ALL); verticesWithSumOfAllNeighborValues.output(new DiscardingOutputFormat<>()); env.execute(); } catch (Exception e) { // We expect the job to fail with an exception } }
Example #26
Source File: ReduceOnEdgesMethodsITCase.java From flink with Apache License 2.0 | 6 votes |
@Test public void testAllOutNeighborsNoValue() throws Exception { /* * Get the all the out-neighbors for each vertex except for the vertex with id 5. */ final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); Graph<Long, Long, Long> graph = Graph.fromDataSet(TestGraphUtils.getLongLongVertexData(env), TestGraphUtils.getLongLongEdgeData(env), env); DataSet<Tuple2<Long, Long>> verticesWithAllOutNeighbors = graph.groupReduceOnEdges(new SelectOutNeighborsExcludeFive(), EdgeDirection.OUT); List<Tuple2<Long, Long>> result = verticesWithAllOutNeighbors.collect(); expectedResult = "1,2\n" + "1,3\n" + "2,3\n" + "3,4\n" + "3,5\n" + "4,5"; compareResultAsTuples(result, expectedResult); }
Example #27
Source File: ReduceOnNeighborMethodsITCase.java From flink with Apache License 2.0 | 6 votes |
@Test public void testSumOfOutNeighborsNoValueMultipliedByTwoIdGreaterThanTwo() throws Exception { /* * Get the sum of out-neighbor values * for each vertex with id greater than two as well as the same sum multiplied by two. */ 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 SumOutNeighborsNoValueMultipliedByTwoIdGreaterThanTwo(), EdgeDirection.OUT); List<Tuple2<Long, Long>> result = verticesWithSumOfOutNeighborValues.collect(); expectedResult = "3,9\n" + "3,18\n" + "4,5\n" + "4,10\n" + "5,1\n" + "5,2"; compareResultAsTuples(result, expectedResult); }
Example #28
Source File: ReduceOnEdgesWithExceptionITCase.java From flink with Apache License 2.0 | 6 votes |
/** * Test groupReduceOnEdges() with an edge having a srcId that does not exist in the vertex DataSet. */ @Test public void testGroupReduceOnEdgesInvalidEdgeSrcId() throws Exception { final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); env.setParallelism(PARALLELISM); env.getConfig().disableSysoutLogging(); Graph<Long, Long, Long> graph = Graph.fromDataSet(TestGraphUtils.getLongLongVertexData(env), TestGraphUtils.getLongLongEdgeInvalidSrcData(env), env); try { DataSet<Tuple2<Long, Long>> verticesWithAllNeighbors = graph.groupReduceOnEdges(new SelectNeighborsValueGreaterThanFour(), EdgeDirection.ALL); verticesWithAllNeighbors.output(new DiscardingOutputFormat<>()); env.execute(); fail("Expected an exception."); } catch (Exception e) { // We expect the job to fail with an exception } }
Example #29
Source File: ReduceOnEdgesMethodsITCase.java From flink with Apache License 2.0 | 6 votes |
@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); }
Example #30
Source File: ReduceOnEdgesMethodsITCase.java From flink with Apache License 2.0 | 6 votes |
@Test public void testLowestWeightInNeighbor() throws Exception { /* * Get the lowest-weight in-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 SelectMinWeightInNeighbor(), EdgeDirection.IN); List<Tuple2<Long, Long>> result = verticesWithLowestOutNeighbor.collect(); expectedResult = "1,5\n" + "2,1\n" + "3,1\n" + "4,3\n" + "5,3\n"; compareResultAsTuples(result, expectedResult); }