Hi Martin,
You are right, this should not happen, your code looks correct. One way
to check the output would be to simply count the number vertices per
component and see if that number stays stable.
Do you supply all vertices in your input data or are some vertices
created during the computation? Maybe there's a bug/race condition with
the vertex creation (just wildly guessing)
Best,
Sebastian
On 02/27/2014 10:48 AM, Martin Neumann wrote:
Hej,
I have modified the connected component example to fit my input data. I
expect it to be deterministic.
But when I run it multiple times it takes a different number of Super
steps. This only happens on the complete dataset and not on my small test
dataset.
(So I cannot check the output for correctness in a simple way)
Has anyone an Idea how this could happen?
cheers Martin
In case its useful here the computation class:
@Override
public void compute(Vertex<Text, Text, NullWritable> vertex,
Iterable<Text> inmessage) throws IOException {
boolean changed = false;
// first superstep && setup
if (getSuperstep() == 0) {
//initialize value
vertex.setValue(vertex.getId());
//cheating by checking the neighbors ID's (cuts down 1
iteration)
for (Edge<Text, NullWritable> e : vertex.getEdges()) {
Text candidate = e.getTargetVertexId();
if (candidate.compareTo(vertex.getValue()) < 0) {
changed = true;
vertex.setValue(candidate);
}
}
}
// other superstep
else {
// read all messages and compare with own state
for (Text message : inmessage) {
if (message.compareTo(vertex.getValue()) < 0) {
changed = true;
vertex.setValue(message);
}
}
}
// if state has changed send a message to all neighbors
if (changed && getSuperstep() < limiter) {
sendMessageToAllEdges(vertex, vertex.getValue());
}
vertex.voteToHalt();
}