本文整理了Java中org.apache.flink.graph.Vertex
类的一些代码示例,展示了Vertex
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Vertex
类的具体详情如下:
包路径:org.apache.flink.graph.Vertex
类名称:Vertex
[英]Represents the graph's nodes. It carries an ID and a value. For vertices with no value, use org.apache.flink.types.NullValue as the value type.
[中]表示图形的节点。它携带一个ID和一个值。对于没有值的顶点,请使用org。阿帕奇。弗林克。类型。值类型为NullValue。
代码示例来源:origin: apache/flink
public Vertex<K, VV> map(Vertex<K, Tuple3<VV, LongValue, LongValue>> vertex) {
return new Vertex<>(vertex.getId(), vertex.getValue().f0);
}
});
代码示例来源:origin: apache/flink
@Override
public void sendMessages(Vertex<K, Double> vertex) {
if (getSuperstepNumber() == 1) {
// initialize vertex ranks
vertex.setValue(1.0 / this.getNumberOfVertices());
}
for (Edge<K, Double> edge : getEdges()) {
sendMessageTo(edge.getTarget(), vertex.getValue() * edge.getValue());
}
}
}
代码示例来源:origin: apache/flink
public Projection(
Vertex<KC, VVC> connectingVertex,
VV sourceVertexValue, VV targetVertexValue,
EV sourceEdgeValue, EV targetEdgeValue) {
this.f0 = connectingVertex.getId();
this.f1 = connectingVertex.getValue();
this.f2 = sourceVertexValue;
this.f3 = targetVertexValue;
this.f4 = sourceEdgeValue;
this.f5 = targetEdgeValue;
}
代码示例来源:origin: apache/flink
/**
* In order to hide the Tuple3(actualValue, inDegree, OutDegree) vertex value from the user,
* another function will be called from {@link org.apache.flink.graph.spargel.ScatterGatherIteration}.
*
* <p>This function will retrieve the vertex from the vertexState and will set its degrees, afterwards calling
* the regular updateVertex function.
*
* @param vertexState
* @param inMessages
* @throws Exception
*/
@SuppressWarnings("unchecked")
<VertexWithDegree> void updateVertexFromScatterGatherIteration(Vertex<K, VertexWithDegree> vertexState,
MessageIterator<Message> inMessages) throws Exception {
Vertex<K, VV> vertex = new Vertex<>(vertexState.f0,
((Tuple3<VV, Long, Long>) vertexState.getValue()).f0);
updateVertex(vertex, inMessages);
}
}
代码示例来源:origin: apache/flink
public Vertex<K, VV> getSrcVertex() {
return new Vertex<>(this.f0, this.f2);
}
代码示例来源:origin: apache/flink
@Override
public Long map(Vertex<K, Tuple2<Long, Double>> vertex) throws Exception {
return vertex.getValue().f0;
}
}
代码示例来源:origin: apache/flink
public Tuple2<K, Either<NullValue, Message>> map(Vertex<K, VV> vertex) {
outTuple.f0 = vertex.getId();
return outTuple;
}
}
代码示例来源:origin: org.gradoop/gradoop-flink
/**
* Constructor.
*/
public VertexToGellyVertexWithNullValue() {
reuseVertex = new org.apache.flink.graph.Vertex<>();
reuseVertex.setValue(NullValue.getInstance());
}
代码示例来源:origin: dbs-leipzig/gradoop
/**
* Map function to create gelly vertices with long key and long value.
*
* @param tuple given unique vertex id
* @return gelly vertex
*/
@Override
public Vertex<Long, Long> map(Tuple2<Long, GradoopId> tuple) {
vertex.setId(tuple.f0);
vertex.setValue(tuple.f0);
return vertex;
}
}
代码示例来源:origin: apache/flink
/**
* Sets the new value of this vertex. Setting a new value triggers the sending of outgoing messages from this vertex.
*
* <p>This should be called at most once per updateVertex.
*
* @param newValue The new vertex value.
*/
public void setNewVertexValue(VV newValue) {
if (setNewVertexValueCalled) {
throw new IllegalStateException("setNewVertexValue should only be called at most once per updateVertex");
}
setNewVertexValueCalled = true;
if (isOptDegrees()) {
outValWithDegrees.f1.f0 = newValue;
outWithDegrees.collect(outValWithDegrees);
} else {
outVal.setValue(newValue);
out.collect(outVal);
}
}
代码示例来源:origin: org.gradoop/gradoop-flink
@Override
public org.apache.flink.graph.Vertex<GradoopId, NullValue> map(Vertex epgmVertex) {
reuseVertex.setId(epgmVertex.getId());
return reuseVertex;
}
}
代码示例来源:origin: apache/flink
public Vertex<K, VV> getTrgVertex() {
return new Vertex<>(this.f1, this.f3);
}
代码示例来源:origin: apache/flink
@Override
public Tuple3<Long, Long, Double> map(Triplet<Long, Point, Double> triplet)
throws Exception {
Vertex<Long, Point> srcVertex = triplet.getSrcVertex();
Vertex<Long, Point> trgVertex = triplet.getTrgVertex();
return new Tuple3<>(srcVertex.getId(), trgVertex.getId(),
srcVertex.getValue().euclideanDistance(trgVertex.getValue()));
}
});
代码示例来源:origin: apache/flink
@Override
public void sendMessages(Vertex<K, VV> vertex) throws Exception {
// send current minimum to neighbors
sendMessageToAllNeighbors(vertex.getValue());
}
代码示例来源:origin: apache/flink
@Override
public void coGroup(Iterable<Edge<K, EV>> edges,
Iterable<Vertex<K, VV>> state,
Collector<Tuple2<K, Message>> out) throws Exception {
final Iterator<Vertex<K, VV>> stateIter = state.iterator();
if (stateIter.hasNext()) {
Vertex<K, VV> newVertexState = stateIter.next();
scatterFunction.set(edges.iterator(), out, newVertexState.getId());
scatterFunction.sendMessages(newVertexState);
}
}
}
代码示例来源:origin: dbs-leipzig/gradoop
/**
* Constructor.
*/
public VertexToGellyVertexWithNullValue() {
reuseVertex = new org.apache.flink.graph.Vertex<>();
reuseVertex.setValue(NullValue.getInstance());
}
代码示例来源:origin: org.gradoop/gradoop-flink
/**
* Map function to create gelly vertices with long key and long value.
*
* @param tuple given unique vertex id
* @return gelly vertex
*/
@Override
public Vertex<Long, Long> map(Tuple2<Long, GradoopId> tuple) {
vertex.setId(tuple.f0);
vertex.setValue(tuple.f0);
return vertex;
}
}
代码示例来源:origin: org.apache.flink/flink-gelly_2.10
/**
* Sets the new value of this vertex. Setting a new value triggers the sending of outgoing messages from this vertex.
*
* This should be called at most once per updateVertex.
*
* @param newValue The new vertex value.
*/
public void setNewVertexValue(VV newValue) {
if(setNewVertexValueCalled) {
throw new IllegalStateException("setNewVertexValue should only be called at most once per updateVertex");
}
setNewVertexValueCalled = true;
if(isOptDegrees()) {
outValWithDegrees.f1.f0 = newValue;
outWithDegrees.collect(outValWithDegrees);
} else {
outVal.setValue(newValue);
out.collect(outVal);
}
}
代码示例来源:origin: dbs-leipzig/gradoop
@Override
public org.apache.flink.graph.Vertex<GradoopId, NullValue> map(Vertex epgmVertex) {
reuseVertex.setId(epgmVertex.getId());
return reuseVertex;
}
}
代码示例来源:origin: apache/flink
public Vertex<K, Tuple2<Long, Double>> map(Vertex<K, Long> vertex) {
return new Vertex<>(vertex.getId(), new Tuple2<>(vertex.getValue(), 1.0));
}
}
内容来源于网络,如有侵权,请联系作者删除!