Add multiple edges in a single gremlin query using vertex ids

1.8k views Asked by At

I am using gremlin REST server in my application and I want to create multiple edges to a vertex in a single query. I have the list of vertex ids from where to create edges to a single vertex.

For eg.- g.V(12,13,14,15).addEdge('uses', g.V(100))

I have tried many traversal steps but cannot get it to work.

1

There are 1 answers

8
stephen mallette On

You should look at the addE() step - here's one example for you can do it:

gremlin> graph = TinkerFactory.createModern()
==>tinkergraph[vertices:6 edges:6]
gremlin> g = graph.traversal()
==>graphtraversalsource[tinkergraph[vertices:6 edges:6], standard]
gremlin> g.V(2,3,4,5,6).as('a').V(1).addE('likes').to('a')
==>e[13][1-likes->2]
==>e[14][1-likes->3]
==>e[15][1-likes->4]
==>e[16][1-likes->5]
==>e[17][1-likes->6]