How to check whether one of outV match with a given vertex ?

10 views
Skip to first unread message

Eric Cyliu

unread,
Aug 25, 2016, 4:39:59 AM8/25/16
to Aurelius
For a vertex 'e', there are three in edges. I would like to check whether one of vertex 'b' is in the list. 
I am quite new for gremlin. Thanks for your help.

//
g.V().has('name','e').inE().outV()
==>v[2]
==>v[4]
==>v[6]
//
b
==>v[2]
// this did not work
g.V().has('name','e').inE().outV() == b
==>false

Daniel Kuppitz

unread,
Aug 25, 2016, 4:47:43 AM8/25/16
to aureliu...@googlegroups.com
Since you know vertex e and vertex b, you probably want to find the edge between them (if one exists):

g.V().has("name", "e").inE().filter(outV().is(b))

If all you need is a boolean value, then just append a .hasNext().

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/1eec56f5-cbfd-460e-a495-f7b67246514e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Eric Cyliu

unread,
Aug 25, 2016, 5:48:47 AM8/25/16
to Aurelius
Yes, this is exactly what I wanted.

I also figured another way myself. This solution is much compact. Mine looks like this.

g.V().has('name','e').inE().outV().hasId(b.id())

Thank you Daniel very much.

On Thursday, August 25, 2016 at 11:47:43 AM UTC+3, Daniel Kuppitz wrote:
Since you know vertex e and vertex b, you probably want to find the edge between them (if one exists):

g.V().has("name", "e").inE().filter(outV().is(b))

If all you need is a boolean value, then just append a .hasNext().

Cheers,
Daniel

On Thu, Aug 25, 2016 at 9:15 AM, Eric Cyliu <farsca...@live.com> wrote:
For a vertex 'e', there are three in edges. I would like to check whether one of vertex 'b' is in the list. 
I am quite new for gremlin. Thanks for your help.

//
g.V().has('name','e').inE().outV()
==>v[2]
==>v[4]
==>v[6]
//
b
==>v[2]
// this did not work
g.V().has('name','e').inE().outV() == b
==>false

--
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.
Reply all
Reply to author
Forward
0 new messages