use of org.apache.flink.graph.Edge in project flink by apache.
the class GraphMutationsITCase method testAddEdge.
@Test
public void testAddEdge() throws Exception {
/*
* Test addEdge() -- simple case
*/
final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
Graph<Long, Long, Long> graph = Graph.fromDataSet(TestGraphUtils.getLongLongVertexData(env), TestGraphUtils.getLongLongEdgeData(env), env);
graph = graph.addEdge(new Vertex<>(6L, 6L), new Vertex<>(1L, 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" + "6,1,61\n";
compareResultAsTuples(result, expectedResult);
}
use of org.apache.flink.graph.Edge in project flink by apache.
the class JoinWithEdgesITCase method testOnSourceWithNoCommonKeys.
@Test
public void testOnSourceWithNoCommonKeys() throws Exception {
/*
* Test joinWithEdgesOnSource 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.joinWithEdgesOnSource(TestGraphUtils.getLongLongTuple2SourceData(env), new DoubleValueMapper());
DataSet<Edge<Long, Long>> data = res.getEdges();
List<Edge<Long, Long>> result = data.collect();
expectedResult = "1,2,20\n" + "1,3,20\n" + "2,3,60\n" + "3,4,80\n" + "3,5,80\n" + "4,5,120\n" + "5,1,51\n";
compareResultAsTuples(result, expectedResult);
}
use of org.apache.flink.graph.Edge in project flink by apache.
the class JoinWithEdgesITCase method testOnTargetWithDifferentType.
@Test
public void testOnTargetWithDifferentType() throws Exception {
/*
* Test joinWithEdgesOnTarget with the input DataSet passed as a parameter containing
* less elements than the edge DataSet and of a different type(Boolean)
*/
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.joinWithEdgesOnTarget(graph.getEdges().first(3).map(new ProjectTargetWithTrueMapper()), new DoubleIfTrueMapper());
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,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 JoinWithEdgesITCase method testWithLessElementsDifferentType.
@Test
public void testWithLessElementsDifferentType() throws Exception {
/*
* Test joinWithEdges with the input DataSet passed as a parameter containing
* less elements than the edge DataSet and of a different type(Boolean)
*/
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().first(3).map(new BooleanEdgeValueMapper()), new DoubleIfTrueMapper());
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,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 JoinWithEdgesITCase method testOnSourceWithDifferentType.
@Test
public void testOnSourceWithDifferentType() throws Exception {
/*
* Test joinWithEdgesOnSource with the input DataSet passed as a parameter containing
* less elements than the edge DataSet and of a different type(Boolean)
*/
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(graph.getEdges().first(3).map(new ProjectSourceWithTrueMapper()), new DoubleIfTrueMapper());
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,34\n" + "3,5,35\n" + "4,5,45\n" + "5,1,51\n";
compareResultAsTuples(result, expectedResult);
}
Aggregations