You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hama.apache.org by ed...@apache.org on 2012/06/19 02:14:41 UTC
svn commit: r1351539 - /hama/trunk/src/site/xdoc/hama_graph_tutorial.xml
Author: edwardyoon
Date: Tue Jun 19 00:14:41 2012
New Revision: 1351539
URL: http://svn.apache.org/viewvc?rev=1351539&view=rev
Log:
Fix arguments typos in graph tutorial page.
Modified:
hama/trunk/src/site/xdoc/hama_graph_tutorial.xml
Modified: hama/trunk/src/site/xdoc/hama_graph_tutorial.xml
URL: http://svn.apache.org/viewvc/hama/trunk/src/site/xdoc/hama_graph_tutorial.xml?rev=1351539&r1=1351538&r2=1351539&view=diff
==============================================================================
--- hama/trunk/src/site/xdoc/hama_graph_tutorial.xml (original)
+++ hama/trunk/src/site/xdoc/hama_graph_tutorial.xml Tue Jun 19 00:14:41 2012
@@ -31,10 +31,10 @@ xsi:schemaLocation="http://maven.apache.
<p>Writing a Hama graph application involves subclassing the predefined Vertex class. Its template arguments define three value types, associated with vertices, edges, and messages.</p>
<pre class="green">
- public abstract class Vertex<ID_TYPE extends Writable, MSG_TYPE extends Writable, EDGE_VALUE_TYPE extends Writable>
- implements VertexInterface<ID_TYPE, MSG_TYPE, EDGE_VALUE_TYPE> {
+ public abstract class Vertex<V extends Writable, E extends Writable, M extends Writable>
+ implements VertexInterface<V, E, M> {
- public void compute(Iterator<MSGTYPE> messages) throws IOException;
+ public void compute(Iterator<M> messages) throws IOException;
..
}</pre>
@@ -52,36 +52,28 @@ From Superstep 1 to 30, each vertex sums
public static class PageRankVertex extends
Vertex<Text, NullWritable, DoubleWritable> {
- static double DAMPING_FACTOR = 0.85;
- static double MAXIMUM_CONVERGENCE_ERROR = 0.001;
-
@Override
public void compute(Iterator<DoubleWritable> messages) throws IOException {
- // initialize this vertex to 1 / count of global vertices in this graph
if (this.getSuperstepCount() == 0) {
- this.setValue(new DoubleWritable(1.0 / this.getNumVertices()));
+ this.setValue(new DoubleWritable(1.0 / (double) this.getNumVertices()));
}
- // in the first superstep, there are no messages to check
- if (this.getSuperstepCount() >= 1) {
+ if (this.getSuperstepCount() >= 1) {
double sum = 0;
while (messages.hasNext()) {
DoubleWritable msg = messages.next();
sum += msg.get();
}
- double alpha = (1.0d - DAMPING_FACTOR) / this.getNumVertices();
- this.setValue(new DoubleWritable(alpha + (DAMPING_FACTOR * sum)));
+
+ double ALPHA = (1 - 0.85) / (double) this.getNumVertices();
+ this.setValue(new DoubleWritable(ALPHA + (0.85 * sum)));
}
- // if we have not reached our global error yet, then proceed.
- DoubleWritable globalError = getLastAggregatedValue(0);
- if (globalError != null && this.getSuperstepCount() > 2
- && MAXIMUM_CONVERGENCE_ERROR > globalError.get()) {
- return;
+ if (this.getSuperstepCount() < this.getMaxIteration()) {
+ int numEdges = this.getOutEdges().size();
+ sendMessageToNeighbors(new DoubleWritable(this.getValue().get()
+ / numEdges));
}
-
- // in each superstep we are going to send a new rank to our neighbours
- sendMessageToNeighbors(new DoubleWritable(this.getValue().get() / numEdges));
}
}</pre>