graph-databasestitangremlintinkerpoptinkerpop3

How to get all vertices of all incoming/outgoing edges from a vertex scala gremlin


I have a vertex A -> B . I have multiple outgoing/incoming edges created between these two edges with same label.

When i query to get the neighbour vertex ,it is giving me duplicate vertex for each edges it has to the other vertex.

example :

gremlin> graph.traversal().V().has('ID', 'a').both("interference")
==>v[2]
==>v[2]
==>v[2]
==>v[2]
==>v[2]
==>v[2]

http://gremlinbin.com/bin/view/58087f51ba0d5

I do not need the duplicate vertex if it has multiple edges .


Solution

  • That's what the dedup() step is for:

    gremlin> graph.traversal().V().has('ID', 'a').both("interference").dedup()
    ==>v[2]