You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hama.apache.org by "Edward J. Yoon" <ed...@apache.org> on 2011/06/28 10:58:05 UTC
Refactor o.a.hama.examples.graph package
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
Re: Refactor o.a.hama.examples.graph package
Posted by Thomas Jungblut <th...@googlemail.com>.
very nice. +1 :D
2011/6/28 Edward J. Yoon <ed...@apache.org>
> 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
> <th...@googlemail.com> 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 <ed...@apache.org>
> >
> >> 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: thomas.jungblut@testberichte.de
> > private: thomas.jungblut@gmail.com
> >
>
>
>
> --
> Best Regards, Edward J. Yoon
> @eddieyoon
>
--
Thomas Jungblut
Berlin
mobile: 0170-3081070
business: thomas.jungblut@testberichte.de
private: thomas.jungblut@gmail.com
Re: Refactor o.a.hama.examples.graph package
Posted by "Edward J. Yoon" <ed...@apache.org>.
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
<th...@googlemail.com> 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 <ed...@apache.org>
>
>> 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: thomas.jungblut@testberichte.de
> private: thomas.jungblut@gmail.com
>
--
Best Regards, Edward J. Yoon
@eddieyoon
Re: Refactor o.a.hama.examples.graph package
Posted by Thomas Jungblut <th...@googlemail.com>.
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 <ed...@apache.org>
> 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: thomas.jungblut@testberichte.de
private: thomas.jungblut@gmail.com