tenantGraph.traversal()
.V(START_CATEGORY_VERTEX_ID)
.emit()
.repeat(
__.inE("hasParent")
.map(traverser -> traverser.get().outVertex())
)
.until(traverser -> stopTraverser(traverser, treeDepth))
.tree().next();
tenantGraph.traversal()
.V(parentCategoryVertices.toArray())
.emit()
.repeat(
__.inE("hasParent")
.outV()
)
.until(traverser -> stopTraverser(traverser, treeDepth))
.tree().next();
To give an example for option #2:
gremlin> g.V("a").emit().repeat(inE("hasParent").order().by("position", incr).outV()).times(2).path().by(id).by("position")
==>[a]
==>[a, 1, aa]
==>[a, 1, aa, 1, aaa]
==>[a, 1, aa, 2, aab]
==>[a, 2, ab]
==>[a, 3, ac]
gremlin> g.V("a").emit().repeat(inE("hasParent").order().by("position", decr).outV()).times(2).path().by(id).by("position")
==>[a]
==>[a, 3, ac]
==>[a, 2, ab]
==>[a, 1, aa]
==>[a, 1, aa, 2, aab]
==>[a, 1, aa, 1, aaa]
Cheers,
Daniel
--
You received this message because you are subscribed to the Google Groups "Gremlin-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gremlin-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/gremlin-users/abac3f2e-8cbf-413a-a0ac-26e462305033%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Could you advice if using paths (which will have to be transformed to tree structure on client side) is better than sorting the tree structure returned by tree() operation ?
public class SortedTree extends org.apache.tinkerpop.gremlin.process.traversal.step.util.Tree {// TODO: override (almost?) all methods}
g.withSideEffect("t", new SortedTree()).V("a").emit().repeat(inE("hasParent").as("e").outV()).times(maxDepth).tree("t").by(id).by("position").cap("t").next()
To view this discussion on the web visit https://groups.google.com/d/msgid/gremlin-users/7d0f83b3-5859-4abf-a305-84a8be2c3f4c%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/gremlin-users/b9fa746d-5bd8-4d4a-8807-0b6ee1909310%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/gremlin-users/CA%2Bf9seUWtU_%2BS4jOvGUyE4%2BRfNsJHVuq0fYn3Ca1fj4Lp5xbdg%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/gremlin-users/6656E8E7-CCC9-41F8-8A0C-AEDC614B56C2%40gmail.com.