org.apache.flink.graph.library.Summarization.EdgeValue Java Examples

The following examples show how to use org.apache.flink.graph.library.Summarization.EdgeValue. 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: SummarizationITCase.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
@Test
public void testWithVertexAndEdgeStringValues() throws Exception {
	ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
	Graph<Long, String, String> input = Graph.fromDataSet(
			SummarizationData.getVertices(env),
			SummarizationData.getEdges(env),
			env);

	List<Vertex<Long, Summarization.VertexValue<String>>> summarizedVertices = new ArrayList<>();
	List<Edge<Long, EdgeValue<String>>> summarizedEdges = new ArrayList<>();

	Graph<Long, Summarization.VertexValue<String>, EdgeValue<String>> output =
			input.run(new Summarization<>());

	output.getVertices().output(new LocalCollectionOutputFormat<>(summarizedVertices));
	output.getEdges().output(new LocalCollectionOutputFormat<>(summarizedEdges));

	env.execute();

	validateVertices(SummarizationData.EXPECTED_VERTICES, summarizedVertices);
	validateEdges(SummarizationData.EXPECTED_EDGES_WITH_VALUES, summarizedEdges);
}
 
Example #2
Source File: SummarizationITCase.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
@Test
public void testWithVertexAndAbsentEdgeStringValues() throws Exception {
	ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
	Graph<Long, String, NullValue> input = Graph.fromDataSet(
			SummarizationData.getVertices(env),
			SummarizationData.getEdges(env),
			env)
		.run(new TranslateEdgeValues<>(new ToNullValue<>()));

	List<Vertex<Long, Summarization.VertexValue<String>>> summarizedVertices = new ArrayList<>();
	List<Edge<Long, EdgeValue<NullValue>>> summarizedEdges = new ArrayList<>();

	Graph<Long, Summarization.VertexValue<String>, EdgeValue<NullValue>> output =
			input.run(new Summarization<>());

	output.getVertices().output(new LocalCollectionOutputFormat<>(summarizedVertices));
	output.getEdges().output(new LocalCollectionOutputFormat<>(summarizedEdges));

	env.execute();

	validateVertices(SummarizationData.EXPECTED_VERTICES, summarizedVertices);
	validateEdges(SummarizationData.EXPECTED_EDGES_ABSENT_VALUES, summarizedEdges);
}
 
Example #3
Source File: SummarizationITCase.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
@Test
public void testWithVertexAndEdgeLongValues() throws Exception {
	ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();

	Graph<Long, Long, Long> input = Graph.fromDataSet(
			SummarizationData.getVertices(env),
			SummarizationData.getEdges(env),
			env)
		.run(new TranslateVertexValues<>(new StringToLong()))
		.run(new TranslateEdgeValues<>(new StringToLong()));

	List<Vertex<Long, Summarization.VertexValue<Long>>> summarizedVertices = new ArrayList<>();
	List<Edge<Long, EdgeValue<Long>>> summarizedEdges = new ArrayList<>();

	Graph<Long, Summarization.VertexValue<Long>, EdgeValue<Long>> output =
		input.run(new Summarization<>());

	output.getVertices().output(new LocalCollectionOutputFormat<>(summarizedVertices));
	output.getEdges().output(new LocalCollectionOutputFormat<>(summarizedEdges));

	env.execute();

	validateVertices(SummarizationData.EXPECTED_VERTICES, summarizedVertices);
	validateEdges(SummarizationData.EXPECTED_EDGES_WITH_VALUES, summarizedEdges);
}
 
Example #4
Source File: SummarizationITCase.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
private <EV extends Comparable<EV>> void validateEdges(String[] expectedEdges, List<Edge<Long, EdgeValue<EV>>> actualEdges) {
	Arrays.sort(expectedEdges);
	Collections.sort(actualEdges, new Comparator<Edge<Long, EdgeValue<EV>>> () {

		@Override
		public int compare(Edge<Long, EdgeValue<EV>> o1, Edge<Long, EdgeValue<EV>> o2) {
			int result = o1.getSource().compareTo(o2.getSource());
			if (result == 0) {
				result = o1.getTarget().compareTo(o2.getTarget());
			}
			if (result == 0) {
				result = o1.getValue().getEdgeGroupValue().compareTo(o2.getValue().getEdgeGroupValue());
			}
			return result;
		}
	});

	for (int i = 0; i < expectedEdges.length; i++) {
		validateEdge(expectedEdges[i], actualEdges.get(i));
	}
}
 
Example #5
Source File: SummarizationITCase.java    From flink with Apache License 2.0 6 votes vote down vote up
@Test
public void testWithVertexAndEdgeStringValues() throws Exception {
	ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
	Graph<Long, String, String> input = Graph.fromDataSet(
			SummarizationData.getVertices(env),
			SummarizationData.getEdges(env),
			env);

	List<Vertex<Long, Summarization.VertexValue<String>>> summarizedVertices = new ArrayList<>();
	List<Edge<Long, EdgeValue<String>>> summarizedEdges = new ArrayList<>();

	Graph<Long, Summarization.VertexValue<String>, EdgeValue<String>> output =
			input.run(new Summarization<>());

	output.getVertices().output(new LocalCollectionOutputFormat<>(summarizedVertices));
	output.getEdges().output(new LocalCollectionOutputFormat<>(summarizedEdges));

	env.execute();

	validateVertices(SummarizationData.EXPECTED_VERTICES, summarizedVertices);
	validateEdges(SummarizationData.EXPECTED_EDGES_WITH_VALUES, summarizedEdges);
}
 
Example #6
Source File: SummarizationITCase.java    From flink with Apache License 2.0 6 votes vote down vote up
@Test
public void testWithVertexAndAbsentEdgeStringValues() throws Exception {
	ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
	Graph<Long, String, NullValue> input = Graph.fromDataSet(
			SummarizationData.getVertices(env),
			SummarizationData.getEdges(env),
			env)
		.run(new TranslateEdgeValues<>(new ToNullValue<>()));

	List<Vertex<Long, Summarization.VertexValue<String>>> summarizedVertices = new ArrayList<>();
	List<Edge<Long, EdgeValue<NullValue>>> summarizedEdges = new ArrayList<>();

	Graph<Long, Summarization.VertexValue<String>, EdgeValue<NullValue>> output =
			input.run(new Summarization<>());

	output.getVertices().output(new LocalCollectionOutputFormat<>(summarizedVertices));
	output.getEdges().output(new LocalCollectionOutputFormat<>(summarizedEdges));

	env.execute();

	validateVertices(SummarizationData.EXPECTED_VERTICES, summarizedVertices);
	validateEdges(SummarizationData.EXPECTED_EDGES_ABSENT_VALUES, summarizedEdges);
}
 
Example #7
Source File: SummarizationITCase.java    From flink with Apache License 2.0 6 votes vote down vote up
@Test
public void testWithVertexAndEdgeLongValues() throws Exception {
	ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();

	Graph<Long, Long, Long> input = Graph.fromDataSet(
			SummarizationData.getVertices(env),
			SummarizationData.getEdges(env),
			env)
		.run(new TranslateVertexValues<>(new StringToLong()))
		.run(new TranslateEdgeValues<>(new StringToLong()));

	List<Vertex<Long, Summarization.VertexValue<Long>>> summarizedVertices = new ArrayList<>();
	List<Edge<Long, EdgeValue<Long>>> summarizedEdges = new ArrayList<>();

	Graph<Long, Summarization.VertexValue<Long>, EdgeValue<Long>> output =
		input.run(new Summarization<>());

	output.getVertices().output(new LocalCollectionOutputFormat<>(summarizedVertices));
	output.getEdges().output(new LocalCollectionOutputFormat<>(summarizedEdges));

	env.execute();

	validateVertices(SummarizationData.EXPECTED_VERTICES, summarizedVertices);
	validateEdges(SummarizationData.EXPECTED_EDGES_WITH_VALUES, summarizedEdges);
}
 
Example #8
Source File: SummarizationITCase.java    From flink with Apache License 2.0 6 votes vote down vote up
private <EV extends Comparable<EV>> void validateEdges(String[] expectedEdges, List<Edge<Long, EdgeValue<EV>>> actualEdges) {
	Arrays.sort(expectedEdges);
	Collections.sort(actualEdges, new Comparator<Edge<Long, EdgeValue<EV>>> () {

		@Override
		public int compare(Edge<Long, EdgeValue<EV>> o1, Edge<Long, EdgeValue<EV>> o2) {
			int result = o1.getSource().compareTo(o2.getSource());
			if (result == 0) {
				result = o1.getTarget().compareTo(o2.getTarget());
			}
			if (result == 0) {
				result = o1.getValue().getEdgeGroupValue().compareTo(o2.getValue().getEdgeGroupValue());
			}
			return result;
		}
	});

	for (int i = 0; i < expectedEdges.length; i++) {
		validateEdge(expectedEdges[i], actualEdges.get(i));
	}
}
 
Example #9
Source File: SummarizationITCase.java    From flink with Apache License 2.0 6 votes vote down vote up
@Test
public void testWithVertexAndEdgeStringValues() throws Exception {
	ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
	Graph<Long, String, String> input = Graph.fromDataSet(
			SummarizationData.getVertices(env),
			SummarizationData.getEdges(env),
			env);

	List<Vertex<Long, Summarization.VertexValue<String>>> summarizedVertices = new ArrayList<>();
	List<Edge<Long, EdgeValue<String>>> summarizedEdges = new ArrayList<>();

	Graph<Long, Summarization.VertexValue<String>, EdgeValue<String>> output =
			input.run(new Summarization<>());

	output.getVertices().output(new LocalCollectionOutputFormat<>(summarizedVertices));
	output.getEdges().output(new LocalCollectionOutputFormat<>(summarizedEdges));

	env.execute();

	validateVertices(SummarizationData.EXPECTED_VERTICES, summarizedVertices);
	validateEdges(SummarizationData.EXPECTED_EDGES_WITH_VALUES, summarizedEdges);
}
 
Example #10
Source File: SummarizationITCase.java    From flink with Apache License 2.0 6 votes vote down vote up
@Test
public void testWithVertexAndAbsentEdgeStringValues() throws Exception {
	ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
	Graph<Long, String, NullValue> input = Graph.fromDataSet(
			SummarizationData.getVertices(env),
			SummarizationData.getEdges(env),
			env)
		.run(new TranslateEdgeValues<>(new ToNullValue<>()));

	List<Vertex<Long, Summarization.VertexValue<String>>> summarizedVertices = new ArrayList<>();
	List<Edge<Long, EdgeValue<NullValue>>> summarizedEdges = new ArrayList<>();

	Graph<Long, Summarization.VertexValue<String>, EdgeValue<NullValue>> output =
			input.run(new Summarization<>());

	output.getVertices().output(new LocalCollectionOutputFormat<>(summarizedVertices));
	output.getEdges().output(new LocalCollectionOutputFormat<>(summarizedEdges));

	env.execute();

	validateVertices(SummarizationData.EXPECTED_VERTICES, summarizedVertices);
	validateEdges(SummarizationData.EXPECTED_EDGES_ABSENT_VALUES, summarizedEdges);
}
 
Example #11
Source File: SummarizationITCase.java    From flink with Apache License 2.0 6 votes vote down vote up
@Test
public void testWithVertexAndEdgeLongValues() throws Exception {
	ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();

	Graph<Long, Long, Long> input = Graph.fromDataSet(
			SummarizationData.getVertices(env),
			SummarizationData.getEdges(env),
			env)
		.run(new TranslateVertexValues<>(new StringToLong()))
		.run(new TranslateEdgeValues<>(new StringToLong()));

	List<Vertex<Long, Summarization.VertexValue<Long>>> summarizedVertices = new ArrayList<>();
	List<Edge<Long, EdgeValue<Long>>> summarizedEdges = new ArrayList<>();

	Graph<Long, Summarization.VertexValue<Long>, EdgeValue<Long>> output =
		input.run(new Summarization<>());

	output.getVertices().output(new LocalCollectionOutputFormat<>(summarizedVertices));
	output.getEdges().output(new LocalCollectionOutputFormat<>(summarizedEdges));

	env.execute();

	validateVertices(SummarizationData.EXPECTED_VERTICES, summarizedVertices);
	validateEdges(SummarizationData.EXPECTED_EDGES_WITH_VALUES, summarizedEdges);
}
 
Example #12
Source File: SummarizationITCase.java    From flink with Apache License 2.0 6 votes vote down vote up
private <EV extends Comparable<EV>> void validateEdges(String[] expectedEdges, List<Edge<Long, EdgeValue<EV>>> actualEdges) {
	Arrays.sort(expectedEdges);
	Collections.sort(actualEdges, new Comparator<Edge<Long, EdgeValue<EV>>> () {

		@Override
		public int compare(Edge<Long, EdgeValue<EV>> o1, Edge<Long, EdgeValue<EV>> o2) {
			int result = o1.getSource().compareTo(o2.getSource());
			if (result == 0) {
				result = o1.getTarget().compareTo(o2.getTarget());
			}
			if (result == 0) {
				result = o1.getValue().getEdgeGroupValue().compareTo(o2.getValue().getEdgeGroupValue());
			}
			return result;
		}
	});

	for (int i = 0; i < expectedEdges.length; i++) {
		validateEdge(expectedEdges[i], actualEdges.get(i));
	}
}
 
Example #13
Source File: SummarizationITCase.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
private <EV> void validateEdge(String expected, Edge<Long, EdgeValue<EV>> actual) {
	String[] tokens = TOKEN_SEPARATOR.split(expected);
	assertTrue(getListFromIdRange(tokens[0]).contains(actual.getSource()));
	assertTrue(getListFromIdRange(tokens[1]).contains(actual.getTarget()));
	assertEquals(getGroupValue(tokens[2]), actual.getValue().getEdgeGroupValue().toString());
	assertEquals(getGroupCount(tokens[2]), actual.getValue().getEdgeGroupCount());
}
 
Example #14
Source File: SummarizationITCase.java    From flink with Apache License 2.0 5 votes vote down vote up
private <EV> void validateEdge(String expected, Edge<Long, EdgeValue<EV>> actual) {
	String[] tokens = TOKEN_SEPARATOR.split(expected);
	assertTrue(getListFromIdRange(tokens[0]).contains(actual.getSource()));
	assertTrue(getListFromIdRange(tokens[1]).contains(actual.getTarget()));
	assertEquals(getGroupValue(tokens[2]), actual.getValue().getEdgeGroupValue().toString());
	assertEquals(getGroupCount(tokens[2]), actual.getValue().getEdgeGroupCount());
}
 
Example #15
Source File: SummarizationITCase.java    From flink with Apache License 2.0 5 votes vote down vote up
private <EV> void validateEdge(String expected, Edge<Long, EdgeValue<EV>> actual) {
	String[] tokens = TOKEN_SEPARATOR.split(expected);
	assertTrue(getListFromIdRange(tokens[0]).contains(actual.getSource()));
	assertTrue(getListFromIdRange(tokens[1]).contains(actual.getTarget()));
	assertEquals(getGroupValue(tokens[2]), actual.getValue().getEdgeGroupValue().toString());
	assertEquals(getGroupCount(tokens[2]), actual.getValue().getEdgeGroupCount());
}