import org.apache.giraph.conf.LongConfOption;
import org.apache.giraph.edge.Edge;
import org.apache.giraph.graph.BasicComputation;
import org.apache.giraph.graph.Vertex;
import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.NullWritable;

import java.io.IOException;

/**
 * Compute shortest paths from a given source.
 */
public class ShortestPathsComputation extends BasicComputation<IntWritable, IntWritable, NullWritable, IntWritable> {
    /**
     * The shortest paths id
     */
    public static final LongConfOption SOURCE_ID = new LongConfOption("SimpleShortestPathsVertex.sourceId", 1, "The shortest paths id");

    /**
     * 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());
    }

    @Override
    public void compute(Vertex<IntWritable, IntWritable, NullWritable> vertex, Iterable<IntWritable> messages) throws IOException {
        if (getSuperstep() == 0) {
            vertex.setValue(new IntWritable(Integer.MAX_VALUE));
        }

        Integer minDist = isSource(vertex) ? 0 : Integer.MAX_VALUE;
        for (IntWritable message : messages) {
            minDist = Math.min(minDist, message.get());
        }

        if (minDist < vertex.getValue().get()) {
            int distance = minDist + 1;
            vertex.setValue(new IntWritable(distance));
            for (Edge<IntWritable, NullWritable> edge : vertex.getEdges()) {
                sendMessage(edge.getTargetVertexId(), new IntWritable(distance));
            }
        }
        vertex.voteToHalt();
    }
}

@@ -245,16 +245,48 @@
 ritable;
+%0Aimport org.apache.log4j.Logger;
 %0A%0Aimport
@@ -481,16 +481,118 @@
 able%3E %7B%0A
+%0A    private static final Logger LOG =%0A            Logger.getLogger(ShortestPathsComputation.class);%0A%0A
     /**%0A
@@ -1466,25 +1466,24 @@
       %7D%0A
-%0A
         
 if (minD
@@ -1478,21 +1478,104 @@
     
-if (
+LOG.debug(String.format(%22Vertex %25s got minDist = %25d vertex value = %25s%22, vertex.getId(), 
 minDist
- %3C
+,
  ver
@@ -1592,57 +1592,61 @@
 ue()
-.get()) %7B%0A            int distance = minDist + 1;
+));%0A%0A        if (minDist %3C vertex.getValue().get()) %7B
 %0A   
@@ -1682,32 +1682,31 @@
 IntWritable(
-distance
+minDist
 ));%0A        
@@ -1770,24 +1770,191 @@
 tEdges()) %7B%0A
+                int distance = minDist + 1;%0A                LOG.debug(String.format(%22Vertex %25s sent to %25s = %25d%22, vertex.getId(), edge.getTargetVertexId(), distance));%0A
             

fix shortest path