collecting properties from traversal?

25 views
Skip to first unread message

Per Bergman

unread,
Mar 13, 2017, 2:28:40 PM3/13/17
to Gremlin-users
I have a tree, where each Vertex has a 'parent' edge. From a leaf I need to construct the path to the root, something like:

g.V("PUBLIC.Node:::13").repeat(out('parent')).until(out('parent').count().is(0)).path()) 

(or .tree())


What I need is to collect all properties from each Vertex in a list, while traversing.
Should I use a sack() or sideEffects(), or something else?


Thanks,
Per

HadoopMarc

unread,
Mar 13, 2017, 4:40:25 PM3/13/17
to Gremlin-users
Hi Per,

It depends on how you want your "list" to look exactly. Just a by() modulator to path() does a pretty decent job:

g=TinkerFactory.createModern().traversal()
==>graphtraversalsource[tinkergraph[vertices:6 edges:6], standard]
gremlin
> g.V(1).out().out().path().by(valueMap())
==>[[name:[marko],age:[29]],[name:[josh],age:[32]],[name:[ripple],lang:[java]]]
==>[[name:[marko],age:[29]],[name:[josh],age:[32]],[name:[lop],lang:[java]]]
gremlin
>



Cheers,   Marc


Op maandag 13 maart 2017 19:28:40 UTC+1 schreef Per Bergman:
Reply all
Reply to author
Forward
0 new messages