That's great. Here's my rough suggestion.
We can add a abstract class for the vertex that can be overrided. I
think, Vertex class can be like this:
abstract class Vertex {
public void compute(Iterator<Message> msgs);
public String getVertexID();
public int getSuperStep();
public double getValue();
public setValue(double nValue);
public void Iterator<Message> getMessages();
public void sendMessageTo(Edge edge, double messageValue);
public List<Edge> getOutEdgeIterator();
public void voteToHalt();
...
}
Then, you can simplify the ShortestPathVertex and PageRankVertex as below:
public cass ShortestPathVertex extends Vertex {
}
or
public class PageRankVertex extends Vertex {
}
And, finally the code will become the same with Google's Pregel.
public void compute() {
int minDist = isSource(this.getVertexID()) ? 0 : INF;
int newPrevVertexID = -1;
for (Message msgs : this.getMessages()) {
minDist = min(minDist, msgs.getValue());
}
if (minDist < this.getValue()) {
this.setValue(minDist);
for (Edge e : this.getOutEdgeIterator()) {
this.sendMessageTo(e, minDist + e.getCost());
}
}
this.voteToHalt();
}
On Tue, Jun 28, 2011 at 6:56 PM, Thomas Jungblut
<[email protected]> wrote:
> Hey,
>
> I always thought of adding some new methods to our abstract BSP Class. For
> example sendMessage(List<Hosts>) or something like that.
> I would change these API things after we added the IO System, because much
> stuff is related and needs the information of it. (getVertexID() for
> example).
>
> Regards,
> Thomas
>
> 2011/6/28 Edward J. Yoon <[email protected]>
>
>> Hi,
>>
>> I think, the code quantity of Dijkstra's shortest path and PageRank
>> can be dramatically reduced by adding Google's Pregel APIs e.g.,
>> compute(List<BSPMessage> msgs), getVertexID(), .. and APIs can be
>> moved in o.a.hama.graph package.
>>
>> Does anyone volunteer here?
>>
>> --
>> Best Regards, Edward J. Yoon
>> @eddieyoon
>>
>
>
>
> --
> Thomas Jungblut
> Berlin
>
> mobile: 0170-3081070
>
> business: [email protected]
> private: [email protected]
>
--
Best Regards, Edward J. Yoon
@eddieyoon