hama-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tjungb...@apache.org
Subject svn commit: r1352620 - in /hama/trunk/graph/src/test/java/org/apache/hama/graph: TestSubmitGraphJob.java example/PageRank.java
Date Thu, 21 Jun 2012 17:06:53 GMT
Author: tjungblut
Date: Thu Jun 21 17:06:52 2012
New Revision: 1352620

URL: http://svn.apache.org/viewvc?rev=1352620&view=rev
Log:
fixing sum errors

Modified:
    hama/trunk/graph/src/test/java/org/apache/hama/graph/TestSubmitGraphJob.java
    hama/trunk/graph/src/test/java/org/apache/hama/graph/example/PageRank.java

Modified: hama/trunk/graph/src/test/java/org/apache/hama/graph/TestSubmitGraphJob.java
URL: http://svn.apache.org/viewvc/hama/trunk/graph/src/test/java/org/apache/hama/graph/TestSubmitGraphJob.java?rev=1352620&r1=1352619&r2=1352620&view=diff
==============================================================================
--- hama/trunk/graph/src/test/java/org/apache/hama/graph/TestSubmitGraphJob.java (original)
+++ hama/trunk/graph/src/test/java/org/apache/hama/graph/TestSubmitGraphJob.java Thu Jun 21
17:06:52 2012
@@ -69,11 +69,8 @@ public class TestSubmitGraphJob extends 
     // set the defaults
     bsp.setMaxIteration(30);
     bsp.set("hama.pagerank.alpha", "0.85");
-    // we need to include a vertex in its adjacency list,
-    // otherwise the pagerank result has a constant loss
-    bsp.set("hama.graph.self.ref", "true");
     bsp.set("hama.graph.repair", "true");
-    bsp.setAggregatorClass(AverageAggregator.class, SumAggregator.class);
+    bsp.setAggregatorClass(AverageAggregator.class, PageRank.DanglingNodeAggregator.class);
 
     bsp.setVertexIDClass(Text.class);
     bsp.setVertexValueClass(DoubleWritable.class);

Modified: hama/trunk/graph/src/test/java/org/apache/hama/graph/example/PageRank.java
URL: http://svn.apache.org/viewvc/hama/trunk/graph/src/test/java/org/apache/hama/graph/example/PageRank.java?rev=1352620&r1=1352619&r2=1352620&view=diff
==============================================================================
--- hama/trunk/graph/src/test/java/org/apache/hama/graph/example/PageRank.java (original)
+++ hama/trunk/graph/src/test/java/org/apache/hama/graph/example/PageRank.java Thu Jun 21
17:06:52 2012
@@ -25,6 +25,7 @@ import org.apache.hadoop.io.DoubleWritab
 import org.apache.hadoop.io.LongWritable;
 import org.apache.hadoop.io.NullWritable;
 import org.apache.hadoop.io.Text;
+import org.apache.hama.graph.AbstractAggregator;
 import org.apache.hama.graph.Edge;
 import org.apache.hama.graph.Vertex;
 import org.apache.hama.graph.VertexInputReader;
@@ -116,4 +117,29 @@ public class PageRank {
 
   }
 
+  public static class DanglingNodeAggregator
+      extends
+      AbstractAggregator<DoubleWritable, Vertex<Text, NullWritable, DoubleWritable>>
{
+
+    double danglingNodeSum;
+
+    @Override
+    public void aggregate(Vertex<Text, NullWritable, DoubleWritable> vertex,
+        DoubleWritable value) {
+      if (vertex != null) {
+        if (vertex.getEdges().size() == 0) {
+          danglingNodeSum += value.get();
+        }
+      } else {
+        danglingNodeSum += value.get();
+      }
+    }
+
+    @Override
+    public DoubleWritable getValue() {
+      return new DoubleWritable(danglingNodeSum);
+    }
+
+  }
+
 }



Mime
View raw message