org.apache.flink.graph.Vertex类的使用及代码示例

x33g5p2x  于2022-02-01 转载在 其他  
字(6.1k)|赞(0)|评价(0)|浏览(109)

本文整理了Java中org.apache.flink.graph.Vertex类的一些代码示例,展示了Vertex类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Vertex类的具体详情如下:
包路径:org.apache.flink.graph.Vertex
类名称: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

  1. public Vertex<K, VV> map(Vertex<K, Tuple3<VV, LongValue, LongValue>> vertex) {
  2. return new Vertex<>(vertex.getId(), vertex.getValue().f0);
  3. }
  4. });

代码示例来源:origin: apache/flink

  1. @Override
  2. public void sendMessages(Vertex<K, Double> vertex) {
  3. if (getSuperstepNumber() == 1) {
  4. // initialize vertex ranks
  5. vertex.setValue(1.0 / this.getNumberOfVertices());
  6. }
  7. for (Edge<K, Double> edge : getEdges()) {
  8. sendMessageTo(edge.getTarget(), vertex.getValue() * edge.getValue());
  9. }
  10. }
  11. }

代码示例来源:origin: apache/flink

  1. public Projection(
  2. Vertex<KC, VVC> connectingVertex,
  3. VV sourceVertexValue, VV targetVertexValue,
  4. EV sourceEdgeValue, EV targetEdgeValue) {
  5. this.f0 = connectingVertex.getId();
  6. this.f1 = connectingVertex.getValue();
  7. this.f2 = sourceVertexValue;
  8. this.f3 = targetVertexValue;
  9. this.f4 = sourceEdgeValue;
  10. this.f5 = targetEdgeValue;
  11. }

代码示例来源:origin: apache/flink

  1. /**
  2. * In order to hide the Tuple3(actualValue, inDegree, OutDegree) vertex value from the user,
  3. * another function will be called from {@link org.apache.flink.graph.spargel.ScatterGatherIteration}.
  4. *
  5. * <p>This function will retrieve the vertex from the vertexState and will set its degrees, afterwards calling
  6. * the regular updateVertex function.
  7. *
  8. * @param vertexState
  9. * @param inMessages
  10. * @throws Exception
  11. */
  12. @SuppressWarnings("unchecked")
  13. <VertexWithDegree> void updateVertexFromScatterGatherIteration(Vertex<K, VertexWithDegree> vertexState,
  14. MessageIterator<Message> inMessages) throws Exception {
  15. Vertex<K, VV> vertex = new Vertex<>(vertexState.f0,
  16. ((Tuple3<VV, Long, Long>) vertexState.getValue()).f0);
  17. updateVertex(vertex, inMessages);
  18. }
  19. }

代码示例来源:origin: apache/flink

  1. public Vertex<K, VV> getSrcVertex() {
  2. return new Vertex<>(this.f0, this.f2);
  3. }

代码示例来源:origin: apache/flink

  1. @Override
  2. public Long map(Vertex<K, Tuple2<Long, Double>> vertex) throws Exception {
  3. return vertex.getValue().f0;
  4. }
  5. }

代码示例来源:origin: apache/flink

  1. public Tuple2<K, Either<NullValue, Message>> map(Vertex<K, VV> vertex) {
  2. outTuple.f0 = vertex.getId();
  3. return outTuple;
  4. }
  5. }

代码示例来源:origin: org.gradoop/gradoop-flink

  1. /**
  2. * Constructor.
  3. */
  4. public VertexToGellyVertexWithNullValue() {
  5. reuseVertex = new org.apache.flink.graph.Vertex<>();
  6. reuseVertex.setValue(NullValue.getInstance());
  7. }

代码示例来源:origin: dbs-leipzig/gradoop

  1. /**
  2. * Map function to create gelly vertices with long key and long value.
  3. *
  4. * @param tuple given unique vertex id
  5. * @return gelly vertex
  6. */
  7. @Override
  8. public Vertex<Long, Long> map(Tuple2<Long, GradoopId> tuple) {
  9. vertex.setId(tuple.f0);
  10. vertex.setValue(tuple.f0);
  11. return vertex;
  12. }
  13. }

代码示例来源:origin: apache/flink

  1. /**
  2. * Sets the new value of this vertex. Setting a new value triggers the sending of outgoing messages from this vertex.
  3. *
  4. * <p>This should be called at most once per updateVertex.
  5. *
  6. * @param newValue The new vertex value.
  7. */
  8. public void setNewVertexValue(VV newValue) {
  9. if (setNewVertexValueCalled) {
  10. throw new IllegalStateException("setNewVertexValue should only be called at most once per updateVertex");
  11. }
  12. setNewVertexValueCalled = true;
  13. if (isOptDegrees()) {
  14. outValWithDegrees.f1.f0 = newValue;
  15. outWithDegrees.collect(outValWithDegrees);
  16. } else {
  17. outVal.setValue(newValue);
  18. out.collect(outVal);
  19. }
  20. }

代码示例来源:origin: org.gradoop/gradoop-flink

  1. @Override
  2. public org.apache.flink.graph.Vertex<GradoopId, NullValue> map(Vertex epgmVertex) {
  3. reuseVertex.setId(epgmVertex.getId());
  4. return reuseVertex;
  5. }
  6. }

代码示例来源:origin: apache/flink

  1. public Vertex<K, VV> getTrgVertex() {
  2. return new Vertex<>(this.f1, this.f3);
  3. }

代码示例来源:origin: apache/flink

  1. @Override
  2. public Tuple3<Long, Long, Double> map(Triplet<Long, Point, Double> triplet)
  3. throws Exception {
  4. Vertex<Long, Point> srcVertex = triplet.getSrcVertex();
  5. Vertex<Long, Point> trgVertex = triplet.getTrgVertex();
  6. return new Tuple3<>(srcVertex.getId(), trgVertex.getId(),
  7. srcVertex.getValue().euclideanDistance(trgVertex.getValue()));
  8. }
  9. });

代码示例来源:origin: apache/flink

  1. @Override
  2. public void sendMessages(Vertex<K, VV> vertex) throws Exception {
  3. // send current minimum to neighbors
  4. sendMessageToAllNeighbors(vertex.getValue());
  5. }

代码示例来源:origin: apache/flink

  1. @Override
  2. public void coGroup(Iterable<Edge<K, EV>> edges,
  3. Iterable<Vertex<K, VV>> state,
  4. Collector<Tuple2<K, Message>> out) throws Exception {
  5. final Iterator<Vertex<K, VV>> stateIter = state.iterator();
  6. if (stateIter.hasNext()) {
  7. Vertex<K, VV> newVertexState = stateIter.next();
  8. scatterFunction.set(edges.iterator(), out, newVertexState.getId());
  9. scatterFunction.sendMessages(newVertexState);
  10. }
  11. }
  12. }

代码示例来源:origin: dbs-leipzig/gradoop

  1. /**
  2. * Constructor.
  3. */
  4. public VertexToGellyVertexWithNullValue() {
  5. reuseVertex = new org.apache.flink.graph.Vertex<>();
  6. reuseVertex.setValue(NullValue.getInstance());
  7. }

代码示例来源:origin: org.gradoop/gradoop-flink

  1. /**
  2. * Map function to create gelly vertices with long key and long value.
  3. *
  4. * @param tuple given unique vertex id
  5. * @return gelly vertex
  6. */
  7. @Override
  8. public Vertex<Long, Long> map(Tuple2<Long, GradoopId> tuple) {
  9. vertex.setId(tuple.f0);
  10. vertex.setValue(tuple.f0);
  11. return vertex;
  12. }
  13. }

代码示例来源:origin: org.apache.flink/flink-gelly_2.10

  1. /**
  2. * Sets the new value of this vertex. Setting a new value triggers the sending of outgoing messages from this vertex.
  3. *
  4. * This should be called at most once per updateVertex.
  5. *
  6. * @param newValue The new vertex value.
  7. */
  8. public void setNewVertexValue(VV newValue) {
  9. if(setNewVertexValueCalled) {
  10. throw new IllegalStateException("setNewVertexValue should only be called at most once per updateVertex");
  11. }
  12. setNewVertexValueCalled = true;
  13. if(isOptDegrees()) {
  14. outValWithDegrees.f1.f0 = newValue;
  15. outWithDegrees.collect(outValWithDegrees);
  16. } else {
  17. outVal.setValue(newValue);
  18. out.collect(outVal);
  19. }
  20. }

代码示例来源:origin: dbs-leipzig/gradoop

  1. @Override
  2. public org.apache.flink.graph.Vertex<GradoopId, NullValue> map(Vertex epgmVertex) {
  3. reuseVertex.setId(epgmVertex.getId());
  4. return reuseVertex;
  5. }
  6. }

代码示例来源:origin: apache/flink

  1. public Vertex<K, Tuple2<Long, Double>> map(Vertex<K, Long> vertex) {
  2. return new Vertex<>(vertex.getId(), new Tuple2<>(vertex.getValue(), 1.0));
  3. }
  4. }

相关文章