You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@giraph.apache.org by ma...@apache.org on 2013/05/20 19:26:58 UTC

[02/12] GIRAPH-667: Decouple Vertex data and Computation, make Computation and Combiner classes switchable (majakabiljo)

http://git-wip-us.apache.org/repos/asf/giraph/blob/8811165e/giraph-examples/src/test/java/org/apache/giraph/TestMaxSuperstep.java
----------------------------------------------------------------------
diff --git a/giraph-examples/src/test/java/org/apache/giraph/TestMaxSuperstep.java b/giraph-examples/src/test/java/org/apache/giraph/TestMaxSuperstep.java
index 0989ac5..75157a1 100644
--- a/giraph-examples/src/test/java/org/apache/giraph/TestMaxSuperstep.java
+++ b/giraph-examples/src/test/java/org/apache/giraph/TestMaxSuperstep.java
@@ -21,8 +21,11 @@ package org.apache.giraph;
 import org.apache.giraph.conf.GiraphConfiguration;
 import org.apache.giraph.counters.GiraphHadoopCounter;
 import org.apache.giraph.counters.GiraphStats;
-import org.apache.giraph.examples.SimplePageRankVertex.SimplePageRankVertexInputFormat;
-import org.apache.giraph.examples.SimplePageRankVertex.SimplePageRankVertexOutputFormat;
+import org.apache.giraph.examples.SimplePageRankComputation.SimplePageRankVertexInputFormat;
+import org.apache.giraph.examples.SimplePageRankComputation.SimplePageRankVertexOutputFormat;
+
+
+import org.apache.giraph.graph.BasicComputation;
 import org.apache.giraph.graph.Vertex;
 import org.apache.giraph.job.GiraphJob;
 import org.apache.hadoop.io.DoubleWritable;
@@ -47,11 +50,12 @@ public class TestMaxSuperstep extends BspCase {
    * Simple test vertex class that will run forever (voteToHalt is never
    * called).
    */
-  public static class InfiniteLoopVertex extends Vertex<LongWritable,
-      DoubleWritable, FloatWritable, DoubleWritable> {
+  public static class InfiniteLoopComputation extends BasicComputation<
+      LongWritable, DoubleWritable, FloatWritable, DoubleWritable> {
     @Override
-    public void compute(Iterable<DoubleWritable> messages) throws IOException {
-      // Do nothing, run forever!
+    public void compute(
+        Vertex<LongWritable, DoubleWritable, FloatWritable> vertex,
+        Iterable<DoubleWritable> messages) throws IOException {
     }
   }
 
@@ -67,7 +71,7 @@ public class TestMaxSuperstep extends BspCase {
   public void testMaxSuperstep()
           throws IOException, InterruptedException, ClassNotFoundException {
     GiraphConfiguration conf = new GiraphConfiguration();
-    conf.setVertexClass(InfiniteLoopVertex.class);
+    conf.setComputationClass(InfiniteLoopComputation.class);
     conf.setVertexInputFormatClass(SimplePageRankVertexInputFormat.class);
     conf.setVertexOutputFormatClass(SimplePageRankVertexOutputFormat.class);
     GiraphJob job = prepareJob(getCallingMethodName(), conf,

http://git-wip-us.apache.org/repos/asf/giraph/blob/8811165e/giraph-examples/src/test/java/org/apache/giraph/TestMutateGraph.java
----------------------------------------------------------------------
diff --git a/giraph-examples/src/test/java/org/apache/giraph/TestMutateGraph.java b/giraph-examples/src/test/java/org/apache/giraph/TestMutateGraph.java
index da85fc4..91252f3 100644
--- a/giraph-examples/src/test/java/org/apache/giraph/TestMutateGraph.java
+++ b/giraph-examples/src/test/java/org/apache/giraph/TestMutateGraph.java
@@ -19,9 +19,9 @@
 package org.apache.giraph;
 
 import org.apache.giraph.conf.GiraphConfiguration;
-import org.apache.giraph.examples.SimpleMutateGraphVertex;
-import org.apache.giraph.examples.SimplePageRankVertex.SimplePageRankVertexInputFormat;
-import org.apache.giraph.examples.SimplePageRankVertex.SimplePageRankVertexOutputFormat;
+import org.apache.giraph.examples.SimpleMutateGraphComputation;
+import org.apache.giraph.examples.SimplePageRankComputation.SimplePageRankVertexInputFormat;
+import org.apache.giraph.examples.SimplePageRankComputation.SimplePageRankVertexOutputFormat;
 import org.apache.giraph.job.GiraphJob;
 import org.junit.Test;
 
@@ -48,11 +48,11 @@ public class TestMutateGraph extends BspCase {
   public void testMutateGraph()
           throws IOException, InterruptedException, ClassNotFoundException {
     GiraphConfiguration conf = new GiraphConfiguration();
-    conf.setVertexClass(SimpleMutateGraphVertex.class);
+    conf.setComputationClass(SimpleMutateGraphComputation.class);
     conf.setVertexInputFormatClass(SimplePageRankVertexInputFormat.class);
     conf.setVertexOutputFormatClass(SimplePageRankVertexOutputFormat.class);
     conf.setWorkerContextClass(
-        SimpleMutateGraphVertex.SimpleMutateGraphVertexWorkerContext.class);
+        SimpleMutateGraphComputation.SimpleMutateGraphVertexWorkerContext.class);
     GiraphJob job = prepareJob(getCallingMethodName(), conf,
         getTempPath(getCallingMethodName()));
     assertTrue(job.run(true));

http://git-wip-us.apache.org/repos/asf/giraph/blob/8811165e/giraph-examples/src/test/java/org/apache/giraph/TestNotEnoughMapTasks.java
----------------------------------------------------------------------
diff --git a/giraph-examples/src/test/java/org/apache/giraph/TestNotEnoughMapTasks.java b/giraph-examples/src/test/java/org/apache/giraph/TestNotEnoughMapTasks.java
index 6da9c50..af16bb6 100644
--- a/giraph-examples/src/test/java/org/apache/giraph/TestNotEnoughMapTasks.java
+++ b/giraph-examples/src/test/java/org/apache/giraph/TestNotEnoughMapTasks.java
@@ -19,9 +19,9 @@
 package org.apache.giraph;
 
 import org.apache.giraph.conf.GiraphConfiguration;
-import org.apache.giraph.examples.SimpleCheckpointVertex;
-import org.apache.giraph.examples.SimpleSuperstepVertex.SimpleSuperstepVertexInputFormat;
-import org.apache.giraph.examples.SimpleSuperstepVertex.SimpleSuperstepVertexOutputFormat;
+import org.apache.giraph.examples.SimpleCheckpoint;
+import org.apache.giraph.examples.SimpleSuperstepComputation.SimpleSuperstepVertexInputFormat;
+import org.apache.giraph.examples.SimpleSuperstepComputation.SimpleSuperstepVertexOutputFormat;
 import org.apache.giraph.job.GiraphJob;
 import org.apache.hadoop.fs.Path;
 import org.junit.Test;
@@ -56,8 +56,8 @@ public class TestNotEnoughMapTasks extends BspCase {
     }
     Path outputPath = getTempPath(getCallingMethodName());
     GiraphConfiguration conf = new GiraphConfiguration();
-    conf.setVertexClass(
-        SimpleCheckpointVertex.SimpleCheckpointComputation.class);
+    conf.setComputationClass(
+        SimpleCheckpoint.SimpleCheckpointComputation.class);
     conf.setVertexInputFormatClass(SimpleSuperstepVertexInputFormat.class);
     conf.setVertexOutputFormatClass(SimpleSuperstepVertexOutputFormat.class);
     GiraphJob job = prepareJob(getCallingMethodName(), conf, outputPath);

http://git-wip-us.apache.org/repos/asf/giraph/blob/8811165e/giraph-examples/src/test/java/org/apache/giraph/TestPartitionContext.java
----------------------------------------------------------------------
diff --git a/giraph-examples/src/test/java/org/apache/giraph/TestPartitionContext.java b/giraph-examples/src/test/java/org/apache/giraph/TestPartitionContext.java
deleted file mode 100644
index 4b042df..0000000
--- a/giraph-examples/src/test/java/org/apache/giraph/TestPartitionContext.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.giraph;
-
-import org.apache.giraph.conf.GiraphConfiguration;
-import org.apache.giraph.conf.GiraphConstants;
-import org.apache.giraph.examples.GeneratedVertexReader;
-import org.apache.giraph.examples.PartitionContextTestVertex;
-import org.apache.giraph.examples.SimplePageRankVertex;
-import org.apache.giraph.job.GiraphJob;
-import org.junit.Test;
-
-import java.io.IOException;
-
-import static org.junit.Assert.assertTrue;
-
-public class TestPartitionContext extends BspCase {
-  public TestPartitionContext() {
-    super(TestPartitionContext.class.getName());
-  }
-
-  @Test
-  public void testPartitionContext() throws IOException,
-      ClassNotFoundException, InterruptedException {
-    if (runningInDistributedMode()) {
-      System.out.println(
-          "testComputeContext: Ignore this test in distributed mode.");
-      return;
-    }
-    GiraphConfiguration conf = new GiraphConfiguration();
-    conf.setVertexClass(PartitionContextTestVertex.class);
-    conf.setVertexInputFormatClass(
-        SimplePageRankVertex.SimplePageRankVertexInputFormat.class);
-    conf.setWorkerContextClass(
-        PartitionContextTestVertex.TestPartitionContextWorkerContext.class);
-    conf.setPartitionContextClass(
-        PartitionContextTestVertex.TestPartitionContextPartitionContext.class);
-    GiraphJob job = prepareJob(getCallingMethodName(), conf);
-    // Use multithreading
-    job.getConfiguration().setNumComputeThreads(
-        PartitionContextTestVertex.NUM_COMPUTE_THREADS);
-    // Increase the number of vertices
-    job.getConfiguration().setInt(
-        GeneratedVertexReader.READER_VERTICES,
-        PartitionContextTestVertex.NUM_VERTICES);
-    // Increase the number of partitions
-    GiraphConstants.USER_PARTITION_COUNT.set(job.getConfiguration(),
-        PartitionContextTestVertex.NUM_PARTITIONS);
-    assertTrue(job.run(true));
-  }
-}

http://git-wip-us.apache.org/repos/asf/giraph/blob/8811165e/giraph-examples/src/test/java/org/apache/giraph/aggregators/TestAggregatorsHandling.java
----------------------------------------------------------------------
diff --git a/giraph-examples/src/test/java/org/apache/giraph/aggregators/TestAggregatorsHandling.java b/giraph-examples/src/test/java/org/apache/giraph/aggregators/TestAggregatorsHandling.java
index 53cdeab..6d22800 100644
--- a/giraph-examples/src/test/java/org/apache/giraph/aggregators/TestAggregatorsHandling.java
+++ b/giraph-examples/src/test/java/org/apache/giraph/aggregators/TestAggregatorsHandling.java
@@ -23,9 +23,9 @@ import org.apache.giraph.comm.aggregators.AggregatorUtils;
 import org.apache.giraph.conf.GiraphConfiguration;
 import org.apache.giraph.conf.GiraphConstants;
 import org.apache.giraph.conf.ImmutableClassesGiraphConfiguration;
-import org.apache.giraph.examples.AggregatorsTestVertex;
-import org.apache.giraph.examples.SimpleCheckpointVertex;
-import org.apache.giraph.examples.SimplePageRankVertex;
+import org.apache.giraph.examples.AggregatorsTestComputation;
+import org.apache.giraph.examples.SimpleCheckpoint;
+import org.apache.giraph.examples.SimplePageRankComputation;
 import org.apache.giraph.job.GiraphJob;
 import org.apache.giraph.master.MasterAggregatorHandler;
 import org.apache.hadoop.fs.Path;
@@ -75,12 +75,12 @@ public class TestAggregatorsHandling extends BspCase {
   public void testAggregatorsHandling() throws IOException,
       ClassNotFoundException, InterruptedException {
     GiraphConfiguration conf = new GiraphConfiguration();
-    conf.setVertexClass(AggregatorsTestVertex.class);
+    conf.setComputationClass(AggregatorsTestComputation.class);
     conf.setVertexInputFormatClass(
-        SimplePageRankVertex.SimplePageRankVertexInputFormat.class);
+        SimplePageRankComputation.SimplePageRankVertexInputFormat.class);
     GiraphJob job = prepareJob(getCallingMethodName(), conf);
     job.getConfiguration().setMasterComputeClass(
-        AggregatorsTestVertex.AggregatorsTestMasterCompute.class);
+        AggregatorsTestComputation.AggregatorsTestMasterCompute.class);
     // test with aggregators split in a few requests
     job.getConfiguration().setInt(
         AggregatorUtils.MAX_BYTES_PER_AGGREGATOR_REQUEST, 50);
@@ -155,11 +155,11 @@ public class TestAggregatorsHandling extends BspCase {
     Path checkpointsDir = getTempPath("checkPointsForTesting");
     Path outputPath = getTempPath(getCallingMethodName());
     GiraphConfiguration conf = new GiraphConfiguration();
-    conf.setVertexClass(AggregatorsTestVertex.class);
+    conf.setComputationClass(AggregatorsTestComputation.class);
     conf.setMasterComputeClass(
-        AggregatorsTestVertex.AggregatorsTestMasterCompute.class);
+        AggregatorsTestComputation.AggregatorsTestMasterCompute.class);
     conf.setVertexInputFormatClass(
-        SimplePageRankVertex.SimplePageRankVertexInputFormat.class);
+        SimplePageRankComputation.SimplePageRankVertexInputFormat.class);
     GiraphJob job = prepareJob(getCallingMethodName(), conf, outputPath);
 
     GiraphConfiguration configuration = job.getConfiguration();
@@ -174,15 +174,15 @@ public class TestAggregatorsHandling extends BspCase {
         "superstep 4 with checkpoint path = " + checkpointsDir);
     outputPath = getTempPath(getCallingMethodName() + "Restarted");
     conf = new GiraphConfiguration();
-    conf.setVertexClass(AggregatorsTestVertex.class);
+    conf.setComputationClass(AggregatorsTestComputation.class);
     conf.setMasterComputeClass(
-        AggregatorsTestVertex.AggregatorsTestMasterCompute.class);
+        AggregatorsTestComputation.AggregatorsTestMasterCompute.class);
     conf.setVertexInputFormatClass(
-        SimplePageRankVertex.SimplePageRankVertexInputFormat.class);
+        SimplePageRankComputation.SimplePageRankVertexInputFormat.class);
     GiraphJob restartedJob = prepareJob(getCallingMethodName() + "Restarted",
         conf, outputPath);
     job.getConfiguration().setMasterComputeClass(
-        SimpleCheckpointVertex.SimpleCheckpointVertexMasterCompute.class);
+        SimpleCheckpoint.SimpleCheckpointVertexMasterCompute.class);
     GiraphConfiguration restartedJobConf = restartedJob.getConfiguration();
     GiraphConstants.CHECKPOINT_DIRECTORY.set(restartedJobConf,
         checkpointsDir.toString());

http://git-wip-us.apache.org/repos/asf/giraph/blob/8811165e/giraph-examples/src/test/java/org/apache/giraph/examples/ConnectedComponentsComputationTest.java
----------------------------------------------------------------------
diff --git a/giraph-examples/src/test/java/org/apache/giraph/examples/ConnectedComponentsComputationTest.java b/giraph-examples/src/test/java/org/apache/giraph/examples/ConnectedComponentsComputationTest.java
new file mode 100644
index 0000000..7d326da
--- /dev/null
+++ b/giraph-examples/src/test/java/org/apache/giraph/examples/ConnectedComponentsComputationTest.java
@@ -0,0 +1,120 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.giraph.examples;
+
+import org.apache.giraph.combiner.MinimumIntCombiner;
+import org.apache.giraph.conf.GiraphConfiguration;
+import org.apache.giraph.edge.ByteArrayEdges;
+import org.apache.giraph.io.formats.IdWithValueTextOutputFormat;
+import org.apache.giraph.io.formats.IntIntNullTextInputFormat;
+import org.apache.giraph.utils.InternalVertexRunner;
+import org.junit.Test;
+
+import com.google.common.base.Splitter;
+import com.google.common.collect.HashMultimap;
+import com.google.common.collect.Iterables;
+import com.google.common.collect.SetMultimap;
+
+import java.util.Set;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+/**
+ *  Tests for {@link ConnectedComponentsComputation}
+ */
+public class ConnectedComponentsComputationTest {
+
+    /**
+     * A local integration test on toy data
+     */
+    @Test
+    public void testToyData() throws Exception {
+
+        // a small graph with three components
+        String[] graph = new String[] {
+                "1 2 3",
+                "2 1 4 5",
+                "3 1 4",
+                "4 2 3 5 13",
+                "5 2 4 12 13",
+                "12 5 13",
+                "13 4 5 12",
+
+                "6 7 8",
+                "7 6 10 11",
+                "8 6 10",
+                "10 7 8 11",
+                "11 7 10",
+
+                "9" };
+
+        GiraphConfiguration conf = new GiraphConfiguration();
+        conf.setComputationClass(ConnectedComponentsComputation.class);
+        conf.setOutEdgesClass(ByteArrayEdges.class);
+        conf.setCombinerClass(MinimumIntCombiner.class);
+        conf.setVertexInputFormatClass(IntIntNullTextInputFormat.class);
+        conf.setVertexOutputFormatClass(IdWithValueTextOutputFormat.class);
+
+        // run internally
+        Iterable<String> results = InternalVertexRunner.run(conf, graph);
+
+        SetMultimap<Integer,Integer> components = parseResults(results);
+
+        Set<Integer> componentIDs = components.keySet();
+        assertEquals(3, componentIDs.size());
+        assertTrue(componentIDs.contains(1));
+        assertTrue(componentIDs.contains(6));
+        assertTrue(componentIDs.contains(9));
+
+        Set<Integer> componentOne = components.get(1);
+        assertEquals(7, componentOne.size());
+        assertTrue(componentOne.contains(1));
+        assertTrue(componentOne.contains(2));
+        assertTrue(componentOne.contains(3));
+        assertTrue(componentOne.contains(4));
+        assertTrue(componentOne.contains(5));
+        assertTrue(componentOne.contains(12));
+        assertTrue(componentOne.contains(13));
+
+        Set<Integer> componentTwo = components.get(6);
+        assertEquals(5, componentTwo.size());
+        assertTrue(componentTwo.contains(6));
+        assertTrue(componentTwo.contains(7));
+        assertTrue(componentTwo.contains(8));
+        assertTrue(componentTwo.contains(10));
+        assertTrue(componentTwo.contains(11));
+
+        Set<Integer> componentThree = components.get(9);
+        assertEquals(1, componentThree.size());
+        assertTrue(componentThree.contains(9));
+    }
+
+    private SetMultimap<Integer,Integer> parseResults(
+            Iterable<String> results) {
+        SetMultimap<Integer,Integer> components = HashMultimap.create();
+        for (String result : results) {
+            Iterable<String> parts = Splitter.on('\t').split(result);
+            int vertex = Integer.parseInt(Iterables.get(parts, 0));
+            int component = Integer.parseInt(Iterables.get(parts, 1));
+            components.put(component, vertex);
+        }
+        return components;
+    }
+}

http://git-wip-us.apache.org/repos/asf/giraph/blob/8811165e/giraph-examples/src/test/java/org/apache/giraph/examples/ConnectedComponentsComputationTestInMemory.java
----------------------------------------------------------------------
diff --git a/giraph-examples/src/test/java/org/apache/giraph/examples/ConnectedComponentsComputationTestInMemory.java b/giraph-examples/src/test/java/org/apache/giraph/examples/ConnectedComponentsComputationTestInMemory.java
new file mode 100644
index 0000000..b94f8dc
--- /dev/null
+++ b/giraph-examples/src/test/java/org/apache/giraph/examples/ConnectedComponentsComputationTestInMemory.java
@@ -0,0 +1,127 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.giraph.examples;
+
+import org.apache.giraph.combiner.MinimumIntCombiner;
+import org.apache.giraph.conf.GiraphConfiguration;
+import org.apache.giraph.edge.ByteArrayEdges;
+import org.apache.giraph.graph.Vertex;
+import org.apache.giraph.utils.InternalVertexRunner;
+import org.apache.giraph.utils.TestGraph;
+import org.apache.hadoop.io.IntWritable;
+import org.apache.hadoop.io.NullWritable;
+import org.junit.Test;
+
+import com.google.common.collect.HashMultimap;
+import com.google.common.collect.SetMultimap;
+
+import java.util.AbstractMap.SimpleEntry;
+import java.util.Map.Entry;
+import java.util.Set;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+/**
+ *  Tests for {@link ConnectedComponentsComputation}
+ */
+public class ConnectedComponentsComputationTestInMemory {
+  public static Entry<IntWritable, NullWritable>[] makeEdges(int... args){
+    Entry<IntWritable, NullWritable> result[] =
+      new Entry[args.length];
+    for (int i=0; i<args.length; i++){
+      result[i] = new SimpleEntry<IntWritable, NullWritable>(
+          new IntWritable(args[i]), NullWritable.get());
+    }
+    return result;
+  }
+  /**
+   * A local integration test on toy data
+   */
+  @Test
+  public void testToyData() throws Exception {
+    GiraphConfiguration conf = new GiraphConfiguration();
+    conf.setComputationClass(ConnectedComponentsComputation.class);
+    conf.setOutEdgesClass(ByteArrayEdges.class);
+    conf.setCombinerClass(MinimumIntCombiner.class);
+
+    TestGraph<IntWritable, IntWritable, NullWritable> graph =
+      new TestGraph<IntWritable, IntWritable, NullWritable> (conf);
+    // a small graph with three components
+    graph.addVertex(new IntWritable(1), new IntWritable(1), makeEdges(2, 3))
+      .addVertex(new IntWritable(2), new IntWritable(2), makeEdges(1, 4, 5))
+      .addVertex(new IntWritable(3), new IntWritable(3), makeEdges(1, 4))
+      .addVertex(new IntWritable(4), new IntWritable(4),
+          makeEdges(2, 3, 5, 13))
+      .addVertex(new IntWritable(5), new IntWritable(5),
+          makeEdges(2, 4, 12, 13))
+      .addVertex(new IntWritable(12), new IntWritable(12), makeEdges(5, 13))
+      .addVertex(new IntWritable(13), new IntWritable(13), makeEdges(4, 5, 12))
+      .addVertex(new IntWritable(6), new IntWritable(6), makeEdges(7, 8))
+      .addVertex(new IntWritable(7), new IntWritable(7), makeEdges(6, 10, 11))
+      .addVertex(new IntWritable(8), new IntWritable(8), makeEdges(6, 10))
+      .addVertex(new IntWritable(10), new IntWritable(10), makeEdges(7, 8, 11))
+      .addVertex(new IntWritable(11), new IntWritable(11), makeEdges(7, 10))
+      .addVertex(new IntWritable(9), new IntWritable(9));
+
+    // run internally
+    TestGraph<IntWritable, IntWritable, NullWritable> results =
+      InternalVertexRunner.run(conf, graph);
+
+    SetMultimap<Integer,Integer> components = parseResults(results);
+
+    Set<Integer> componentIDs = components.keySet();
+    assertEquals(3, componentIDs.size());
+    assertTrue(componentIDs.contains(1));
+    assertTrue(componentIDs.contains(6));
+    assertTrue(componentIDs.contains(9));
+
+    Set<Integer> componentOne = components.get(1);
+    assertEquals(7, componentOne.size());
+    assertTrue(componentOne.contains(1));
+    assertTrue(componentOne.contains(2));
+    assertTrue(componentOne.contains(3));
+    assertTrue(componentOne.contains(4));
+    assertTrue(componentOne.contains(5));
+    assertTrue(componentOne.contains(12));
+    assertTrue(componentOne.contains(13));
+
+    Set<Integer> componentTwo = components.get(6);
+    assertEquals(5, componentTwo.size());
+    assertTrue(componentTwo.contains(6));
+    assertTrue(componentTwo.contains(7));
+    assertTrue(componentTwo.contains(8));
+    assertTrue(componentTwo.contains(10));
+    assertTrue(componentTwo.contains(11));
+
+    Set<Integer> componentThree = components.get(9);
+    assertEquals(1, componentThree.size());
+    assertTrue(componentThree.contains(9));
+  }
+
+  private SetMultimap<Integer,Integer> parseResults(
+    TestGraph<IntWritable, IntWritable, NullWritable> results) {
+    SetMultimap<Integer,Integer> components = HashMultimap.create();
+    for (Vertex<IntWritable, IntWritable, NullWritable> vertex : results) {
+      int component = vertex.getValue().get();
+      components.put(component, vertex.getId().get());
+    }
+    return components;
+  }
+}

http://git-wip-us.apache.org/repos/asf/giraph/blob/8811165e/giraph-examples/src/test/java/org/apache/giraph/examples/ConnectedComponentsVertexTest.java
----------------------------------------------------------------------
diff --git a/giraph-examples/src/test/java/org/apache/giraph/examples/ConnectedComponentsVertexTest.java b/giraph-examples/src/test/java/org/apache/giraph/examples/ConnectedComponentsVertexTest.java
deleted file mode 100644
index 5d71259..0000000
--- a/giraph-examples/src/test/java/org/apache/giraph/examples/ConnectedComponentsVertexTest.java
+++ /dev/null
@@ -1,120 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.giraph.examples;
-
-import org.apache.giraph.combiner.MinimumIntCombiner;
-import org.apache.giraph.conf.GiraphConfiguration;
-import org.apache.giraph.edge.ByteArrayEdges;
-import org.apache.giraph.io.formats.IdWithValueTextOutputFormat;
-import org.apache.giraph.io.formats.IntIntNullTextInputFormat;
-import org.apache.giraph.utils.InternalVertexRunner;
-import org.junit.Test;
-
-import com.google.common.base.Splitter;
-import com.google.common.collect.HashMultimap;
-import com.google.common.collect.Iterables;
-import com.google.common.collect.SetMultimap;
-
-import java.util.Set;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-
-/**
- *  Tests for {@link ConnectedComponentsVertex}
- */
-public class ConnectedComponentsVertexTest {
-
-    /**
-     * A local integration test on toy data
-     */
-    @Test
-    public void testToyData() throws Exception {
-
-        // a small graph with three components
-        String[] graph = new String[] {
-                "1 2 3",
-                "2 1 4 5",
-                "3 1 4",
-                "4 2 3 5 13",
-                "5 2 4 12 13",
-                "12 5 13",
-                "13 4 5 12",
-
-                "6 7 8",
-                "7 6 10 11",
-                "8 6 10",
-                "10 7 8 11",
-                "11 7 10",
-
-                "9" };
-
-        GiraphConfiguration conf = new GiraphConfiguration();
-        conf.setVertexClass(ConnectedComponentsVertex.class);
-        conf.setOutEdgesClass(ByteArrayEdges.class);
-        conf.setCombinerClass(MinimumIntCombiner.class);
-        conf.setVertexInputFormatClass(IntIntNullTextInputFormat.class);
-        conf.setVertexOutputFormatClass(IdWithValueTextOutputFormat.class);
-
-        // run internally
-        Iterable<String> results = InternalVertexRunner.run(conf, graph);
-
-        SetMultimap<Integer,Integer> components = parseResults(results);
-
-        Set<Integer> componentIDs = components.keySet();
-        assertEquals(3, componentIDs.size());
-        assertTrue(componentIDs.contains(1));
-        assertTrue(componentIDs.contains(6));
-        assertTrue(componentIDs.contains(9));
-
-        Set<Integer> componentOne = components.get(1);
-        assertEquals(7, componentOne.size());
-        assertTrue(componentOne.contains(1));
-        assertTrue(componentOne.contains(2));
-        assertTrue(componentOne.contains(3));
-        assertTrue(componentOne.contains(4));
-        assertTrue(componentOne.contains(5));
-        assertTrue(componentOne.contains(12));
-        assertTrue(componentOne.contains(13));
-
-        Set<Integer> componentTwo = components.get(6);
-        assertEquals(5, componentTwo.size());
-        assertTrue(componentTwo.contains(6));
-        assertTrue(componentTwo.contains(7));
-        assertTrue(componentTwo.contains(8));
-        assertTrue(componentTwo.contains(10));
-        assertTrue(componentTwo.contains(11));
-
-        Set<Integer> componentThree = components.get(9);
-        assertEquals(1, componentThree.size());
-        assertTrue(componentThree.contains(9));
-    }
-
-    private SetMultimap<Integer,Integer> parseResults(
-            Iterable<String> results) {
-        SetMultimap<Integer,Integer> components = HashMultimap.create();
-        for (String result : results) {
-            Iterable<String> parts = Splitter.on('\t').split(result);
-            int vertex = Integer.parseInt(Iterables.get(parts, 0));
-            int component = Integer.parseInt(Iterables.get(parts, 1));
-            components.put(component, vertex);
-        }
-        return components;
-    }
-}

http://git-wip-us.apache.org/repos/asf/giraph/blob/8811165e/giraph-examples/src/test/java/org/apache/giraph/examples/ConnectedComponentsVertexTestInMemory.java
----------------------------------------------------------------------
diff --git a/giraph-examples/src/test/java/org/apache/giraph/examples/ConnectedComponentsVertexTestInMemory.java b/giraph-examples/src/test/java/org/apache/giraph/examples/ConnectedComponentsVertexTestInMemory.java
deleted file mode 100644
index e4c029c..0000000
--- a/giraph-examples/src/test/java/org/apache/giraph/examples/ConnectedComponentsVertexTestInMemory.java
+++ /dev/null
@@ -1,130 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.giraph.examples;
-
-import org.apache.giraph.combiner.MinimumIntCombiner;
-import org.apache.giraph.conf.GiraphConfiguration;
-import org.apache.giraph.edge.ByteArrayEdges;
-import org.apache.giraph.graph.Vertex;
-import org.apache.giraph.utils.InternalVertexRunner;
-import org.apache.giraph.utils.TestGraph;
-import org.apache.hadoop.io.IntWritable;
-import org.apache.hadoop.io.NullWritable;
-import org.junit.Test;
-
-import com.google.common.collect.HashMultimap;
-import com.google.common.collect.SetMultimap;
-
-import java.util.AbstractMap.SimpleEntry;
-import java.util.Map.Entry;
-import java.util.Set;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-
-/**
- *  Tests for {@link ConnectedComponentsVertex}
- */
-public class ConnectedComponentsVertexTestInMemory {
-  public static Entry<IntWritable, NullWritable>[] makeEdges(int... args){
-    Entry<IntWritable, NullWritable> result[] =
-      new Entry[args.length];
-    for (int i=0; i<args.length; i++){
-      result[i] = new SimpleEntry<IntWritable, NullWritable>(
-          new IntWritable(args[i]), NullWritable.get());
-    }
-    return result;
-  }
-  /**
-   * A local integration test on toy data
-   */
-  @Test
-  public void testToyData() throws Exception {
-    GiraphConfiguration conf = new GiraphConfiguration();
-    conf.setVertexClass(ConnectedComponentsVertex.class);
-    conf.setOutEdgesClass(ByteArrayEdges.class);
-    conf.setCombinerClass(MinimumIntCombiner.class);
-
-    TestGraph<IntWritable, IntWritable, NullWritable, IntWritable> graph =
-      new TestGraph<IntWritable, IntWritable, NullWritable, IntWritable> (conf);
-    // a small graph with three components
-    graph.addVertex(new IntWritable(1), new IntWritable(1), makeEdges(2, 3))
-      .addVertex(new IntWritable(2), new IntWritable(2), makeEdges(1, 4, 5))
-      .addVertex(new IntWritable(3), new IntWritable(3), makeEdges(1, 4))
-      .addVertex(new IntWritable(4), new IntWritable(4),
-          makeEdges(2, 3, 5, 13))
-      .addVertex(new IntWritable(5), new IntWritable(5),
-          makeEdges(2, 4, 12, 13))
-      .addVertex(new IntWritable(12), new IntWritable(12), makeEdges(5, 13))
-      .addVertex(new IntWritable(13), new IntWritable(13), makeEdges(4, 5, 12))
-      .addVertex(new IntWritable(6), new IntWritable(6), makeEdges(7, 8))
-      .addVertex(new IntWritable(7), new IntWritable(7), makeEdges(6, 10, 11))
-      .addVertex(new IntWritable(8), new IntWritable(8), makeEdges(6, 10))
-      .addVertex(new IntWritable(10), new IntWritable(10), makeEdges(7, 8, 11))
-      .addVertex(new IntWritable(11), new IntWritable(11), makeEdges(7, 10))
-      .addVertex(new IntWritable(9), new IntWritable(9));
-
-    // run internally
-    TestGraph<IntWritable, IntWritable, NullWritable, IntWritable> results =
-      InternalVertexRunner.run(conf, graph);
-
-    SetMultimap<Integer,Integer> components = parseResults(results);
-
-    Set<Integer> componentIDs = components.keySet();
-    assertEquals(3, componentIDs.size());
-    assertTrue(componentIDs.contains(1));
-    assertTrue(componentIDs.contains(6));
-    assertTrue(componentIDs.contains(9));
-
-    Set<Integer> componentOne = components.get(1);
-    assertEquals(7, componentOne.size());
-    assertTrue(componentOne.contains(1));
-    assertTrue(componentOne.contains(2));
-    assertTrue(componentOne.contains(3));
-    assertTrue(componentOne.contains(4));
-    assertTrue(componentOne.contains(5));
-    assertTrue(componentOne.contains(12));
-    assertTrue(componentOne.contains(13));
-
-    Set<Integer> componentTwo = components.get(6);
-    assertEquals(5, componentTwo.size());
-    assertTrue(componentTwo.contains(6));
-    assertTrue(componentTwo.contains(7));
-    assertTrue(componentTwo.contains(8));
-    assertTrue(componentTwo.contains(10));
-    assertTrue(componentTwo.contains(11));
-
-    Set<Integer> componentThree = components.get(9);
-    assertEquals(1, componentThree.size());
-    assertTrue(componentThree.contains(9));
-  }
-
-  private SetMultimap<Integer,Integer> parseResults(
-    TestGraph<IntWritable, IntWritable, NullWritable, IntWritable> results) {
-    SetMultimap<Integer,Integer> components = HashMultimap.create();
-    for (Vertex<IntWritable,
-                IntWritable,
-                NullWritable,
-                IntWritable> vertex: results) {
-      int component = vertex.getValue().get();
-      components.put(component, vertex.getId().get());
-    }
-    return components;
-  }
-}

http://git-wip-us.apache.org/repos/asf/giraph/blob/8811165e/giraph-examples/src/test/java/org/apache/giraph/examples/PageRankComputationTest.java
----------------------------------------------------------------------
diff --git a/giraph-examples/src/test/java/org/apache/giraph/examples/PageRankComputationTest.java b/giraph-examples/src/test/java/org/apache/giraph/examples/PageRankComputationTest.java
new file mode 100644
index 0000000..dcdef19
--- /dev/null
+++ b/giraph-examples/src/test/java/org/apache/giraph/examples/PageRankComputationTest.java
@@ -0,0 +1,79 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.giraph.examples;
+
+import org.apache.giraph.conf.GiraphConfiguration;
+import org.apache.giraph.edge.ByteArrayEdges;
+import org.apache.giraph.utils.InternalVertexRunner;
+import org.junit.Test;
+
+import java.util.Map;
+
+import static org.junit.Assert.assertEquals;
+
+
+/**
+ * Tests for {@link PageRankComputation}
+ */
+public class PageRankComputationTest {
+
+  /**
+   * A local integration test on toy data
+   */
+  @Test
+  public void testToyData() throws Exception {
+
+    // A small graph
+    String[] graph = new String[] {
+      "1 4 2 3",
+      "2 1",
+      "4 3 2",
+      "5 2 4"
+    };
+
+    GiraphConfiguration conf = new GiraphConfiguration();
+    conf.setInt(RandomWalkWithRestartComputation.MAX_SUPERSTEPS, 50);
+    conf.setFloat(
+        RandomWalkWithRestartComputation.TELEPORTATION_PROBABILITY, 0.15f);
+    conf.setComputationClass(PageRankComputation.class);
+    conf.setOutEdgesClass(ByteArrayEdges.class);
+    conf.setVertexInputFormatClass(LongDoubleNullTextInputFormat.class);
+    conf.setVertexOutputFormatClass(
+        VertexWithDoubleValueNullEdgeTextOutputFormat.class);
+    conf.setWorkerContextClass(RandomWalkWorkerContext.class);
+    conf.setMasterComputeClass(RandomWalkVertexMasterCompute.class);
+    // Run internally
+    Iterable<String> results = InternalVertexRunner.run(conf, graph);
+
+    Map<Long, Double> steadyStateProbabilities =
+        RandomWalkTestUtils.parseSteadyStateProbabilities(results);
+
+    assertEquals(0.28159076008518047, steadyStateProbabilities.get(1l),
+        RandomWalkTestUtils.EPSILON);
+    assertEquals(0.2514648601529863, steadyStateProbabilities.get(2l),
+        RandomWalkTestUtils.EPSILON);
+    assertEquals(0.22262961972286327, steadyStateProbabilities.get(3l),
+        RandomWalkTestUtils.EPSILON);
+    assertEquals(0.17646783276703806, steadyStateProbabilities.get(4l),
+        RandomWalkTestUtils.EPSILON);
+    assertEquals(0.06784692727193153, steadyStateProbabilities.get(5l),
+        RandomWalkTestUtils.EPSILON);
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/giraph/blob/8811165e/giraph-examples/src/test/java/org/apache/giraph/examples/PageRankVertexTest.java
----------------------------------------------------------------------
diff --git a/giraph-examples/src/test/java/org/apache/giraph/examples/PageRankVertexTest.java b/giraph-examples/src/test/java/org/apache/giraph/examples/PageRankVertexTest.java
deleted file mode 100644
index 2a39291..0000000
--- a/giraph-examples/src/test/java/org/apache/giraph/examples/PageRankVertexTest.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.giraph.examples;
-
-import org.apache.giraph.conf.GiraphConfiguration;
-import org.apache.giraph.edge.ByteArrayEdges;
-import org.apache.giraph.utils.InternalVertexRunner;
-import org.junit.Test;
-
-import java.util.Map;
-
-import static org.junit.Assert.assertEquals;
-
-
-/**
- * Tests for {@link PageRankVertex}
- */
-public class PageRankVertexTest {
-
-  /**
-   * A local integration test on toy data
-   */
-  @Test
-  public void testToyData() throws Exception {
-
-    // A small graph
-    String[] graph = new String[] {
-      "1 4 2 3",
-      "2 1",
-      "4 3 2",
-      "5 2 4"
-    };
-
-    GiraphConfiguration conf = new GiraphConfiguration();
-    conf.setInt(RandomWalkWithRestartVertex.MAX_SUPERSTEPS, 50);
-    conf.setFloat(RandomWalkWithRestartVertex.TELEPORTATION_PROBABILITY, 0.15f);
-    conf.setVertexClass(PageRankVertex.class);
-    conf.setOutEdgesClass(ByteArrayEdges.class);
-    conf.setVertexInputFormatClass(LongDoubleNullTextInputFormat.class);
-    conf.setVertexOutputFormatClass(
-        VertexWithDoubleValueNullEdgeTextOutputFormat.class);
-    conf.setWorkerContextClass(RandomWalkWorkerContext.class);
-    conf.setMasterComputeClass(RandomWalkVertexMasterCompute.class);
-    // Run internally
-    Iterable<String> results = InternalVertexRunner.run(conf, graph);
-
-    Map<Long, Double> steadyStateProbabilities =
-        RandomWalkTestUtils.parseSteadyStateProbabilities(results);
-
-    assertEquals(0.28159076008518047, steadyStateProbabilities.get(1l),
-        RandomWalkTestUtils.EPSILON);
-    assertEquals(0.2514648601529863, steadyStateProbabilities.get(2l),
-        RandomWalkTestUtils.EPSILON);
-    assertEquals(0.22262961972286327, steadyStateProbabilities.get(3l),
-        RandomWalkTestUtils.EPSILON);
-    assertEquals(0.17646783276703806, steadyStateProbabilities.get(4l),
-        RandomWalkTestUtils.EPSILON);
-    assertEquals(0.06784692727193153, steadyStateProbabilities.get(5l),
-        RandomWalkTestUtils.EPSILON);
-  }
-
-}

http://git-wip-us.apache.org/repos/asf/giraph/blob/8811165e/giraph-examples/src/test/java/org/apache/giraph/examples/RandomWalkWithRestartComputationTest.java
----------------------------------------------------------------------
diff --git a/giraph-examples/src/test/java/org/apache/giraph/examples/RandomWalkWithRestartComputationTest.java b/giraph-examples/src/test/java/org/apache/giraph/examples/RandomWalkWithRestartComputationTest.java
new file mode 100644
index 0000000..ee27b71
--- /dev/null
+++ b/giraph-examples/src/test/java/org/apache/giraph/examples/RandomWalkWithRestartComputationTest.java
@@ -0,0 +1,111 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.giraph.examples;
+
+import org.apache.giraph.conf.GiraphConfiguration;
+import org.apache.giraph.edge.ByteArrayEdges;
+import org.apache.giraph.utils.InternalVertexRunner;
+import org.junit.Test;
+
+import java.util.Map;
+
+import static org.junit.Assert.assertEquals;
+
+/**
+ * Tests for {@link RandomWalkWithRestartComputation}
+ */
+public class RandomWalkWithRestartComputationTest {
+
+  /**
+   * A local integration test on toy data
+   */
+  @Test
+  public void testToyData() throws Exception {
+    // A small graph
+    String[] graph = new String[] { "12 34 56", "34 78", "56 34 78", "78 34" };
+
+    GiraphConfiguration conf = new GiraphConfiguration();
+    conf.setInt(RandomWalkWithRestartComputation.SOURCE_VERTEX, 12);
+    conf.setInt(RandomWalkWithRestartComputation.MAX_SUPERSTEPS, 30);
+    conf.setFloat(
+        RandomWalkWithRestartComputation.TELEPORTATION_PROBABILITY, 0.25f);
+    conf.setComputationClass(RandomWalkWithRestartComputation.class);
+    conf.setOutEdgesClass(ByteArrayEdges.class);
+    conf.setVertexInputFormatClass(LongDoubleDoubleTextInputFormat.class);
+    conf.setVertexOutputFormatClass(
+        VertexWithDoubleValueDoubleEdgeTextOutputFormat.class);
+    conf.setWorkerContextClass(RandomWalkWorkerContext.class);
+    conf.setMasterComputeClass(RandomWalkVertexMasterCompute.class);
+    // Run internally
+    Iterable<String> results = InternalVertexRunner.run(conf, graph);
+
+    Map<Long, Double> steadyStateProbabilities =
+        RandomWalkTestUtils.parseSteadyStateProbabilities(results);
+    // values computed with external software
+    // 0.25, 0.354872, 0.09375, 0.301377
+    assertEquals(0.25, steadyStateProbabilities.get(12L), RandomWalkTestUtils.EPSILON);
+    assertEquals(0.354872, steadyStateProbabilities.get(34L),
+        RandomWalkTestUtils.EPSILON);
+    assertEquals(0.09375, steadyStateProbabilities.get(56L), RandomWalkTestUtils.EPSILON);
+    assertEquals(0.301377, steadyStateProbabilities.get(78L),
+        RandomWalkTestUtils.EPSILON);
+  }
+
+  /**
+   * A local integration test on toy data
+   */
+  @Test
+  public void testWeightedGraph() throws Exception {
+    // A small graph
+    String[] graph =
+        new String[] { "12 34:0.1 56:0.9", "34 78:0.9 56:0.1",
+          "56 12:0.1 34:0.8 78:0.1", "78 34:1.0" };
+
+    GiraphConfiguration conf = new GiraphConfiguration();
+    conf.setInt(RandomWalkWithRestartComputation.SOURCE_VERTEX, 12);
+    conf.setInt(RandomWalkWithRestartComputation.MAX_SUPERSTEPS, 30);
+    conf.setFloat(
+        RandomWalkWithRestartComputation.TELEPORTATION_PROBABILITY, 0.15f);
+    conf.setComputationClass(RandomWalkWithRestartComputation.class);
+    conf.setOutEdgesClass(ByteArrayEdges.class);
+    conf.setVertexInputFormatClass(
+        NormalizingLongDoubleDoubleTextInputFormat.class);
+    conf.setVertexOutputFormatClass(
+        VertexWithDoubleValueDoubleEdgeTextOutputFormat.class);
+    conf.setWorkerContextClass(RandomWalkWorkerContext.class);
+    conf.setMasterComputeClass(RandomWalkVertexMasterCompute.class);
+    // Run internally
+    Iterable<String> results = InternalVertexRunner.run(conf, graph);
+
+    Map<Long, Double> steadyStateProbabilities =
+        RandomWalkTestUtils.parseSteadyStateProbabilities(results);
+    // values computed with external software
+    // 0.163365, 0.378932, 0.156886, 0.300816
+    assertEquals(0.163365, steadyStateProbabilities.get(12L),
+        RandomWalkTestUtils.EPSILON);
+    assertEquals(0.378932, steadyStateProbabilities.get(34L),
+        RandomWalkTestUtils.EPSILON);
+    assertEquals(0.156886, steadyStateProbabilities.get(56L),
+        RandomWalkTestUtils.EPSILON);
+    assertEquals(0.300816, steadyStateProbabilities.get(78L),
+        RandomWalkTestUtils.EPSILON);
+  }
+
+
+}

http://git-wip-us.apache.org/repos/asf/giraph/blob/8811165e/giraph-examples/src/test/java/org/apache/giraph/examples/RandomWalkWithRestartVertexTest.java
----------------------------------------------------------------------
diff --git a/giraph-examples/src/test/java/org/apache/giraph/examples/RandomWalkWithRestartVertexTest.java b/giraph-examples/src/test/java/org/apache/giraph/examples/RandomWalkWithRestartVertexTest.java
deleted file mode 100644
index a2a891e..0000000
--- a/giraph-examples/src/test/java/org/apache/giraph/examples/RandomWalkWithRestartVertexTest.java
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.giraph.examples;
-
-import org.apache.giraph.conf.GiraphConfiguration;
-import org.apache.giraph.edge.ByteArrayEdges;
-import org.apache.giraph.utils.InternalVertexRunner;
-import org.junit.Test;
-
-import java.util.Map;
-
-import static org.junit.Assert.assertEquals;
-
-/**
- * Tests for {@link RandomWalkWithRestartVertex}
- */
-public class RandomWalkWithRestartVertexTest {
-
-  /**
-   * A local integration test on toy data
-   */
-  @Test
-  public void testToyData() throws Exception {
-    // A small graph
-    String[] graph = new String[] { "12 34 56", "34 78", "56 34 78", "78 34" };
-
-    GiraphConfiguration conf = new GiraphConfiguration();
-    conf.setInt(RandomWalkWithRestartVertex.SOURCE_VERTEX, 12);
-    conf.setInt(RandomWalkWithRestartVertex.MAX_SUPERSTEPS, 30);
-    conf.setFloat(RandomWalkWithRestartVertex.TELEPORTATION_PROBABILITY, 0.25f);
-    conf.setVertexClass(RandomWalkWithRestartVertex.class);
-    conf.setOutEdgesClass(ByteArrayEdges.class);
-    conf.setVertexInputFormatClass(LongDoubleDoubleTextInputFormat.class);
-    conf.setVertexOutputFormatClass(
-        VertexWithDoubleValueDoubleEdgeTextOutputFormat.class);
-    conf.setWorkerContextClass(RandomWalkWorkerContext.class);
-    conf.setMasterComputeClass(RandomWalkVertexMasterCompute.class);
-    // Run internally
-    Iterable<String> results = InternalVertexRunner.run(conf, graph);
-
-    Map<Long, Double> steadyStateProbabilities =
-        RandomWalkTestUtils.parseSteadyStateProbabilities(results);
-    // values computed with external software
-    // 0.25, 0.354872, 0.09375, 0.301377
-    assertEquals(0.25, steadyStateProbabilities.get(12L), RandomWalkTestUtils.EPSILON);
-    assertEquals(0.354872, steadyStateProbabilities.get(34L),
-        RandomWalkTestUtils.EPSILON);
-    assertEquals(0.09375, steadyStateProbabilities.get(56L), RandomWalkTestUtils.EPSILON);
-    assertEquals(0.301377, steadyStateProbabilities.get(78L),
-        RandomWalkTestUtils.EPSILON);
-  }
-
-  /**
-   * A local integration test on toy data
-   */
-  @Test
-  public void testWeightedGraph() throws Exception {
-    // A small graph
-    String[] graph =
-        new String[] { "12 34:0.1 56:0.9", "34 78:0.9 56:0.1",
-          "56 12:0.1 34:0.8 78:0.1", "78 34:1.0" };
-
-    GiraphConfiguration conf = new GiraphConfiguration();
-    conf.setInt(RandomWalkWithRestartVertex.SOURCE_VERTEX, 12);
-    conf.setInt(RandomWalkWithRestartVertex.MAX_SUPERSTEPS, 30);
-    conf.setFloat(RandomWalkWithRestartVertex.TELEPORTATION_PROBABILITY, 0.15f);
-    conf.setVertexClass(RandomWalkWithRestartVertex.class);
-    conf.setOutEdgesClass(ByteArrayEdges.class);
-    conf.setVertexInputFormatClass(
-        NormalizingLongDoubleDoubleTextInputFormat.class);
-    conf.setVertexOutputFormatClass(
-        VertexWithDoubleValueDoubleEdgeTextOutputFormat.class);
-    conf.setWorkerContextClass(RandomWalkWorkerContext.class);
-    conf.setMasterComputeClass(RandomWalkVertexMasterCompute.class);
-    // Run internally
-    Iterable<String> results = InternalVertexRunner.run(conf, graph);
-
-    Map<Long, Double> steadyStateProbabilities =
-        RandomWalkTestUtils.parseSteadyStateProbabilities(results);
-    // values computed with external software
-    // 0.163365, 0.378932, 0.156886, 0.300816
-    assertEquals(0.163365, steadyStateProbabilities.get(12L),
-        RandomWalkTestUtils.EPSILON);
-    assertEquals(0.378932, steadyStateProbabilities.get(34L),
-        RandomWalkTestUtils.EPSILON);
-    assertEquals(0.156886, steadyStateProbabilities.get(56L),
-        RandomWalkTestUtils.EPSILON);
-    assertEquals(0.300816, steadyStateProbabilities.get(78L),
-        RandomWalkTestUtils.EPSILON);
-  }
-
-
-}

http://git-wip-us.apache.org/repos/asf/giraph/blob/8811165e/giraph-examples/src/test/java/org/apache/giraph/examples/SimpleShortestPathsComputationTest.java
----------------------------------------------------------------------
diff --git a/giraph-examples/src/test/java/org/apache/giraph/examples/SimpleShortestPathsComputationTest.java b/giraph-examples/src/test/java/org/apache/giraph/examples/SimpleShortestPathsComputationTest.java
new file mode 100644
index 0000000..93a3248
--- /dev/null
+++ b/giraph-examples/src/test/java/org/apache/giraph/examples/SimpleShortestPathsComputationTest.java
@@ -0,0 +1,164 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.giraph.examples;
+
+import org.apache.giraph.conf.GiraphConfiguration;
+import org.apache.giraph.edge.ByteArrayEdges;
+import org.apache.giraph.edge.EdgeFactory;
+import org.apache.giraph.graph.Vertex;
+import org.apache.giraph.io.formats.JsonLongDoubleFloatDoubleVertexInputFormat;
+import org.apache.giraph.io.formats.JsonLongDoubleFloatDoubleVertexOutputFormat;
+import org.apache.giraph.utils.InternalVertexRunner;
+import org.apache.giraph.utils.MockUtils;
+import org.apache.hadoop.io.DoubleWritable;
+import org.apache.hadoop.io.FloatWritable;
+import org.apache.hadoop.io.LongWritable;
+import org.json.JSONArray;
+import org.json.JSONException;
+import org.junit.Test;
+import org.mockito.Mockito;
+
+import com.google.common.collect.Iterables;
+import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
+
+import java.util.Map;
+
+import static org.apache.giraph.examples.SimpleShortestPathsComputation.SOURCE_ID;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+/**
+ * Contains a simple unit test for {@link SimpleShortestPathsComputation}
+ */
+public class SimpleShortestPathsComputationTest {
+
+  /**
+   * Test the behavior when a shorter path to a vertex has been found
+   */
+  @Test
+  public void testOnShorterPathFound() throws Exception {
+    Vertex<LongWritable, DoubleWritable, FloatWritable> vertex =
+        new Vertex<LongWritable, DoubleWritable, FloatWritable>();
+    SimpleShortestPathsComputation computation =
+        new SimpleShortestPathsComputation();
+    MockUtils.MockedEnvironment<LongWritable, DoubleWritable, FloatWritable,
+        DoubleWritable> env = MockUtils.prepareVertexAndComputation(vertex,
+        new LongWritable(7L), new DoubleWritable(Double.MAX_VALUE), false,
+        computation, 1L);
+    Mockito.when(SOURCE_ID.get(env.getConfiguration())).thenReturn(2L);
+
+    vertex.addEdge(EdgeFactory.create(
+        new LongWritable(10L), new FloatWritable(2.5f)));
+    vertex.addEdge(EdgeFactory.create(
+        new LongWritable(20L), new FloatWritable(0.5f)));
+
+    computation.compute(vertex, Lists.newArrayList(new DoubleWritable(2),
+        new DoubleWritable(1.5)));
+
+    assertTrue(vertex.isHalted());
+    assertEquals(1.5d, vertex.getValue().get(), 0d);
+
+    env.verifyMessageSent(new LongWritable(10L), new DoubleWritable(4));
+    env.verifyMessageSent(new LongWritable(20L), new DoubleWritable(2));
+  }
+
+  /**
+   * Test the behavior when a new, but not shorter path to a vertex has been
+   * found.
+   */
+  @Test
+  public void testOnNoShorterPathFound() throws Exception {
+    Vertex<LongWritable, DoubleWritable, FloatWritable> vertex =
+        new Vertex<LongWritable, DoubleWritable, FloatWritable>();
+    SimpleShortestPathsComputation computation =
+        new SimpleShortestPathsComputation();
+    MockUtils.MockedEnvironment<LongWritable, DoubleWritable, FloatWritable,
+        DoubleWritable> env = MockUtils.prepareVertexAndComputation(vertex,
+        new LongWritable(7L), new DoubleWritable(0.5), false, computation, 1L);
+    Mockito.when(SOURCE_ID.get(env.getConfiguration())).thenReturn(2L);
+
+    vertex.addEdge(EdgeFactory.create(new LongWritable(10L),
+        new FloatWritable(2.5f)));
+    vertex.addEdge(EdgeFactory.create(
+        new LongWritable(20L), new FloatWritable(0.5f)));
+
+    computation.compute(vertex, Lists.newArrayList(new DoubleWritable(2),
+        new DoubleWritable(1.5)));
+
+    assertTrue(vertex.isHalted());
+    assertEquals(0.5d, vertex.getValue().get(), 0d);
+
+    env.verifyNoMessageSent();
+  }
+
+  /**
+   * A local integration test on toy data
+   */
+  @Test
+  public void testToyData() throws Exception {
+
+    // a small four vertex graph
+    String[] graph = new String[] {
+        "[1,0,[[2,1],[3,3]]]",
+        "[2,0,[[3,1],[4,10]]]",
+        "[3,0,[[4,2]]]",
+        "[4,0,[]]"
+    };
+
+    GiraphConfiguration conf = new GiraphConfiguration();
+    // start from vertex 1
+    SOURCE_ID.set(conf, 1);
+    conf.setComputationClass(SimpleShortestPathsComputation.class);
+    conf.setOutEdgesClass(ByteArrayEdges.class);
+    conf.setVertexInputFormatClass(
+        JsonLongDoubleFloatDoubleVertexInputFormat.class);
+    conf.setVertexOutputFormatClass(
+        JsonLongDoubleFloatDoubleVertexOutputFormat.class);
+
+    // run internally
+    Iterable<String> results = InternalVertexRunner.run(conf, graph);
+
+    Map<Long, Double> distances = parseDistances(results);
+
+    // verify results
+    assertNotNull(distances);
+    assertEquals(4, (int) distances.size());
+    assertEquals(0.0, (double) distances.get(1L), 0d);
+    assertEquals(1.0, (double) distances.get(2L), 0d);
+    assertEquals(2.0, (double) distances.get(3L), 0d);
+    assertEquals(4.0, (double) distances.get(4L), 0d);
+  }
+
+  private Map<Long, Double> parseDistances(Iterable<String> results) {
+    Map<Long, Double> distances =
+        Maps.newHashMapWithExpectedSize(Iterables.size(results));
+    for (String line : results) {
+      try {
+        JSONArray jsonVertex = new JSONArray(line);
+        distances.put(jsonVertex.getLong(0), jsonVertex.getDouble(1));
+      } catch (JSONException e) {
+        throw new IllegalArgumentException(
+            "Couldn't get vertex from line " + line, e);
+      }
+    }
+    return distances;
+  }
+}

http://git-wip-us.apache.org/repos/asf/giraph/blob/8811165e/giraph-examples/src/test/java/org/apache/giraph/examples/SimpleShortestPathsVertexTest.java
----------------------------------------------------------------------
diff --git a/giraph-examples/src/test/java/org/apache/giraph/examples/SimpleShortestPathsVertexTest.java b/giraph-examples/src/test/java/org/apache/giraph/examples/SimpleShortestPathsVertexTest.java
deleted file mode 100644
index 1006577..0000000
--- a/giraph-examples/src/test/java/org/apache/giraph/examples/SimpleShortestPathsVertexTest.java
+++ /dev/null
@@ -1,161 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.giraph.examples;
-
-import org.apache.giraph.conf.GiraphConfiguration;
-import org.apache.giraph.edge.ByteArrayEdges;
-import org.apache.giraph.edge.EdgeFactory;
-import org.apache.giraph.io.formats.JsonLongDoubleFloatDoubleVertexInputFormat;
-import org.apache.giraph.io.formats.JsonLongDoubleFloatDoubleVertexOutputFormat;
-import org.apache.giraph.utils.InternalVertexRunner;
-import org.apache.giraph.utils.MockUtils;
-import org.apache.hadoop.io.DoubleWritable;
-import org.apache.hadoop.io.FloatWritable;
-import org.apache.hadoop.io.LongWritable;
-import org.json.JSONArray;
-import org.json.JSONException;
-import org.junit.Test;
-import org.mockito.Mockito;
-
-import com.google.common.collect.Iterables;
-import com.google.common.collect.Lists;
-import com.google.common.collect.Maps;
-
-import java.util.Map;
-
-import static org.apache.giraph.examples.SimpleShortestPathsVertex.SOURCE_ID;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
-/**
- * Contains a simple unit test for {@link SimpleShortestPathsVertex}
- */
-public class SimpleShortestPathsVertexTest {
-
-  /**
-   * Test the behavior when a shorter path to a vertex has been found
-   */
-  @Test
-  public void testOnShorterPathFound() throws Exception {
-    SimpleShortestPathsVertex vertex = new SimpleShortestPathsVertex();
-
-    MockUtils.MockedEnvironment<LongWritable, DoubleWritable, FloatWritable,
-    DoubleWritable> env = MockUtils.prepareVertex(vertex, 1L,
-        new LongWritable(7L), new DoubleWritable(Double.MAX_VALUE), false);
-
-    Mockito.when(SOURCE_ID.get(env.getConfiguration())).thenReturn(2L);
-
-    vertex.addEdge(EdgeFactory.create(
-        new LongWritable(10L), new FloatWritable(2.5f)));
-    vertex.addEdge(EdgeFactory.create(
-        new LongWritable(20L), new FloatWritable(0.5f)));
-
-    vertex.compute(Lists.newArrayList(new DoubleWritable(2),
-        new DoubleWritable(1.5)));
-
-    assertTrue(vertex.isHalted());
-    assertEquals(1.5d, vertex.getValue().get(), 0d);
-
-    env.verifyMessageSent(new LongWritable(10L), new DoubleWritable(4));
-    env.verifyMessageSent(new LongWritable(20L), new DoubleWritable(2));
-  }
-
-  /**
-   * Test the behavior when a new, but not shorter path to a vertex has been
-   * found.
-   */
-  @Test
-  public void testOnNoShorterPathFound() throws Exception {
-
-    SimpleShortestPathsVertex vertex = new SimpleShortestPathsVertex();
-
-    MockUtils.MockedEnvironment<LongWritable, DoubleWritable, FloatWritable,
-    DoubleWritable> env = MockUtils.prepareVertex(vertex, 1L,
-        new LongWritable(7L), new DoubleWritable(0.5), false);
-
-    Mockito.when(SOURCE_ID.get(env.getConfiguration())).thenReturn(2L);
-
-    vertex.addEdge(EdgeFactory.create(new LongWritable(10L),
-        new FloatWritable(2.5f)));
-    vertex.addEdge(EdgeFactory.create(
-        new LongWritable(20L), new FloatWritable(0.5f)));
-
-    vertex.compute(Lists.newArrayList(new DoubleWritable(2),
-        new DoubleWritable(1.5)));
-
-    assertTrue(vertex.isHalted());
-    assertEquals(0.5d, vertex.getValue().get(), 0d);
-
-    env.verifyNoMessageSent();
-  }
-
-  /**
-   * A local integration test on toy data
-   */
-  @Test
-  public void testToyData() throws Exception {
-
-    // a small four vertex graph
-    String[] graph = new String[] {
-        "[1,0,[[2,1],[3,3]]]",
-        "[2,0,[[3,1],[4,10]]]",
-        "[3,0,[[4,2]]]",
-        "[4,0,[]]"
-    };
-
-    GiraphConfiguration conf = new GiraphConfiguration();
-    // start from vertex 1
-    SOURCE_ID.set(conf, 1);
-    conf.setVertexClass(SimpleShortestPathsVertex.class);
-    conf.setOutEdgesClass(ByteArrayEdges.class);
-    conf.setVertexInputFormatClass(
-        JsonLongDoubleFloatDoubleVertexInputFormat.class);
-    conf.setVertexOutputFormatClass(
-        JsonLongDoubleFloatDoubleVertexOutputFormat.class);
-
-    // run internally
-    Iterable<String> results = InternalVertexRunner.run(conf, graph);
-
-    Map<Long, Double> distances = parseDistances(results);
-
-    // verify results
-    assertNotNull(distances);
-    assertEquals(4, (int) distances.size());
-    assertEquals(0.0, (double) distances.get(1L), 0d);
-    assertEquals(1.0, (double) distances.get(2L), 0d);
-    assertEquals(2.0, (double) distances.get(3L), 0d);
-    assertEquals(4.0, (double) distances.get(4L), 0d);
-  }
-
-  private Map<Long, Double> parseDistances(Iterable<String> results) {
-    Map<Long, Double> distances =
-        Maps.newHashMapWithExpectedSize(Iterables.size(results));
-    for (String line : results) {
-      try {
-        JSONArray jsonVertex = new JSONArray(line);
-        distances.put(jsonVertex.getLong(0), jsonVertex.getDouble(1));
-      } catch (JSONException e) {
-        throw new IllegalArgumentException(
-            "Couldn't get vertex from line " + line, e);
-      }
-    }
-    return distances;
-  }
-}

http://git-wip-us.apache.org/repos/asf/giraph/blob/8811165e/giraph-examples/src/test/java/org/apache/giraph/examples/SimpleTriangleClosingComputationTest.java
----------------------------------------------------------------------
diff --git a/giraph-examples/src/test/java/org/apache/giraph/examples/SimpleTriangleClosingComputationTest.java b/giraph-examples/src/test/java/org/apache/giraph/examples/SimpleTriangleClosingComputationTest.java
new file mode 100644
index 0000000..73516a4
--- /dev/null
+++ b/giraph-examples/src/test/java/org/apache/giraph/examples/SimpleTriangleClosingComputationTest.java
@@ -0,0 +1,92 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.giraph.examples;
+
+import com.google.common.collect.Lists;
+
+import org.apache.giraph.graph.Vertex;
+import org.apache.giraph.utils.MockUtils;
+import org.apache.giraph.edge.EdgeFactory;
+import org.apache.hadoop.io.IntWritable;
+import org.apache.hadoop.io.NullWritable;
+import org.junit.Test;
+
+import static org.apache.giraph.examples.SimpleTriangleClosingComputation.IntArrayListWritable;
+
+import static org.junit.Assert.assertEquals;
+
+/**
+ * Contains a simple unit test for {@link SimpleTriangleClosingComputation}
+ */
+public class SimpleTriangleClosingComputationTest {
+
+  /**
+   * Test the behavior of the triangle closing algorithm:
+   * does it send all its out edge values to all neighbors?
+   */
+  @Test
+  public void testSuperstepZero() throws Exception {
+    // this guy should end up with an array value of 4
+    Vertex<IntWritable, IntArrayListWritable, NullWritable> vertex =
+        new Vertex<IntWritable, IntArrayListWritable, NullWritable>();
+
+    IntArrayListWritable alw = new IntArrayListWritable();
+
+    SimpleTriangleClosingComputation computation =
+        new SimpleTriangleClosingComputation();
+    MockUtils.MockedEnvironment env = MockUtils.prepareVertexAndComputation(
+        vertex, new IntWritable(1), alw, false, computation, 0L);
+
+    vertex.addEdge(EdgeFactory.create(new IntWritable(5)));
+    vertex.addEdge(EdgeFactory.create(new IntWritable(7)));
+
+    computation.compute(vertex, Lists.<IntWritable>newArrayList(
+      new IntWritable(83), new IntWritable(42)));
+
+    env.verifyMessageSent(new IntWritable(5), new IntWritable(5));
+    env.verifyMessageSent(new IntWritable(5), new IntWritable(7));
+    env.verifyMessageSent(new IntWritable(7), new IntWritable(5));
+    env.verifyMessageSent(new IntWritable(7), new IntWritable(7));
+  }
+
+  /** Test behavior of compute() with incoming messages (superstep 1) */
+  @Test
+  public void testSuperstepOne() throws Exception {
+    // see if the vertex interprets its incoming
+    // messages properly to verify the algorithm
+    Vertex<IntWritable, IntArrayListWritable, NullWritable> vertex =
+        new Vertex<IntWritable, IntArrayListWritable, NullWritable>();
+    SimpleTriangleClosingComputation computation =
+        new SimpleTriangleClosingComputation();
+    MockUtils.MockedEnvironment env = MockUtils.prepareVertexAndComputation(
+        vertex, new IntWritable(1), null, false, computation, 1L);
+
+      // superstep 1: can the vertex process these correctly?
+      computation.compute(vertex, Lists.<IntWritable>newArrayList(
+        new IntWritable(7),
+        new IntWritable(3),
+        new IntWritable(4),
+        new IntWritable(7),
+        new IntWritable(4),
+        new IntWritable(2),
+        new IntWritable(4)));
+      final String pairCheck = "[4, 7]";
+      assertEquals(pairCheck, vertex.getValue().toString());
+  }
+ }

http://git-wip-us.apache.org/repos/asf/giraph/blob/8811165e/giraph-examples/src/test/java/org/apache/giraph/examples/SimpleTriangleClosingVertexTest.java
----------------------------------------------------------------------
diff --git a/giraph-examples/src/test/java/org/apache/giraph/examples/SimpleTriangleClosingVertexTest.java b/giraph-examples/src/test/java/org/apache/giraph/examples/SimpleTriangleClosingVertexTest.java
deleted file mode 100644
index bfe8002..0000000
--- a/giraph-examples/src/test/java/org/apache/giraph/examples/SimpleTriangleClosingVertexTest.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.giraph.examples;
-
-import com.google.common.collect.Lists;
-import org.apache.giraph.utils.MockUtils;
-import org.apache.giraph.edge.EdgeFactory;
-import org.apache.hadoop.io.IntWritable;
-import org.apache.hadoop.io.NullWritable;
-import org.junit.Test;
-
-import static org.junit.Assert.assertEquals;
-
-/**
- * Contains a simple unit test for {@link SimpleTriangleClosingVertex}
- */
-public class SimpleTriangleClosingVertexTest {
-
-  /**
-   * Test the behavior of the triangle closing algorithm:
-   * does it send all its out edge values to all neighbors?
-   */
-  @Test
-  public void testSuperstepZero() throws Exception {
-    // this guy should end up with an array value of 4
-    SimpleTriangleClosingVertex vertex =
-        new SimpleTriangleClosingVertex();
-
-    SimpleTriangleClosingVertex.IntArrayListWritable alw =
-      new SimpleTriangleClosingVertex.IntArrayListWritable();
-
-    MockUtils.MockedEnvironment<IntWritable,
-      SimpleTriangleClosingVertex.IntArrayListWritable,
-    NullWritable, IntWritable> env =
-      MockUtils.prepareVertex(vertex, 0L,
-        new IntWritable(1), alw, false);
-
-    vertex.addEdge(EdgeFactory.create(new IntWritable(5)));
-    vertex.addEdge(EdgeFactory.create(new IntWritable(7)));
-
-    vertex.compute(Lists.<IntWritable>newArrayList(
-      new IntWritable(83), new IntWritable(42)));
-
-    env.verifyMessageSent(new IntWritable(5), new IntWritable(5));
-    env.verifyMessageSent(new IntWritable(5), new IntWritable(7));
-    env.verifyMessageSent(new IntWritable(7), new IntWritable(5));
-    env.verifyMessageSent(new IntWritable(7), new IntWritable(7));
-  }
-
-  /** Test behavior of compute() with incoming messages (superstep 1) */
-  @Test
-  public void testSuperstepOne() throws Exception {
-    // see if the vertex interprets its incoming
-    // messages properly to verify the algorithm
-    SimpleTriangleClosingVertex vertex =
-      new SimpleTriangleClosingVertex();
-
-    MockUtils.MockedEnvironment<IntWritable,
-      SimpleTriangleClosingVertex.IntArrayListWritable,
-      NullWritable, IntWritable>
-      env = MockUtils.<IntWritable,
-      SimpleTriangleClosingVertex.IntArrayListWritable,
-      NullWritable, IntWritable> prepareVertex(
-        vertex, 1L, new IntWritable(1), null, false);
-      // superstep 1: can the vertex process these correctly?
-      vertex.compute(Lists.<IntWritable>newArrayList(
-        new IntWritable(7),
-        new IntWritable(3),
-        new IntWritable(4),
-        new IntWritable(7),
-        new IntWritable(4),
-        new IntWritable(2),
-        new IntWritable(4)));
-      final String pairCheck = "[4, 7]";
-      assertEquals(pairCheck, vertex.getValue().toString());
-  }
- }

http://git-wip-us.apache.org/repos/asf/giraph/blob/8811165e/giraph-examples/src/test/java/org/apache/giraph/examples/TestPageRank.java
----------------------------------------------------------------------
diff --git a/giraph-examples/src/test/java/org/apache/giraph/examples/TestPageRank.java b/giraph-examples/src/test/java/org/apache/giraph/examples/TestPageRank.java
index 922e736..f8c7c48 100644
--- a/giraph-examples/src/test/java/org/apache/giraph/examples/TestPageRank.java
+++ b/giraph-examples/src/test/java/org/apache/giraph/examples/TestPageRank.java
@@ -64,13 +64,13 @@ public class TestPageRank extends BspCase {
   private void testPageRank(int numComputeThreads)
       throws IOException, InterruptedException, ClassNotFoundException {
     GiraphConfiguration conf = new GiraphConfiguration();
-    conf.setVertexClass(SimplePageRankVertex.class);
+    conf.setComputationClass(SimplePageRankComputation.class);
     conf.setVertexInputFormatClass(
-        SimplePageRankVertex.SimplePageRankVertexInputFormat.class);
+        SimplePageRankComputation.SimplePageRankVertexInputFormat.class);
     conf.setWorkerContextClass(
-        SimplePageRankVertex.SimplePageRankVertexWorkerContext.class);
+        SimplePageRankComputation.SimplePageRankWorkerContext.class);
     conf.setMasterComputeClass(
-        SimplePageRankVertex.SimplePageRankVertexMasterCompute.class);
+        SimplePageRankComputation.SimplePageRankMasterCompute.class);
     conf.setNumComputeThreads(numComputeThreads);
     // Set enough partitions to generate randomness on the compute side
     if (numComputeThreads != 1) {
@@ -80,11 +80,11 @@ public class TestPageRank extends BspCase {
     assertTrue(job.run(true));
     if (!runningInDistributedMode()) {
       double maxPageRank =
-          SimplePageRankVertex.SimplePageRankVertexWorkerContext.getFinalMax();
+          SimplePageRankComputation.SimplePageRankWorkerContext.getFinalMax();
       double minPageRank =
-          SimplePageRankVertex.SimplePageRankVertexWorkerContext.getFinalMin();
+          SimplePageRankComputation.SimplePageRankWorkerContext.getFinalMin();
       long numVertices =
-          SimplePageRankVertex.SimplePageRankVertexWorkerContext.getFinalSum();
+          SimplePageRankComputation.SimplePageRankWorkerContext.getFinalSum();
       System.out.println(getCallingMethodName() + ": maxPageRank=" +
           maxPageRank + " minPageRank=" +
           minPageRank + " numVertices=" + numVertices + ", " +

http://git-wip-us.apache.org/repos/asf/giraph/blob/8811165e/giraph-examples/src/test/java/org/apache/giraph/examples/TryMultiIpcBindingPortsTest.java
----------------------------------------------------------------------
diff --git a/giraph-examples/src/test/java/org/apache/giraph/examples/TryMultiIpcBindingPortsTest.java b/giraph-examples/src/test/java/org/apache/giraph/examples/TryMultiIpcBindingPortsTest.java
index 23d055e..1323ff6 100644
--- a/giraph-examples/src/test/java/org/apache/giraph/examples/TryMultiIpcBindingPortsTest.java
+++ b/giraph-examples/src/test/java/org/apache/giraph/examples/TryMultiIpcBindingPortsTest.java
@@ -70,7 +70,7 @@ public class TryMultiIpcBindingPortsTest {
         // fail the first port binding attempt
         GiraphConfiguration conf = new GiraphConfiguration();
         GiraphConstants.FAIL_FIRST_IPC_PORT_BIND_ATTEMPT.set(conf, true);
-        conf.setVertexClass(ConnectedComponentsVertex.class);
+        conf.setComputationClass(ConnectedComponentsComputation.class);
         conf.setOutEdgesClass(ByteArrayEdges.class);
         conf.setCombinerClass(MinimumIntCombiner.class);
         conf.setVertexInputFormatClass(IntIntNullTextInputFormat.class);

http://git-wip-us.apache.org/repos/asf/giraph/blob/8811165e/giraph-examples/src/test/java/org/apache/giraph/vertex/TestComputationTypes.java
----------------------------------------------------------------------
diff --git a/giraph-examples/src/test/java/org/apache/giraph/vertex/TestComputationTypes.java b/giraph-examples/src/test/java/org/apache/giraph/vertex/TestComputationTypes.java
new file mode 100644
index 0000000..3c63ee0
--- /dev/null
+++ b/giraph-examples/src/test/java/org/apache/giraph/vertex/TestComputationTypes.java
@@ -0,0 +1,244 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.giraph.vertex;
+
+import org.apache.giraph.combiner.Combiner;
+import org.apache.giraph.conf.GiraphConstants;
+import org.apache.giraph.conf.ImmutableClassesGiraphConfiguration;
+import org.apache.giraph.edge.ByteArrayEdges;
+import org.apache.giraph.examples.SimpleSuperstepComputation.SimpleSuperstepVertexInputFormat;
+import org.apache.giraph.graph.VertexValueFactory;
+import org.apache.giraph.io.formats.GeneratedVertexInputFormat;
+import org.apache.giraph.io.formats.JsonBase64VertexInputFormat;
+import org.apache.giraph.io.formats.JsonBase64VertexOutputFormat;
+import org.apache.giraph.job.GiraphConfigurationValidator;
+import org.apache.giraph.utils.NoOpComputation;
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.io.DoubleWritable;
+import org.apache.hadoop.io.FloatWritable;
+import org.apache.hadoop.io.IntWritable;
+import org.apache.hadoop.io.LongWritable;
+import org.junit.Test;
+
+import static org.apache.giraph.conf.GiraphConstants.VERTEX_VALUE_FACTORY_CLASS;
+
+
+public class TestComputationTypes {
+
+    /**
+     * Matches the {@link GeneratedVertexInputFormat}
+     */
+    private static class GeneratedComputationMatch extends NoOpComputation<
+        LongWritable, IntWritable, FloatWritable, FloatWritable> { }
+
+    /**
+     * Matches the {@link GeneratedVertexInputFormat}
+     */
+    private static class DerivedComputationMatch extends
+        GeneratedComputationMatch {
+    }
+
+    /**
+     * Mismatches the {@link GeneratedVertexInputFormat}
+     */
+    private static class GeneratedComputationMismatch extends NoOpComputation<
+        LongWritable, FloatWritable, FloatWritable, FloatWritable> { }
+
+    /**
+     * Matches the {@link GeneratedComputationMatch}
+     */
+    private static class GeneratedVertexMatchCombiner extends
+        Combiner<LongWritable, FloatWritable> {
+      @Override
+      public void combine(LongWritable vertexIndex,
+          FloatWritable originalMessage,
+          FloatWritable messageToCombine) {
+      }
+
+      @Override
+      public FloatWritable createInitialMessage() {
+        return null;
+      }
+    }
+
+    /**
+     * Mismatches the {@link GeneratedComputationMatch}
+     */
+    private static class GeneratedVertexMismatchCombiner extends
+        Combiner<LongWritable, DoubleWritable> {
+      @Override
+      public void combine(LongWritable vertexIndex,
+          DoubleWritable originalMessage,
+          DoubleWritable messageToCombine) {
+      }
+
+      @Override
+      public DoubleWritable createInitialMessage() {
+        return null;
+      }
+    }
+
+    /**
+     * Mismatches the {@link GeneratedComputationMatch}
+     */
+    private static class GeneratedVertexMismatchValueFactory implements
+        VertexValueFactory<DoubleWritable> {
+
+      @Override
+      public void initialize(
+          ImmutableClassesGiraphConfiguration<?, DoubleWritable, ?>
+              configuration) {}
+
+      @Override
+      public DoubleWritable createVertexValue() {
+        return new DoubleWritable();
+      }
+    }
+
+    /**
+     * Just populate a conf with testing defaults that won't
+     * upset the GiraphConfigurationValidator.
+     * */
+    private Configuration getDefaultTestConf() {
+      Configuration conf = new Configuration();
+      conf.setInt(GiraphConstants.MAX_WORKERS, 1);
+      conf.setInt(GiraphConstants.MIN_WORKERS, 1);
+      conf.set(GiraphConstants.VERTEX_INPUT_FORMAT_CLASS.getKey(),
+        "org.apache.giraph.io.formats.DUMMY_TEST_VALUE");
+      return conf;
+    }
+
+    @Test
+    public void testMatchingType() throws SecurityException,
+            NoSuchMethodException, NoSuchFieldException {
+        Configuration conf = getDefaultTestConf();
+        GiraphConstants.COMPUTATION_CLASS.set(conf,
+            GeneratedComputationMatch.class);
+        GiraphConstants.VERTEX_EDGES_CLASS.set(conf, ByteArrayEdges.class);
+        GiraphConstants.VERTEX_INPUT_FORMAT_CLASS.set(conf,
+            SimpleSuperstepVertexInputFormat.class);
+        GiraphConstants.VERTEX_COMBINER_CLASS.set(conf,
+            GeneratedVertexMatchCombiner.class);
+      @SuppressWarnings("rawtypes")
+      GiraphConfigurationValidator<?, ?, ?, ?, ?> validator =
+        new GiraphConfigurationValidator(conf);
+
+      ImmutableClassesGiraphConfiguration gc = new
+          ImmutableClassesGiraphConfiguration(conf);
+
+
+      validator.validateConfiguration();
+    }
+
+    @Test
+    public void testDerivedMatchingType() throws SecurityException,
+            NoSuchMethodException, NoSuchFieldException {
+        Configuration conf = getDefaultTestConf() ;
+        GiraphConstants.COMPUTATION_CLASS.set(conf,
+            DerivedComputationMatch.class);
+        GiraphConstants.VERTEX_EDGES_CLASS.set(conf, ByteArrayEdges.class);
+        GiraphConstants.VERTEX_INPUT_FORMAT_CLASS.set(conf,
+            SimpleSuperstepVertexInputFormat.class);
+        @SuppressWarnings("rawtypes")
+        GiraphConfigurationValidator<?, ?, ?, ?, ?> validator =
+          new GiraphConfigurationValidator(conf);
+        validator.validateConfiguration();
+    }
+
+    @Test
+    public void testDerivedInputFormatType() throws SecurityException,
+            NoSuchMethodException, NoSuchFieldException {
+        Configuration conf = getDefaultTestConf() ;
+        GiraphConstants.COMPUTATION_CLASS.set(conf,
+            DerivedComputationMatch.class);
+        GiraphConstants.VERTEX_EDGES_CLASS.set(conf, ByteArrayEdges.class);
+        GiraphConstants.VERTEX_INPUT_FORMAT_CLASS.set(conf,
+            SimpleSuperstepVertexInputFormat.class);
+      @SuppressWarnings("rawtypes")
+      GiraphConfigurationValidator<?, ?, ?, ?, ?> validator =
+        new GiraphConfigurationValidator(conf);
+      validator.validateConfiguration();
+    }
+
+    @Test(expected = IllegalArgumentException.class)
+    public void testMismatchingVertex() throws SecurityException,
+      NoSuchMethodException, NoSuchFieldException {
+      Configuration conf = getDefaultTestConf() ;
+      GiraphConstants.COMPUTATION_CLASS.set(conf,
+          GeneratedComputationMismatch.class);
+      GiraphConstants.VERTEX_EDGES_CLASS.set(conf, ByteArrayEdges.class);
+      GiraphConstants.VERTEX_INPUT_FORMAT_CLASS.set(conf,
+        SimpleSuperstepVertexInputFormat.class);
+      @SuppressWarnings("rawtypes")
+      GiraphConfigurationValidator<?, ?, ?, ?, ?> validator =
+        new GiraphConfigurationValidator(conf);
+      validator.validateConfiguration();
+    }
+
+    @Test(expected = IllegalArgumentException.class)
+    public void testMismatchingCombiner() throws SecurityException,
+      NoSuchMethodException, NoSuchFieldException {
+      Configuration conf = getDefaultTestConf() ;
+      GiraphConstants.COMPUTATION_CLASS.set(conf,
+          GeneratedComputationMatch.class);
+      GiraphConstants.VERTEX_EDGES_CLASS.set(conf, ByteArrayEdges.class);
+      GiraphConstants.VERTEX_INPUT_FORMAT_CLASS.set(conf,
+        SimpleSuperstepVertexInputFormat.class);
+      GiraphConstants.VERTEX_COMBINER_CLASS.set(conf,
+        GeneratedVertexMismatchCombiner.class);
+      @SuppressWarnings("rawtypes")
+      GiraphConfigurationValidator<?, ?, ?, ?, ?> validator =
+        new GiraphConfigurationValidator(conf);
+      validator.validateConfiguration();
+    }
+
+    @Test(expected = IllegalArgumentException.class)
+    public void testMismatchingVertexValueFactory() throws SecurityException,
+        NoSuchMethodException, NoSuchFieldException {
+      Configuration conf = getDefaultTestConf() ;
+      GiraphConstants.COMPUTATION_CLASS.set(conf,
+          GeneratedComputationMatch.class);
+      GiraphConstants.VERTEX_EDGES_CLASS.set(conf, ByteArrayEdges.class);
+      GiraphConstants.VERTEX_INPUT_FORMAT_CLASS.set(conf,
+          SimpleSuperstepVertexInputFormat.class);
+      VERTEX_VALUE_FACTORY_CLASS.set(conf,
+          GeneratedVertexMismatchValueFactory.class);
+      @SuppressWarnings("rawtypes")
+      GiraphConfigurationValidator<?, ?, ?, ?, ?> validator =
+          new GiraphConfigurationValidator(conf);
+      validator.validateConfiguration();
+    }
+
+    @Test
+    public void testJsonBase64FormatType() throws SecurityException,
+            NoSuchMethodException, NoSuchFieldException {
+        Configuration conf = getDefaultTestConf() ;
+        GiraphConstants.COMPUTATION_CLASS.set(conf,
+            GeneratedComputationMatch.class);
+        GiraphConstants.VERTEX_EDGES_CLASS.set(conf, ByteArrayEdges.class);
+        GiraphConstants.VERTEX_INPUT_FORMAT_CLASS.set(conf,
+            JsonBase64VertexInputFormat.class);
+        GiraphConstants.VERTEX_OUTPUT_FORMAT_CLASS.set(conf,
+            JsonBase64VertexOutputFormat.class);
+        @SuppressWarnings("rawtypes")
+        GiraphConfigurationValidator<?, ?, ?, ?, ?> validator =
+          new GiraphConfigurationValidator(conf);
+        validator.validateConfiguration();
+    }
+}