Ok, so, exactly as I wrote a few e-mails back in this thread, you can do
this with a vertex-centric iteration :-)

All you need to do is call "myGraph.runVertexCentricIteration(new
MyUpdateFunction(), new MyMessagingFunction(), maxIterations)"
and define MyUpdateFunction and MyMessagingFunction.

The first function defines how a vertex updates its value based on the
received messages, while the second defines what messages a vertex sends in
each superstep.
Inside both functions, you have access to the vertex ID and value, so you
can check whether it's the vertex you're interested in.

In your case, in the first superstep, the Person vertex sends a message to
its neighbors​.
You can do this with something like the following inside the the
sendMessages() method:

for (Edge<K, V> edge : getOutgoingEdges()) {

  sendMessageTo(edge.getTarget(), msg);

}
The rest of the vertices don't need to do anything in the first superstep.
In the next supersteps, the vertices which have received a message,
propagate it to their neighbors in the same way.

One thing you need to be careful about is detecting cycles, so that the
iteration terminates. One way to do this is to mark the vertices you visit,
e.g. by setting a flag in the vertex value and not propagate messages from
a "visited" vertex.

If you are totally unfamiliar with the vertex-centric model, it might be a
good idea to first do some reading on this, in order to understand how it
works, for example take a look at the Pregel paper [1].

Let us know how it goes!

Cheers,
-Vasia.

[1]: http://kowshik.github.io/JPregel/pregel_paper.pdf


On 14 April 2015 at 18:12, Flavio Pompermaier <pomperma...@okkam.it> wrote:

> Hi Vasia,
> for compute subgraph for Person I mean exactly all the vertices that
> can be reached
> starting from this node and following the graph edges.
> I drafted the graph as a set of vertices (where the id is the subject of
> the set of triples and the value is all of its triples)
> and a set of edges (properties connecting two vertices, this is only
> possible if the object is an URI).
>
> Thus, once computed the subgraph of a Person, if I merge the values of all
> reachable vertices, I'll obtain all the triples of such a subgraph.
>
> On Tue, Apr 14, 2015 at 4:55 PM, Vasiliki Kalavri <
> vasilikikala...@gmail.com
> > wrote:
>
> > Hi Flavio,
> >
> > I'm not quite familiar with RDF or sparql, so not all of your code is
> clear
> > to me.
> >
> > Your first TODO is "compute subgraph for Person". Is "Person" a vertex id
> > in your graph? A vertex value?
> > And by "subgraph of Person", do you mean all the vertices that can be
> > reached starting from this node and following the graph edges?
> >
> > -Vasia.
> >
> > On 14 April 2015 at 10:37, Flavio Pompermaier <pomperma...@okkam.it>
> > wrote:
> >
> > > Hi to all,
> > > I made a simple RDF Gelly test and I shared it on my github repo at
> > > https://github.com/fpompermaier/rdf-gelly-test.
> > > I basically setup the Gelly stuff but I can't proceed and compute the
> > > drafted TODOs.
> > > Could someone help me and implementing them..?
> > > I think this could become a nice example of how Gelly could help in
> > > handling RDF graphs :)
> > >
> > > Best,
> > > Flavio
> > >
> > > On Mon, Mar 23, 2015 at 10:41 AM, Flavio Pompermaier <
> > pomperma...@okkam.it
> > > >
> > > wrote:
> > >
> > > > Thanks Vasiliki,
> > > > when I'll find the time I'll try to make a quick prototype using the
> > > > pointers you suggested!
> > > >
> > > > Thanks for the support,
> > > > Flavio
> > > >
> > > > On Mon, Mar 23, 2015 at 10:31 AM, Vasiliki Kalavri <
> > > > vasilikikala...@gmail.com> wrote:
> > > >
> > > >> Hi Flavio,
> > > >>
> > > >> I'm not familiar with JSON-LD, but as far as I understand, you want
> to
> > > >> generate some trees from selected root nodes.
> > > >>
> > > >> Once you have created the Graph as Andra describes above, you can
> > first
> > > >> filter out the edges that are of no interest to you, using
> > > filterOnEdges.
> > > >> There is a description of how edge filtering works in the Gelly docs
> > > [1].
> > > >> Then, you could use a vertex-centric iteration and propagate a
> message
> > > >> from
> > > >> the selected root node to the neighbors recursively, until you have
> > the
> > > >> tree.
> > > >>
> > > >> In the vertex-centric model, you program from the perspective of a
> > > vertex
> > > >> in the graph. You basically need to define what each vertex does
> > within
> > > >> each iteration (superstep). In Gelly this boils down to two things:
> > > >> (a) what messages this vertex will send to its neighbors and
> > > >> (b) how a vertex will update its value using the received messages.
> > > >>
> > > >> This is also described in the Gelly docs [2].
> > > >> Also, take a look at the Gelly library [3]. The library methods are
> > > >> implemented using this model and should give you an idea.
> > > >>
> > > >> In your case, you will probably need to simply propagate one message
> > > from
> > > >> the root node and gather the newly discovered neighbors in each
> > > superstep.
> > > >>
> > > >> I hope this helps! Let us know if you have further questions!
> > > >>
> > > >> -Vasia.
> > > >>
> > > >> [1]:
> > > >>
> > > >>
> > >
> >
> http://ci.apache.org/projects/flink/flink-docs-master/gelly_guide.html#graph-transformations
> > > >>
> > > >> [2]:
> > > >>
> > > >>
> > >
> >
> http://ci.apache.org/projects/flink/flink-docs-master/gelly_guide.html#vertex-centric-iterations
> > > >>
> > > >> [3]:
> > > >>
> > > >>
> > >
> >
> http://github.com/apache/flink/tree/master/flink-staging/flink-gelly/src/main/java/orgThehveflink/graph/library
> > > >>
> > > >
> > > >
> > > >
> > >
> >
>

Reply via email to