FollowRecursive parent


#1

Using http://blog.juganaru.eu/2016/06/28/google-cayley-graph-database-tutorial-family-tree/ as an example,

If I want all of John’s children and their children, I can write

g.V(‘john’).FollowRecursive(g.M().Out(‘child’)).All();

However, in the result set, I would like to know who the parent is as traversed by the FollowRecursive call / not both of childX’s parents as defined in the dataset / graph.

How can I get this?


FollowRecursive is not a function
#2

The most intuitive way would be to Tag a node before Out(child), so at the end of traversal last node’s parent will remain. But it will add a significant overhead in case of deep traversal, so it might be better to SaveR('child','parent') at the end of whole query.


#3

As you mentioned, I can get the parents via

g.V(‘john’).FollowRecursive(g.M().Out(‘child’)).SaveR(‘child’, ‘parent’).All()

but then I get all parents vs only the one that FollowRecursive traversed through… can you please provide query with the tag suggestion? I can’t seem to get that working…

g.V(‘john’).Follow(g.M().Tag(‘name’).Out(‘child’)).All() will tag the name of the current node, but

g.V(‘john’).FollowRecursive(g.M().Tag(‘name’).Out(‘child’)).All() drops it.

Also, to your point regarding deep traversal, I take it there is no option to specify the recursion depth as part of the FollowRecursive call?


#4

I assumed there will be only one child relation to a specific object. This suggests that you have multiple ones. This query will not work then.

This was a bug - recursive iterator was not tagging path correctly. Fixed upstream.

It’s not exposed to Gizmo queries yet. I’ll make this change a bit later. Can you file an issue on Github to track progress?