@Override public boolean shouldDebugVertex( Vertex<LongWritable, IntWritable, NullWritable> vertex, long superstepNo) { return (vertex.getId().get() == 74780L) || (vertex.getId().get() == 75686) || (vertex.getId().get() == 75685); }
// public static double level=0; @Override public void compute( Vertex<LongWritable, DoubleWritable, FloatWritable> v, Iterable<DoubleWritable> msg) throws IOException { if (getSuperstep() == 0) { if (isSource(v) == true) { v.setValue(new DoubleWritable(0)); // level++; sendMessageToAllEdges(v, new DoubleWritable(v.getId().get())); } else v.setValue(new DoubleWritable(-1)); } else { for (DoubleWritable messages : msg) { if (v.getValue().get() == -1) { v.setValue(messages); for (Edge<LongWritable, FloatWritable> edge : v.getEdges()) { if (edge.getTargetVertexId().get() != v.getValue().get()) { sendMessage(edge.getTargetVertexId(), new DoubleWritable(v.getId().get())); } } } else { if (v.getValue().get() != messages.get()) { removeEdgesRequest(v.getId(), new LongWritable((long) messages.get())); removeEdgesRequest(new LongWritable((long) messages.get()), v.getId()); } } /* if(v.getValue().get() > messages.get()) { v.setValue(new DoubleWritable(getSuperstep())); // changed=true; }*/ } if (v.getValue().get() == -1) { for (Edge<LongWritable, FloatWritable> edge : v.getEdges()) { if (edge.getTargetVertexId().get() != v.getValue().get()) sendMessage(edge.getTargetVertexId(), new DoubleWritable(v.getId().get())); } } /* if(changed) { level++; sendMessageToAllEdges(v,new DoubleWritable(level)); changed=false; }*/ } v.voteToHalt(); }
/** * Is this vertex the source id? * * @param vertex Vertex * @return True if the source id */ private boolean isSource(Vertex<IntWritable, ?, ?> vertex) { return vertex.getId().get() == SOURCE_ID.get(getConf()); }
private boolean isSource(Vertex<LongWritable, DoubleWritable, FloatWritable> v) { return v.getId().get() == SOURCE_ID.get(getConf()); }