How to save traverse result in a variable and reuse them in the next traversal?

777 views
Skip to first unread message

Eric Cyliu

unread,
Aug 25, 2016, 5:59:15 AM8/25/16
to Aurelius
Hi,

I wonder how to save traversal result in a variable and start another traverse with that variable. I have tried following codes. It seems the variable is empty.

gremlin> previous = g.V().has('name', 'b').outE()
==>e[13][2-next->8]
gremlin> previous.inE()
The traversal strategies are complete and the traversal can no longer be modulated
Display stack trace? [yN] 

Thanks.

Daniel Kuppitz

unread,
Aug 25, 2016, 6:43:45 AM8/25/16
to aureliu...@googlegroups.com
The console will automatically iterate your traversals. To work around this behavior you can do this:

gremlin> t = g.V().has("name", "lop"); []
gremlin> t.inE()
==>e[9][1-created->3]
==>e[11][4-created->3]
==>e[12][6-created->3]
gremlin> 

Cheers,
Daniel


--
You received this message because you are subscribed to the Google Groups "Aurelius" group.
To unsubscribe from this group and stop receiving emails from it, send an email to aureliusgraphs+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/aureliusgraphs/3b80f1fc-6413-43f0-83e6-f39f5bc51e27%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Eric Cyliu

unread,
Aug 25, 2016, 7:45:33 AM8/25/16
to Aurelius
Thanks Daniel again.
Why do semicolon and square brackets help ?  


On Thursday, August 25, 2016 at 1:43:45 PM UTC+3, Daniel Kuppitz wrote:
The console will automatically iterate your traversals. To work around this behavior you can do this:

gremlin> t = g.V().has("name", "lop"); []
gremlin> t.inE()
==>e[9][1-created->3]
==>e[11][4-created->3]
==>e[12][6-created->3]
gremlin> 

Cheers,
Daniel

On Thu, Aug 25, 2016 at 11:59 AM, Eric Cyliu <farsca...@live.com> wrote:
Hi,

I wonder how to save traversal result in a variable and start another traverse with that variable. I have tried following codes. It seems the variable is empty.

gremlin> previous = g.V().has('name', 'b').outE()
==>e[13][2-next->8]
gremlin> previous.inE()
The traversal strategies are complete and the traversal can no longer be modulated
Display stack trace? [yN] 

Thanks.

--
You received this message because you are subscribed to the Google Groups "Aurelius" group.
To unsubscribe from this group and stop receiving emails from it, send an email to aureliusgraph...@googlegroups.com.

Eric Cyliu

unread,
Aug 25, 2016, 7:54:17 AM8/25/16
to Aurelius
I also realized that t can be used only once. Why is that ? Is it possible to use many times?


On Thursday, August 25, 2016 at 1:43:45 PM UTC+3, Daniel Kuppitz wrote:
The console will automatically iterate your traversals. To work around this behavior you can do this:

gremlin> t = g.V().has("name", "lop"); []
gremlin> t.inE()
==>e[9][1-created->3]
==>e[11][4-created->3]
==>e[12][6-created->3]
gremlin> 

Cheers,
Daniel

On Thu, Aug 25, 2016 at 11:59 AM, Eric Cyliu <farsca...@live.com> wrote:
Hi,

I wonder how to save traversal result in a variable and start another traverse with that variable. I have tried following codes. It seems the variable is empty.

gremlin> previous = g.V().has('name', 'b').outE()
==>e[13][2-next->8]
gremlin> previous.inE()
The traversal strategies are complete and the traversal can no longer be modulated
Display stack trace? [yN] 

Thanks.

--
You received this message because you are subscribed to the Google Groups "Aurelius" group.
To unsubscribe from this group and stop receiving emails from it, send an email to aureliusgraph...@googlegroups.com.

Daniel Kuppitz

unread,
Aug 25, 2016, 10:56:01 AM8/25/16
to aureliu...@googlegroups.com
Because it makes [] the last statement of the line and only the last statement will be evaluated / iterated.

Cheers,
Daniel


To unsubscribe from this group and stop receiving emails from it, send an email to aureliusgraphs+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/aureliusgraphs/b0631d0b-7453-4088-92ca-746a6cc03c72%40googlegroups.com.

Daniel Kuppitz

unread,
Aug 25, 2016, 10:56:45 AM8/25/16
to aureliu...@googlegroups.com
If you want to use it multiple times, .clone() it.

Cheers,
Daniel


To unsubscribe from this group and stop receiving emails from it, send an email to aureliusgraphs+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/aureliusgraphs/398e1758-11ea-4eef-9a0d-eefadab6b8c0%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages