Commit d6b94510 authored by yorn's avatar yorn

Forward message score to last edge

In order to justify an outgoing connection, we can assume that the last
incoming equivalent connection was the reason.
parent 2ab266c4
......@@ -37,6 +37,20 @@ public class SpreadRank extends
return octets[0] << 24 | octets[1] << 16 | octets[2] << 8 | octets[3];
}
static Edge<IntWritable, LongWritable> getLastEdgeBefore(long time,
Iterable<Edge<IntWritable, LongWritable>> edges) {
long highest = Long.MIN_VALUE;
Edge<IntWritable, LongWritable> edge = null;
for (Edge<IntWritable, LongWritable> e : edges) {
long candidate = e.getValue().get();
if (candidate < time && candidate > highest) {
highest = candidate;
edge = e;
}
}
return edge;
}
@Override
public void compute(Vertex<IntWritable, IntWritable, LongWritable> vertex,
Iterable<LongWritable> messages) throws IOException {
......@@ -52,12 +66,8 @@ public class SpreadRank extends
long messageWeight = (l + STEP_WEIGHT) & MASK_WEIGHT;
long messageTime = l & MASK_TIME;
int value = (int) (messageWeight >> 48);
for (Edge<IntWritable, LongWritable> e : vertex.getEdges()) {
if (e.getValue().get() > messageTime) {
sendMessage(e.getTargetVertexId(), new LongWritable(messageWeight));
break;
}
}
sendMessage(getLastEdgeBefore(messageTime, vertex.getEdges())
.getTargetVertexId(), new LongWritable(messageWeight));
if (value > currentValue) {
currentValue = value;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment