To teach myself querying a graph database (Cayley).
I started to make some example graphs and queries that I use myself and can share later.
One of them I’m working on right now is about metro stations and practice morphism and recursive queries.
While working on it I slowly changed my graph to the following nodes:
Line (has green, blue, red, etc, with direction, i.e. green-south)
Platform (with direction, i.e. westminster-green-south, westminster-green-north)
How I approach this now (a bit naive) is (bit pseudo code):
towardsMorph = g.M().OutWithTags("pred", availableLines).Tag('towards') p = g.V("DepartureStation").Out(towardsMorph).Tag('direction').Back('departure') p = p.FollowRecursive(towardsMorph, -1 , depth).Tag('platform'). p = p.Out('is_located_at').Tag('station').Back('platform')
I iterate over the result and collect a route for every direction, once I reached my destination on one of the routes I mark that route as complete and cancel my context and stop iterating.
This works well for travelling on one line, but I’m wonder if I maybe can use some graph query tricks that make this better, faster, or span multiple lines. Or am I hoping for something that does not exist and do I need to do all the work in the iterator?