How does gremlin interpret double repeats such as described here for Lowest Common Ancestor algorithm? http://tinkerpop.apache.org/docs/3.2.3-SNAPSHOT/recipes/#_lowest_common_ancestor
It appears this is interpreted as a nested loop inside another loop O(n^2), rather than two independent loops. I would like to verify this behavior. Can I have a detailed explanation of the semantics here.
If this is behavior, is there a way to break the outer loop on condition of inner loop?
That's not a nested repeat()
(i.e. one repeat()
inside another) - the first repeat()
ends at the first emit()
and then a new repeat()
begins. It's thus saying that the traversal will first traverse out()
emitting every vertex it comes across and each of those vertices will traverse in()
only emitting the "D" vertex.
Nested loops were not supported in 3.2.3 and is actually only possible in the soon to be released 3.4.0 which you can read about here and looks like this:
gremlin> g.V().repeat(__.in('traverses').repeat(__.in('develops')).emit()).emit().values('name')
==>stephen
==>matthias
==>marko
Here you can see a repeat()
actually inside a repeat()