0

I am using this library for gremlin scala by https://github.com/mpollmeier/gremlin-scala#getting-started.

Here is a use case there is three vertex(A,B,C). Two A,B vertex is already connected with edges name "IS".

Now I want to drop "IS" edge between A,B and connect A to C with edge named "IS" in single gremlin scala query. Earlier I wrote two different gremlin scala query one is for dropping edge and other is for adding edge but I want to combine these two queries in one.

Erick Ramirez
  • 13,964
  • 1
  • 18
  • 23
Mukul Lohar
  • 111
  • 7

1 Answers1

1

Assuming that all of the following are supported by that library, you should be able to run the following which will drop a relationship between V(1) and V(2) while adding an edge between V(1) and V(6).

Leaned upon a related question in order to formulate this, which can be found here

For your case: A=1, B=2, C=6

gremlin> graph = TinkerFactory.createModern()
==>tinkergraph[vertices:6 edges:6]
gremlin>  g = graph.traversal()
==>graphtraversalsource[tinkergraph[vertices:6 edges:6], standard]
gremlin> g.E()
==>e[7][1-knows->2]
==>e[8][1-knows->4]
==>e[9][1-created->3]
==>e[10][4-created->5]
==>e[11][4-created->3]
==>e[12][6-created->3]
gremlin> g.V(1).as('A').bothE().where(otherV().hasId(2)).as('drop').addE('IS').from('A').to(V(6)).select('drop').drop()
gremlin> g.E()
==>e[8][1-knows->4]
==>e[9][1-created->3]
==>e[10][4-created->5]
==>e[11][4-created->3]
==>e[12][6-created->3]
==>e[13][1-IS->6]