import org.apache.giraph.graph.BasicComputation;
import org.apache.giraph.conf.LongConfOption;
import org.apache.giraph.edge.Edge;
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 {
  }
}

@@ -1,53 +1,4 @@
-import org.apache.giraph.graph.BasicComputation;%0A
 impo
@@ -75,16 +75,65 @@
 e.Edge;%0A
+import org.apache.giraph.graph.BasicComputation;%0A
 import o
@@ -394,21 +394,16 @@
 utation%3C
-%0A    
 IntWrita
@@ -449,21 +449,30 @@
 able%3E %7B%0A
+  
   /**
+%0A     *
  The sho
@@ -485,20 +485,27 @@
 paths id
+%0A    
  */%0A
+  
   public
@@ -544,22 +544,16 @@
 RCE_ID =
-%0A     
  new Lon
@@ -608,18 +608,8 @@
 , 1,
-%0A         
  %22Th
@@ -634,20 +634,24 @@
 d%22);%0A%0A  
+ 
+ 
 /**%0A
+  
    * Is 
@@ -681,16 +681,18 @@
 id?%0A
+  
    *%0A   
 * @p
@@ -687,16 +687,18 @@
    *%0A   
+  
 * @param
@@ -712,16 +712,18 @@
  Vertex%0A
+  
    * @re
@@ -749,22 +749,26 @@
 urce id%0A
+  
    */%0A
+  
   privat
@@ -826,16 +826,20 @@
 ) %7B%0A    
+   
+ 
 return v
@@ -891,13 +891,17 @@
 ));%0A
+  
   %7D%0A%0A
+  
   @O
@@ -908,16 +908,18 @@
 verride%0A
+  
   public
@@ -932,23 +932,16 @@
 compute(
-%0A      
 Vertex%3CI
@@ -986,22 +986,16 @@
  vertex,
-%0A     
  Iterabl
@@ -1040,14 +1040,625 @@
 ption %7B%0A
+        if (getSuperstep() == 0) %7B%0A            vertex.setValue(new IntWritable(Integer.MAX_VALUE));%0A        %7D%0A%0A        Integer minDist = isSource(vertex) ? 0 : Integer.MAX_VALUE;%0A        for (IntWritable message : messages) %7B%0A            minDist = Math.min(minDist, message.get());%0A        %7D%0A%0A        if (minDist %3C vertex.getValue().get()) %7B%0A            vertex.setValue(new IntWritable(minDist));%0A            for (Edge%3CIntWritable, NullWritable%3E edge : vertex.getEdges()) %7B%0A                sendMessage(edge.getTargetVertexId(), new IntWritable(minDist));%0A            %7D%0A%0A        %7D%0A        vertex.voteToHalt();%0A  
   %7D%0A%7D%0A

add shortest path