use of org.apache.flink.graph.Edge in project flink by apache.
the class JoinWithEdgesITCase method testWithEdgesInputDataset.
@Test
public void testWithEdgesInputDataset() throws Exception {
/*
* Test joinWithEdges with the input DataSet parameter identical
* to the edge DataSet
*/
final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
Graph<Long, Long, Long> graph = Graph.fromDataSet(TestGraphUtils.getLongLongVertexData(env), TestGraphUtils.getLongLongEdgeData(env), env);
Graph<Long, Long, Long> res = graph.joinWithEdges(graph.getEdges().map(new EdgeToTuple3Map<Long, Long>()), new AddValuesMapper());
DataSet<Edge<Long, Long>> data = res.getEdges();
List<Edge<Long, Long>> result = data.collect();
expectedResult = "1,2,24\n" + "1,3,26\n" + "2,3,46\n" + "3,4,68\n" + "3,5,70\n" + "4,5,90\n" + "5,1,102\n";
compareResultAsTuples(result, expectedResult);
}
use of org.apache.flink.graph.Edge in project flink by apache.
the class JoinWithEdgesITCase method testWithNoCommonKeys.
@Test
public void testWithNoCommonKeys() throws Exception {
/*
* Test joinWithEdges with the input DataSet containing different keys than the edge DataSet
* - the iterator becomes empty.
*/
final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
Graph<Long, Long, Long> graph = Graph.fromDataSet(TestGraphUtils.getLongLongVertexData(env), TestGraphUtils.getLongLongEdgeData(env), env);
Graph<Long, Long, Long> res = graph.joinWithEdges(TestGraphUtils.getLongLongLongTuple3Data(env), new DoubleValueMapper());
DataSet<Edge<Long, Long>> data = res.getEdges();
List<Edge<Long, Long>> result = data.collect();
expectedResult = "1,2,24\n" + "1,3,26\n" + "2,3,46\n" + "3,4,68\n" + "3,5,35\n" + "4,5,45\n" + "5,1,51\n";
compareResultAsTuples(result, expectedResult);
}
use of org.apache.flink.graph.Edge in project flink by apache.
the class JoinWithEdgesITCase method testOnSourceWithCustom.
@Test
public void testOnSourceWithCustom() throws Exception {
/*
* Test joinWithEdgesOnSource with a DataSet containing custom parametrised type input values
*/
final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
Graph<Long, Long, Long> graph = Graph.fromDataSet(TestGraphUtils.getLongLongVertexData(env), TestGraphUtils.getLongLongEdgeData(env), env);
Graph<Long, Long, Long> res = graph.joinWithEdgesOnSource(TestGraphUtils.getLongCustomTuple2SourceData(env), new CustomValueMapper());
DataSet<Edge<Long, Long>> data = res.getEdges();
List<Edge<Long, Long>> result = data.collect();
expectedResult = "1,2,10\n" + "1,3,10\n" + "2,3,30\n" + "3,4,40\n" + "3,5,40\n" + "4,5,45\n" + "5,1,51\n";
compareResultAsTuples(result, expectedResult);
}
use of org.apache.flink.graph.Edge in project flink by apache.
the class GraphMutationsITCase method testRemoveInvalidEdge.
@Test
public void testRemoveInvalidEdge() throws Exception {
/*
* Test removeEdge() -- invalid edge
*/
final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
Graph<Long, Long, Long> graph = Graph.fromDataSet(TestGraphUtils.getLongLongVertexData(env), TestGraphUtils.getLongLongEdgeData(env), env);
graph = graph.removeEdge(new Edge<>(6L, 1L, 61L));
DataSet<Edge<Long, Long>> data = graph.getEdges();
List<Edge<Long, Long>> result = data.collect();
expectedResult = "1,2,12\n" + "1,3,13\n" + "2,3,23\n" + "3,4,34\n" + "3,5,35\n" + "4,5,45\n" + "5,1,51\n";
compareResultAsTuples(result, expectedResult);
}
use of org.apache.flink.graph.Edge in project flink by apache.
the class GraphMutationsITCase method testAddEdgesInvalidVertices.
@Test
public void testAddEdgesInvalidVertices() throws Exception {
/*
* Test addEdges() -- the source and target vertices do not exist in the graph
*/
final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
Graph<Long, Long, Long> graph = Graph.fromDataSet(TestGraphUtils.getLongLongVertexData(env), TestGraphUtils.getLongLongEdgeData(env), env);
List<Edge<Long, Long>> edgesToBeAdded = new ArrayList<>();
edgesToBeAdded.add(new Edge<>(6L, 1L, 61L));
edgesToBeAdded.add(new Edge<>(7L, 1L, 71L));
graph = graph.addEdges(edgesToBeAdded);
DataSet<Edge<Long, Long>> data = graph.getEdges();
List<Edge<Long, Long>> result = data.collect();
expectedResult = "1,2,12\n" + "1,3,13\n" + "2,3,23\n" + "3,4,34\n" + "3,5,35\n" + "4,5,45\n" + "5,1,51\n";
compareResultAsTuples(result, expectedResult);
}
Aggregations