本文整理汇总了Java中org.apache.flink.graph.Vertex.getValue方法的典型用法代码示例。如果您正苦于以下问题:Java Vertex.getValue方法的具体用法?Java Vertex.getValue怎么用?Java Vertex.getValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.flink.graph.Vertex
的用法示例。
在下文中一共展示了Vertex.getValue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: compute
import org.apache.flink.graph.Vertex; //导入方法依赖的package包/类
@Override
public void compute(Vertex<K, Double> vertex, MessageIterator<NewMinDistance> messageIterator) throws Exception {
// Send initial group of messages from the source vertex
if (vertex.getId().equals(sourceVertex) && getSuperstepNumber() == 1) {
sendNewDistanceToAll(0);
}
// Calculate new min distance from source node
double minDistance = minDistance(messageIterator);
// Send new min distance to neighbour vertices if new min distance is less
if (minDistance < vertex.getValue()) {
setNewVertexValue(minDistance);
sendNewDistanceToAll(minDistance);
}
}
示例2: reduce
import org.apache.flink.graph.Vertex; //导入方法依赖的package包/类
@Override
public void reduce(Iterable<Vertex<K, VV>> values, Collector<VertexGroupItem<K, VV>> out) throws Exception {
K vertexGroupRepresentativeID = null;
long vertexGroupCount = 0L;
VV vertexGroupValue = null;
boolean isFirstElement = true;
for (Vertex<K, VV> vertex : values) {
if (isFirstElement) {
// take final group representative vertex id from first tuple
vertexGroupRepresentativeID = vertex.getId();
vertexGroupValue = vertex.getValue();
isFirstElement = false;
}
// no need to set group value for those tuples
reuseVertexGroupItem.setVertexId(vertex.getId());
reuseVertexGroupItem.setGroupRepresentativeId(vertexGroupRepresentativeID);
out.collect(reuseVertexGroupItem);
vertexGroupCount++;
}
createGroupRepresentativeTuple(vertexGroupRepresentativeID, vertexGroupValue, vertexGroupCount);
out.collect(reuseVertexGroupItem);
reuseVertexGroupItem.reset();
}
示例3: updateVertex
import org.apache.flink.graph.Vertex; //导入方法依赖的package包/类
@Override
public void updateVertex(Vertex<K, 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);
}
}
示例4: map
import org.apache.flink.graph.Vertex; //导入方法依赖的package包/类
public String map(Vertex<Long, Long> vertex) throws Exception {
String stringValue;
if (vertex.getValue() == 1) {
stringValue = "one";
} else if (vertex.getValue() == 2) {
stringValue = "two";
} else if (vertex.getValue() == 3) {
stringValue = "three";
} else if (vertex.getValue() == 4) {
stringValue = "four";
} else if (vertex.getValue() == 5) {
stringValue = "five";
} else {
stringValue = "";
}
return stringValue;
}
示例5: compute
import org.apache.flink.graph.Vertex; //导入方法依赖的package包/类
@Override
public void compute(Vertex<String, Double> vertex, MessageIterator<Double> messages) throws Exception {
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<String, Double> e : getEdges()) {
sendMessageTo(e.getTarget(), minDistance + e.getValue());
}
}
}
示例6: sendMessages
import org.apache.flink.graph.Vertex; //导入方法依赖的package包/类
@Override
public void sendMessages(Vertex<Long, Double> vertex) {
if (vertex.getValue() < Double.POSITIVE_INFINITY) {
for (Edge<Long, Double> edge : getEdges()) {
sendMessageTo(edge.getTarget(), vertex.getValue() + edge.getValue());
}
}
}
示例7: updateVertex
import org.apache.flink.graph.Vertex; //导入方法依赖的package包/类
@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);
}
}
示例8: compute
import org.apache.flink.graph.Vertex; //导入方法依赖的package包/类
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());
}
}
}
示例9: Projection
import org.apache.flink.graph.Vertex; //导入方法依赖的package包/类
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;
}
示例10: updateVertex
import org.apache.flink.graph.Vertex; //导入方法依赖的package包/类
@Override
public void updateVertex(Vertex<K, VV> vertex, MessageIterator<VV> messages) throws Exception {
VV current = vertex.getValue();
VV min = current;
for (VV msg : messages) {
if (msg.compareTo(min) < 0) {
min = msg;
}
}
if (!min.equals(current)) {
setNewVertexValue(min);
}
}
示例11: updateVertex
import org.apache.flink.graph.Vertex; //导入方法依赖的package包/类
public void updateVertex(Vertex<K, VV> vertex, MessageIterator<VV> inMessages) {
Map<VV, Long> labelsWithFrequencies = new HashMap<>();
long maxFrequency = 1;
VV mostFrequentLabel = vertex.getValue();
// store the labels with their frequencies
for (VV msg : inMessages) {
if (labelsWithFrequencies.containsKey(msg)) {
long currentFreq = labelsWithFrequencies.get(msg);
labelsWithFrequencies.put(msg, currentFreq + 1);
} else {
labelsWithFrequencies.put(msg, 1L);
}
}
// select the most frequent label: if two or more labels have the
// same frequency, the node adopts the label with the highest value
for (Entry<VV, Long> entry : labelsWithFrequencies.entrySet()) {
if (entry.getValue() == maxFrequency) {
// check the label value to break ties
if (entry.getKey().compareTo(mostFrequentLabel) > 0) {
mostFrequentLabel = entry.getKey();
}
} else if (entry.getValue() > maxFrequency) {
maxFrequency = entry.getValue();
mostFrequentLabel = entry.getKey();
}
}
setNewVertexValue(mostFrequentLabel);
}
示例12: sendMessages
import org.apache.flink.graph.Vertex; //导入方法依赖的package包/类
@Override
public void sendMessages(Vertex<K, Double> vertex) {
if (vertex.getValue() < Double.POSITIVE_INFINITY) {
for (Edge<K, Double> edge : getEdges()) {
sendMessageTo(edge.getTarget(), vertex.getValue() + edge.getValue());
}
}
}
示例13: compute
import org.apache.flink.graph.Vertex; //导入方法依赖的package包/类
@Override
public void compute(Vertex<Long, Long> vertex, MessageIterator<Long> messages) throws Exception {
long currentComponent = vertex.getValue();
for (Long msg : messages) {
currentComponent = Math.min(currentComponent, msg);
}
if ((getSuperstepNumber() == 1) || (currentComponent < vertex.getValue())) {
setNewVertexValue(currentComponent);
for (Edge<Long, NullValue> edge : getEdges()) {
sendMessageTo(edge.getTarget(), currentComponent);
}
}
}
示例14: iterateEdges
import org.apache.flink.graph.Vertex; //导入方法依赖的package包/类
@Override
public void iterateEdges(Vertex<Long, Long> v, Iterable<Edge<Long, Long>> edges,
Collector<Tuple2<Long, Long>> out) throws Exception {
for (Edge<Long, Long> edge : edges) {
if (v.getValue() > 4) {
if (v.getId().equals(edge.getTarget())) {
out.collect(new Tuple2<>(v.getId(), edge.getSource()));
} else {
out.collect(new Tuple2<>(v.getId(), edge.getTarget()));
}
}
}
}
示例15: iterateEdges
import org.apache.flink.graph.Vertex; //导入方法依赖的package包/类
@Override
public void iterateEdges(Vertex<Long, Long> v, Iterable<Edge<Long, Long>> edges,
Collector<Tuple2<Long, Long>> out) throws Exception {
for (Edge<Long, Long> edge : edges) {
if (v.getValue() > 2) {
out.collect(new Tuple2<>(v.getId(), edge.getTarget()));
}
}
}