@Override public Long map(Vertex<K, Tuple2<Long, Double>> vertex) throws Exception { return vertex.getValue().f0; } }
@Override public void sendMessages(Vertex<K, VV> vertex) throws Exception { // send current minimum to neighbors sendMessageToAllNeighbors(vertex.getValue()); }
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; }
@Override public void updateVertex(Vertex<Long, Double> vertex, MessageIterator<Double> inMessages) { Double minDistance = Double.MAX_VALUE; for (double msg : inMessages) { if (msg < minDistance) { minDistance = msg; } } if (vertex.getValue() > minDistance) { setNewVertexValue(minDistance); } } }
@Override public void join(Tuple4<K, K, VV, EV> tripletWithSrcValSet, Vertex<K, VV> vertex, Collector<Triplet<K, VV, EV>> collector) throws Exception { collector.collect(new Triplet<>(tripletWithSrcValSet.f0, tripletWithSrcValSet.f1, tripletWithSrcValSet.f2, vertex.getValue(), tripletWithSrcValSet.f3)); } }
@Override public void join(Tuple2<K, M> newValue, final Vertex<K, VV> currentValue, final Collector<Vertex<K, VV>> out) throws Exception { this.applyFunction.setOutput(currentValue, out); this.applyFunction.apply(newValue.f1, currentValue.getValue()); }
public void join(Tuple3<K, K, Edge<K, EV>> keysWithEdge, Vertex<K, VV> neighbor, Collector<Tuple2<K, VV>> out) { out.collect(new Tuple2<>(keysWithEdge.f0, neighbor.getValue())); } }
public Vertex<K, VV> map(Vertex<K, Tuple3<VV, LongValue, LongValue>> vertex) { return new Vertex<>(vertex.getId(), vertex.getValue().f0); } });
@SuppressWarnings("unchecked") public void join(Edge<K, EV> edge, Vertex<K, VV> otherVertex, Collector<Tuple2<K, VV>> out) { out.collect(new Tuple2<>((K) edge.getField(fieldPosition), otherVertex.getValue())); } }
@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())); } });
public void compute(Vertex<Long, Double> vertex, MessageIterator<Double> messages) { double minDistance = (vertex.getId().equals(srcId)) ? 0d : Double.POSITIVE_INFINITY; for (Double msg : messages) { minDistance = Math.min(minDistance, msg); } if (minDistance < vertex.getValue()) { setNewVertexValue(minDistance); for (Edge<Long, Double> e: getEdges()) { sendMessageTo(e.getTarget(), minDistance + e.getValue()); } } } }
public Vertex<K, Tuple2<Long, Double>> map(Vertex<K, Long> vertex) { return new Vertex<>(vertex.getId(), new Tuple2<>(vertex.getValue(), 1.0)); } }
@Override public void join(Vertex<K, VV> vertex, Edge<K, EV> edge, Collector<Tuple4<K, K, VV, EV>> collector) throws Exception { collector.collect(new Tuple4<>(edge.getSource(), edge.getTarget(), vertex.getValue(), edge.getValue())); } }
@Override public void join(Vertex<K, VV> vertex, Tuple3<K, LongValue, LongValue> degrees, Collector<Vertex<K, Tuple3<VV, LongValue, LongValue>>> out) throws Exception { out.collect(new Vertex<>(vertex.getId(), new Tuple3<>(vertex.getValue(), degrees.f1, degrees.f2))); } }).withForwardedFieldsFirst("f0");
public void join(Vertex<K, VV> vertex, Edge<K, EV> edge, Collector<Tuple2<K, Neighbor<VV, EV>>> out) { out.collect(new Tuple2<>( edge.getTarget(), new Neighbor<>(vertex.getValue(), edge.getValue()))); } }
public void join(Vertex<K, VV> vertex, Edge<K, EV> edge, Collector<Tuple2<K, Neighbor<VV, EV>>> out) { out.collect(new Tuple2<>( edge.getSource(), new Neighbor<>(vertex.getValue(), edge.getValue()))); } }
@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()); } } }