提交 a50eb73e 编写于 作者: V vasia

[FLINK-3181] [gelly] avoid unnecessary messages in SSSP examples and library method

This closes #1467
上级 f7b113d9
......@@ -113,8 +113,10 @@ object SingleSourceShortestPaths {
MessagingFunction[Long, Double, Double, Double] {
override def sendMessages(vertex: Vertex[Long, Double]) {
for (edge: Edge[Long, Double] <- getEdges) {
sendMessageTo(edge.getTarget, vertex.getValue + edge.getValue)
if (vertex.getValue < Double.PositiveInfinity) {
for (edge: Edge[Long, Double] <- getEdges) {
sendMessageTo(edge.getTarget, vertex.getValue + edge.getValue)
}
}
}
}
......
......@@ -135,8 +135,10 @@ public class SingleSourceShortestPaths implements ProgramDescription {
@Override
public void sendMessages(Vertex<Long, Double> vertex) {
for (Edge<Long, Double> edge : getEdges()) {
sendMessageTo(edge.getTarget(), vertex.getValue() + edge.getValue());
if (vertex.getValue() < Double.POSITIVE_INFINITY) {
for (Edge<Long, Double> edge : getEdges()) {
sendMessageTo(edge.getTarget(), vertex.getValue() + edge.getValue());
}
}
}
}
......
......@@ -108,10 +108,11 @@ public class SingleSourceShortestPaths<K> implements GraphAlgorithm<K, Double, D
public static final class MinDistanceMessenger<K> extends MessagingFunction<K, Double, Double, Double> {
@Override
public void sendMessages(Vertex<K, Double> vertex)
throws Exception {
for (Edge<K, Double> edge : getEdges()) {
sendMessageTo(edge.getTarget(), vertex.getValue() + edge.getValue());
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());
}
}
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册