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

The following examples show how to use org.apache.flink.graph.Graph#addVertices() . 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: GraphMutationsITCase.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
@Test
public void testAddVertices() throws Exception {
	/*
	 * Test addVertices() -- simple case
	 */

	final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();

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

	List<Vertex<Long, Long>> vertices = new ArrayList<>();
	// the first vertex has a duplicate ID from a vertex in the graph and
	// should not be added to the new graph
	vertices.add(new Vertex<>(5L, 0L));
	vertices.add(new Vertex<>(6L, 6L));
	vertices.add(new Vertex<>(7L, 7L));

	graph = graph.addVertices(vertices);

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

	expectedResult = "1,1\n" +
			"2,2\n" +
			"3,3\n" +
			"4,4\n" +
			"5,5\n" +
			"6,6\n" +
			"7,7\n";

	compareResultAsTuples(result, expectedResult);
}
 
Example 2
Source File: GraphMutationsITCase.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
@Test
public void testAddVerticesBothExisting() throws Exception {
	/*
	 * Test addVertices() -- add two existing vertices
	 */

	final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();

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

	List<Vertex<Long, Long>> vertices = new ArrayList<>();
	vertices.add(new Vertex<>(1L, 1L));
	vertices.add(new Vertex<>(3L, 3L));

	graph = graph.addVertices(vertices);

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

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

	compareResultAsTuples(result, expectedResult);
}
 
Example 3
Source File: GraphMutationsITCase.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
@Test
public void testAddVerticesOneExisting() throws Exception {
	/*
	 * Test addVertices() -- add an existing vertex
	 */

	final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();

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

	List<Vertex<Long, Long>> vertices = new ArrayList<>();
	vertices.add(new Vertex<>(1L, 1L));
	vertices.add(new Vertex<>(6L, 6L));

	graph = graph.addVertices(vertices);

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

	expectedResult = "1,1\n" +
			"2,2\n" +
			"3,3\n" +
			"4,4\n" +
			"5,5\n" +
			"6,6\n";

	compareResultAsTuples(result, expectedResult);
}
 
Example 4
Source File: GraphMutationsITCase.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test
public void testAddVertices() throws Exception {
	/*
	 * Test addVertices() -- simple case
	 */

	final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();

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

	List<Vertex<Long, Long>> vertices = new ArrayList<>();
	// the first vertex has a duplicate ID from a vertex in the graph and
	// should not be added to the new graph
	vertices.add(new Vertex<>(5L, 0L));
	vertices.add(new Vertex<>(6L, 6L));
	vertices.add(new Vertex<>(7L, 7L));

	graph = graph.addVertices(vertices);

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

	expectedResult = "1,1\n" +
			"2,2\n" +
			"3,3\n" +
			"4,4\n" +
			"5,5\n" +
			"6,6\n" +
			"7,7\n";

	compareResultAsTuples(result, expectedResult);
}
 
Example 5
Source File: GraphMutationsITCase.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test
public void testAddVerticesBothExisting() throws Exception {
	/*
	 * Test addVertices() -- add two existing vertices
	 */

	final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();

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

	List<Vertex<Long, Long>> vertices = new ArrayList<>();
	vertices.add(new Vertex<>(1L, 1L));
	vertices.add(new Vertex<>(3L, 3L));

	graph = graph.addVertices(vertices);

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

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

	compareResultAsTuples(result, expectedResult);
}
 
Example 6
Source File: GraphMutationsITCase.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test
public void testAddVerticesOneExisting() throws Exception {
	/*
	 * Test addVertices() -- add an existing vertex
	 */

	final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();

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

	List<Vertex<Long, Long>> vertices = new ArrayList<>();
	vertices.add(new Vertex<>(1L, 1L));
	vertices.add(new Vertex<>(6L, 6L));

	graph = graph.addVertices(vertices);

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

	expectedResult = "1,1\n" +
			"2,2\n" +
			"3,3\n" +
			"4,4\n" +
			"5,5\n" +
			"6,6\n";

	compareResultAsTuples(result, expectedResult);
}
 
Example 7
Source File: GraphMutationsITCase.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test
public void testAddVertices() throws Exception {
	/*
	 * Test addVertices() -- simple case
	 */

	final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();

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

	List<Vertex<Long, Long>> vertices = new ArrayList<>();
	// the first vertex has a duplicate ID from a vertex in the graph and
	// should not be added to the new graph
	vertices.add(new Vertex<>(5L, 0L));
	vertices.add(new Vertex<>(6L, 6L));
	vertices.add(new Vertex<>(7L, 7L));

	graph = graph.addVertices(vertices);

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

	expectedResult = "1,1\n" +
			"2,2\n" +
			"3,3\n" +
			"4,4\n" +
			"5,5\n" +
			"6,6\n" +
			"7,7\n";

	compareResultAsTuples(result, expectedResult);
}
 
Example 8
Source File: GraphMutationsITCase.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test
public void testAddVerticesBothExisting() throws Exception {
	/*
	 * Test addVertices() -- add two existing vertices
	 */

	final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();

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

	List<Vertex<Long, Long>> vertices = new ArrayList<>();
	vertices.add(new Vertex<>(1L, 1L));
	vertices.add(new Vertex<>(3L, 3L));

	graph = graph.addVertices(vertices);

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

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

	compareResultAsTuples(result, expectedResult);
}
 
Example 9
Source File: GraphMutationsITCase.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test
public void testAddVerticesOneExisting() throws Exception {
	/*
	 * Test addVertices() -- add an existing vertex
	 */

	final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();

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

	List<Vertex<Long, Long>> vertices = new ArrayList<>();
	vertices.add(new Vertex<>(1L, 1L));
	vertices.add(new Vertex<>(6L, 6L));

	graph = graph.addVertices(vertices);

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

	expectedResult = "1,1\n" +
			"2,2\n" +
			"3,3\n" +
			"4,4\n" +
			"5,5\n" +
			"6,6\n";

	compareResultAsTuples(result, expectedResult);
}