Question on path()

42 views
Skip to first unread message

andrei...@gmail.com

unread,
Feb 15, 2016, 4:28:13 PM2/15/16
to Gremlin-users
Hi,

My graph looks something like this (length can be longer). What I need is all the different and distinct branches, eg {A,B,E,J}, {A,C,F,K}, {A,D,G,L}, {A,H,I.M}

My idea so far is an in-loop starting from A, get all the paths, but among them I receive as well the intermediary ones:
eg. The orange path is not needed. I need just the complete, final paths. 
==>[v[768], v[1792]] 
==>[v[768], v[1536]]
==>[v[768], v[1792], v[2048]]
That's my query: g.V.has('someProp','A').as('x').in.loop('x'){it.loops<100}{true}.path()
Any idea how I could do this with path()? And if it's not possible, any other ideas how I could do this? 

Thank you,
Andrei

Daniel Kuppitz

unread,
Feb 15, 2016, 4:41:20 PM2/15/16
to gremli...@googlegroups.com
The {true} tells the loop step to emit all vertices, hence you'll see each and every path. This should work:

g.V.has('someProp','A').as('x').in().loop('x') {it.loops<100} {!it.object.inE().hasNext()}.path()

Now loop only emits those vertices that don't have an in-edge.

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/4248e68f-a02d-40a1-9b5b-8785feb212ba%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

andrei...@gmail.com

unread,
Feb 16, 2016, 3:48:26 AM2/16/16
to Gremlin-users
Thanks a lot! It works :)
Reply all
Reply to author
Forward
0 new messages