Graphs with Ashikawa

20 views
Skip to first unread message

Patrick Mulder

unread,
Dec 5, 2012, 11:21:24 AM12/5/12
to ashi...@googlegroups.com
As a follow-up from the previous discussion:

Lucas wrote:
> There is absolutely no good solution yet for any of the graph databases [snip] 

Hmm.. Neo4J looks quite interesting, but I haven't played with it enough to understand the shortcomings or roadmap of the technology. 

When I look at the example of the Neo4J ruby gem, I see something like this:

andreas.outgoing(:friends).depth(5).find_all{|friend| friend.city == city && friend.likes.include?(film)}.to_a.join(', ')


It's not really easy to understand what the query would return, and similarly on the lower level, in Cypher, there is no "Wow... that looks simple". So, I agree, we have to invest quite some time to learn what's up with graphs queries.


> But I don't get entirely how your proposed solution works! User and Tag are both Vertices? What are the edges?

In my previous thought experiment, I was thinking that a query should be written as follows:

my_graph_teachers = User.who_knows("cypher").who_is_located_in("Boston")

So, the query would speak more to me, what I would be looking for...


But actually, I am bit confused too, what would fit with edges, what would fit with vertices.


Another approach I imagine could be something like:

User.with_skills("cypher").wthin_distance("100 km")



Hmm... anyway, just loud thinking, to explore some basic "Hello World" for a graph query.

What do you think?


BR,
Patrick

Lucas Dohmen

unread,
Dec 14, 2012, 5:14:21 AM12/14/12
to ashi...@googlegroups.com
Hi :)

The problem with Neo4j's way to handle this is, that they only support it in embedded mode.
We do not (and do not want to) offer an embedded mode for ArangoDB – the request should
be send via HTTP to the server. If you would use it in the way you proposed, we would basically
execute it in memory and loose the strength of the database this way.
So we would have to think up a way to have it produce a query in a DSL-style.

andreas.outgoing(:friends).depth(5)

would be possible. But we can't offer blocks, because translating them to a query is hard, slow
and has restrictions that are not clear to the user.

So I'm thinking about something like this:

user = User.where(name: "Patrick")
friends = user.neighbors_via label: ["likes"]
# friends is now a relation, will be executed if you call .each, .to_a....
friends_of_friends = friends.neighbors_via label: ["likes"]
# I now refined the relation
friends_of_friends.each { |ff| invite_to_birthday ff }

What do you think? :)

Patrick Mulder

unread,
Dec 14, 2012, 8:09:22 AM12/14/12
to ashi...@googlegroups.com
On Fri, Dec 14, 2012 at 11:14 AM, Lucas Dohmen <lucas....@rwth-aachen.de> wrote:

user = User.where(name: "Patrick")
friends = user.neighbors_via label: ["likes"]

This idea of "neighbors" looks nice. I am wondering if it would be possible to wrap the "likes" edge within "friends", e.g.

guests = user.friends  # friends could be some macro simllar to has_scope :friends, lambda { neighbors_via [:like] }

 ... not sure if the semantics of an ActiveRecord "scope" make sense, but maybe interesting to explore a bit.

Another important point:  How do you actually add relationships/edges within a graph? I hope to understand a bit better graph CRUD soon; I'll share something when I made some progress.

Cheers,
Patrick

Patrick Mulder

unread,
Dec 14, 2012, 8:13:57 AM12/14/12
to ashi...@googlegroups.com
On Fri, Dec 14, 2012 at 2:09 PM, Patrick Mulder <mulder....@gmail.com> wrote:
On Fri, Dec 14, 2012 at 11:14 AM, Lucas Dohmen <lucas....@rwth-aachen.de> wrote:

user = User.where(name: "Patrick")
friends = user.neighbors_via label: ["likes"]

This idea of "neighbors" looks nice. I am wondering if it would be possible to wrap the "likes" edge within "friends", e.g.


Actually this might work:

class User

   has_neighbours :friends, :edges: "likes"

    ...

end

so, user.friends => neighbour nodes ?

cheers,

patrick 

Lucas

unread,
Jan 4, 2013, 9:42:14 AM1/4/13
to ashi...@googlegroups.com
Ups. I thought I had answered this a long time ago!

This is a really, really good idea. Noted that :)
Makes it really intuitive!

Patrick Mulder

unread,
Jan 4, 2013, 4:37:59 PM1/4/13
to ashi...@googlegroups.com
Thanks Lucas, no problem.
I am bit pressured by other topics right now, but hopefully find some time end of January to come back to this... I'll update you as soon as possible.
Reply all
Reply to author
Forward
0 new messages