Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to return a list the last vertex within each path object?

I am trying to build a chaining mechanism with my query and I want to start my next invocation from the end of the previous. I’ve tried using the by step, but I can’t seem to get it to work or do what I would like. What is the best way to get the last vertex in all the paths from the below query?

g.V(1).repeat(out()).times(2).emit().path();

If this returned:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

[v[1], v[2], v[3]]
[v[1], v[3], v[4]]

All I want is:

v[3]
v[4]

Thanks!

>Solution :

You can take the tail of a path

gremlin> g.V(44).out().out().limit(5).path()
==>[v[44],v[8],v[47]]
==>[v[44],v[8],v[48]]
==>[v[44],v[8],v[49]]
==>[v[44],v[8],v[51]]
==>[v[44],v[8],v[52]]

gremlin> g.V(44).out().out().limit(5).path().tail(local)
==>v[47]
==>v[48]
==>v[49]
==>v[51]
==>v[52]   
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading