Adding a edge for existing vertices [TP3]

3,184 views
Skip to first unread message

smunx

unread,
Feb 1, 2016, 7:11:37 AM2/1/16
to Gremlin-users
Hi,
I am using tinkerpop 3 and TinkerGraph


--Thanks

Daniel Kuppitz

unread,
Feb 1, 2016, 7:27:17 AM2/1/16
to gremli...@googlegroups.com
You can't add an edge by only using a GraphTraversalSource (e.g. g.addE(...)), but you can edges within a traversal:

g.V().as('a').out('mother').as('b').addE('child').from('b').to('a')

The JavaDocs you should be looking at are these:


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/daacb6e5-a7c5-4d46-a3e6-56e82cbc8c25%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

smunx

unread,
Feb 1, 2016, 11:24:56 PM2/1/16
to Gremlin-users
Hi Daniel,
Can you please explain the above query in detail ?
But what about the newly created vertex that dose not have a connection with the graph yet ? 
And should I specify the vertex index id if I want to target a specific node ?

   g.V(13).as('a').out('mother').as('b').addE('child').from('b').to('a')

Thanks

Daniel Kuppitz

unread,
Feb 2, 2016, 7:57:04 AM2/2/16
to gremli...@googlegroups.com
But what about the newly created vertex that dose not have a connection with the graph yet ? 

Maybe show your code..? If you have a reference to a vertex, then you can simply do this:

existingVertex.addEdge("label", otherVertex)

Since this is pretty basic stuff, it's probably worth to give the Getting Started tutorial a read.

Cheers,
Daniel


Michalis Michaelidis

unread,
Dec 20, 2016, 12:44:19 PM12/20/16
to Gremlin-users
I think what you are trying to do could be done like that:

g.addV("SomeLabel").as("newA").V(existingBId).as("existingB").addE("SomeEdge").from("newA").to("existingB")
Reply all
Reply to author
Forward
0 new messages