Java Code Examples for org.apache.flink.graph.utils.GraphUtils.MapTo

The following examples show how to use org.apache.flink.graph.utils.GraphUtils.MapTo. These examples are extracted from open source projects. 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 Project: Flink-CEPplus   Source File: GSAConnectedComponents.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public DataSet<Vertex<K, VV>> run(Graph<K, VV, EV> graph) throws Exception {

	// get type information for vertex value
	TypeInformation<VV> valueTypeInfo = ((TupleTypeInfo<?>) graph.getVertices().getType()).getTypeAt(1);

	Graph<K, VV, NullValue> undirectedGraph = graph
		.mapEdges(new MapTo<>(NullValue.getInstance()))
		.getUndirected();

	return undirectedGraph.runGatherSumApplyIteration(
		new GatherNeighborIds<>(valueTypeInfo),
		new SelectMinId<>(valueTypeInfo),
		new UpdateComponentId<>(valueTypeInfo),
		maxIterations).getVertices();
}
 
Example 2
Source Project: flink   Source File: GSAConnectedComponents.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public DataSet<Vertex<K, VV>> run(Graph<K, VV, EV> graph) throws Exception {

	// get type information for vertex value
	TypeInformation<VV> valueTypeInfo = ((TupleTypeInfo<?>) graph.getVertices().getType()).getTypeAt(1);

	Graph<K, VV, NullValue> undirectedGraph = graph
		.mapEdges(new MapTo<>(NullValue.getInstance()))
		.getUndirected();

	return undirectedGraph.runGatherSumApplyIteration(
		new GatherNeighborIds<>(valueTypeInfo),
		new SelectMinId<>(valueTypeInfo),
		new UpdateComponentId<>(valueTypeInfo),
		maxIterations).getVertices();
}
 
Example 3
Source Project: flink   Source File: GSAConnectedComponents.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public DataSet<Vertex<K, VV>> run(Graph<K, VV, EV> graph) throws Exception {

	// get type information for vertex value
	TypeInformation<VV> valueTypeInfo = ((TupleTypeInfo<?>) graph.getVertices().getType()).getTypeAt(1);

	Graph<K, VV, NullValue> undirectedGraph = graph
		.mapEdges(new MapTo<>(NullValue.getInstance()))
		.getUndirected();

	return undirectedGraph.runGatherSumApplyIteration(
		new GatherNeighborIds<>(valueTypeInfo),
		new SelectMinId<>(valueTypeInfo),
		new UpdateComponentId<>(valueTypeInfo),
		maxIterations).getVertices();
}
 
Example 4
Source Project: Flink-CEPplus   Source File: ConnectedComponents.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public DataSet<Vertex<K, VV>> run(Graph<K, VV, EV> graph) throws Exception {

	// get type information for vertex value
	TypeInformation<VV> valueTypeInfo = ((TupleTypeInfo<?>) graph.getVertices().getType()).getTypeAt(1);

	Graph<K, VV, NullValue> undirectedGraph = graph
		.mapEdges(new MapTo<>(NullValue.getInstance()))
		.getUndirected();

	return undirectedGraph.runScatterGatherIteration(
		new CCMessenger<>(valueTypeInfo),
		new CCUpdater<>(),
		maxIterations).getVertices();
}
 
Example 5
Source Project: Flink-CEPplus   Source File: LabelPropagation.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public DataSet<Vertex<K, VV>> run(Graph<K, VV, EV> input) {

	TypeInformation<VV> valueType = ((TupleTypeInfo<?>) input.getVertices().getType()).getTypeAt(1);
	// iteratively adopt the most frequent label among the neighbors of each vertex
	return input
		.mapEdges(new MapTo<>(NullValue.getInstance()))
		.runScatterGatherIteration(
			new SendNewLabelToNeighbors<>(valueType), new UpdateVertexLabel<>(), maxIterations)
		.getVertices();
}
 
Example 6
Source Project: flink   Source File: ConnectedComponents.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public DataSet<Vertex<K, VV>> run(Graph<K, VV, EV> graph) throws Exception {

	// get type information for vertex value
	TypeInformation<VV> valueTypeInfo = ((TupleTypeInfo<?>) graph.getVertices().getType()).getTypeAt(1);

	Graph<K, VV, NullValue> undirectedGraph = graph
		.mapEdges(new MapTo<>(NullValue.getInstance()))
		.getUndirected();

	return undirectedGraph.runScatterGatherIteration(
		new CCMessenger<>(valueTypeInfo),
		new CCUpdater<>(),
		maxIterations).getVertices();
}
 
Example 7
Source Project: flink   Source File: LabelPropagation.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public DataSet<Vertex<K, VV>> run(Graph<K, VV, EV> input) {

	TypeInformation<VV> valueType = ((TupleTypeInfo<?>) input.getVertices().getType()).getTypeAt(1);
	// iteratively adopt the most frequent label among the neighbors of each vertex
	return input
		.mapEdges(new MapTo<>(NullValue.getInstance()))
		.runScatterGatherIteration(
			new SendNewLabelToNeighbors<>(valueType), new UpdateVertexLabel<>(), maxIterations)
		.getVertices();
}
 
Example 8
Source Project: flink   Source File: ConnectedComponents.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public DataSet<Vertex<K, VV>> run(Graph<K, VV, EV> graph) throws Exception {

	// get type information for vertex value
	TypeInformation<VV> valueTypeInfo = ((TupleTypeInfo<?>) graph.getVertices().getType()).getTypeAt(1);

	Graph<K, VV, NullValue> undirectedGraph = graph
		.mapEdges(new MapTo<>(NullValue.getInstance()))
		.getUndirected();

	return undirectedGraph.runScatterGatherIteration(
		new CCMessenger<>(valueTypeInfo),
		new CCUpdater<>(),
		maxIterations).getVertices();
}
 
Example 9
Source Project: flink   Source File: LabelPropagation.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public DataSet<Vertex<K, VV>> run(Graph<K, VV, EV> input) {

	TypeInformation<VV> valueType = ((TupleTypeInfo<?>) input.getVertices().getType()).getTypeAt(1);
	// iteratively adopt the most frequent label among the neighbors of each vertex
	return input
		.mapEdges(new MapTo<>(NullValue.getInstance()))
		.runScatterGatherIteration(
			new SendNewLabelToNeighbors<>(valueType), new UpdateVertexLabel<>(), maxIterations)
		.getVertices();
}