Java Code Examples for org.apache.flink.graph.Graph#difference()

The following examples show how to use org.apache.flink.graph.Graph#difference() . 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: GraphOperationsITCase.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
@Test
public void testDifference() throws Exception {
	/*Test  difference() method  by checking    the output  for getEdges()   on  the resultant   graph
	 */
	final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();

	Graph<Long, Long, Long> graph = Graph.fromDataSet(TestGraphUtils.getLongLongVertexData(env),
		TestGraphUtils.getLongLongEdgeData(env), env);

	Graph<Long, Long, Long> graph2 = Graph.fromDataSet(TestGraphUtils.getLongLongVertexDataDifference(env),
		TestGraphUtils.getLongLongEdgeDataDifference(env), env);

	graph = graph.difference(graph2);

	List<Edge<Long, Long>> result = graph.getEdges().collect();

	expectedResult = "4,5,45\n";
	compareResultAsTuples(result, expectedResult);
}
 
Example 2
Source File: GraphOperationsITCase.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
@Test
public void testDifferenceVertices() throws Exception {
	/*Test  difference() method  by checking    the output  for getVertices()   on  the resultant   graph
	 */
	final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();

	Graph<Long, Long, Long> graph = Graph.fromDataSet(TestGraphUtils.getLongLongVertexData(env),
		TestGraphUtils.getLongLongEdgeData(env), env);

	Graph<Long, Long, Long> graph2 = Graph.fromDataSet(TestGraphUtils.getLongLongVertexDataDifference(env),
		TestGraphUtils.getLongLongEdgeDataDifference(env), env);

	graph = graph.difference(graph2);

	List<Vertex<Long, Long>> result = graph.getVertices().collect();

	expectedResult = "2,2\n" +
		"4,4\n" +
		"5,5\n";

	compareResultAsTuples(result, expectedResult);
}
 
Example 3
Source File: GraphOperationsITCase.java    From flink with Apache License 2.0 6 votes vote down vote up
@Test
public void testDifference() throws Exception {
	/*Test  difference() method  by checking    the output  for getEdges()   on  the resultant   graph
	 */
	final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();

	Graph<Long, Long, Long> graph = Graph.fromDataSet(TestGraphUtils.getLongLongVertexData(env),
		TestGraphUtils.getLongLongEdgeData(env), env);

	Graph<Long, Long, Long> graph2 = Graph.fromDataSet(TestGraphUtils.getLongLongVertexDataDifference(env),
		TestGraphUtils.getLongLongEdgeDataDifference(env), env);

	graph = graph.difference(graph2);

	List<Edge<Long, Long>> result = graph.getEdges().collect();

	expectedResult = "4,5,45\n";
	compareResultAsTuples(result, expectedResult);
}
 
Example 4
Source File: GraphOperationsITCase.java    From flink with Apache License 2.0 6 votes vote down vote up
@Test
public void testDifferenceVertices() throws Exception {
	/*Test  difference() method  by checking    the output  for getVertices()   on  the resultant   graph
	 */
	final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();

	Graph<Long, Long, Long> graph = Graph.fromDataSet(TestGraphUtils.getLongLongVertexData(env),
		TestGraphUtils.getLongLongEdgeData(env), env);

	Graph<Long, Long, Long> graph2 = Graph.fromDataSet(TestGraphUtils.getLongLongVertexDataDifference(env),
		TestGraphUtils.getLongLongEdgeDataDifference(env), env);

	graph = graph.difference(graph2);

	List<Vertex<Long, Long>> result = graph.getVertices().collect();

	expectedResult = "2,2\n" +
		"4,4\n" +
		"5,5\n";

	compareResultAsTuples(result, expectedResult);
}
 
Example 5
Source File: GraphOperationsITCase.java    From flink with Apache License 2.0 6 votes vote down vote up
@Test
public void testDifference() throws Exception {
	/*Test  difference() method  by checking    the output  for getEdges()   on  the resultant   graph
	 */
	final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();

	Graph<Long, Long, Long> graph = Graph.fromDataSet(TestGraphUtils.getLongLongVertexData(env),
		TestGraphUtils.getLongLongEdgeData(env), env);

	Graph<Long, Long, Long> graph2 = Graph.fromDataSet(TestGraphUtils.getLongLongVertexDataDifference(env),
		TestGraphUtils.getLongLongEdgeDataDifference(env), env);

	graph = graph.difference(graph2);

	List<Edge<Long, Long>> result = graph.getEdges().collect();

	expectedResult = "4,5,45\n";
	compareResultAsTuples(result, expectedResult);
}
 
Example 6
Source File: GraphOperationsITCase.java    From flink with Apache License 2.0 6 votes vote down vote up
@Test
public void testDifferenceVertices() throws Exception {
	/*Test  difference() method  by checking    the output  for getVertices()   on  the resultant   graph
	 */
	final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();

	Graph<Long, Long, Long> graph = Graph.fromDataSet(TestGraphUtils.getLongLongVertexData(env),
		TestGraphUtils.getLongLongEdgeData(env), env);

	Graph<Long, Long, Long> graph2 = Graph.fromDataSet(TestGraphUtils.getLongLongVertexDataDifference(env),
		TestGraphUtils.getLongLongEdgeDataDifference(env), env);

	graph = graph.difference(graph2);

	List<Vertex<Long, Long>> result = graph.getVertices().collect();

	expectedResult = "2,2\n" +
		"4,4\n" +
		"5,5\n";

	compareResultAsTuples(result, expectedResult);
}
 
Example 7
Source File: GraphOperationsITCase.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
@Test
public void testDifference2() throws Exception {
	/*
	 * Test difference() such that no common vertices are there
	 */
	final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();

	Graph<Long, Long, Long> graph = Graph.fromDataSet(TestGraphUtils.getLongLongVertexData(env),
		TestGraphUtils.getLongLongEdgeData(env), env);

	DataSet<Vertex<Long, Long>> vertex = env.fromElements(new Vertex<>(6L, 6L));

	Graph<Long, Long, Long> graph2 = Graph.fromDataSet(vertex, TestGraphUtils.getLongLongEdgeDataDifference2(env), env);

	graph = graph.difference(graph2);

	List<Edge<Long, Long>> result = graph.getEdges().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);
}
 
Example 8
Source File: GraphOperationsITCase.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test
public void testDifference2() throws Exception {
	/*
	 * Test difference() such that no common vertices are there
	 */
	final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();

	Graph<Long, Long, Long> graph = Graph.fromDataSet(TestGraphUtils.getLongLongVertexData(env),
		TestGraphUtils.getLongLongEdgeData(env), env);

	DataSet<Vertex<Long, Long>> vertex = env.fromElements(new Vertex<>(6L, 6L));

	Graph<Long, Long, Long> graph2 = Graph.fromDataSet(vertex, TestGraphUtils.getLongLongEdgeDataDifference2(env), env);

	graph = graph.difference(graph2);

	List<Edge<Long, Long>> result = graph.getEdges().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);
}
 
Example 9
Source File: GraphOperationsITCase.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test
public void testDifference2() throws Exception {
	/*
	 * Test difference() such that no common vertices are there
	 */
	final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();

	Graph<Long, Long, Long> graph = Graph.fromDataSet(TestGraphUtils.getLongLongVertexData(env),
		TestGraphUtils.getLongLongEdgeData(env), env);

	DataSet<Vertex<Long, Long>> vertex = env.fromElements(new Vertex<>(6L, 6L));

	Graph<Long, Long, Long> graph2 = Graph.fromDataSet(vertex, TestGraphUtils.getLongLongEdgeDataDifference2(env), env);

	graph = graph.difference(graph2);

	List<Edge<Long, Long>> result = graph.getEdges().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);
}