addE
Specify an edge from a traversal.
Synopsis
g.V(vertex)
.addE('edgeLabel')
.to(vertex)
| Syntax conventions | Description |
|---|---|
| Lowercase and uppercase | Literal keyword. Includes (). |
Italics |
Variable value. Replace with a user-defined value. |
[] |
Optional. Square brackets ( [] ) surround
optional command arguments. Do not type the square brackets. |
{} |
Group. Braces ( {} ) identify a group to choose
from. Do not type the braces. |
| |
Or. A vertical bar ( | ) separates alternative
elements. Type any one of the elements. Do not type the vertical
bar. |
... |
Repeatable. An ellipsis ( ... ) indicates that
you can repeat the syntax element as often as required. |
Description
The addE() step is a map/sideEffect. An edge is added from a traversal
g using addE between two existing vertices. A previously created
edge label must be specified.
Examples
Create an edge with an edge label
knows between two vertices, stephenSmith and
johnDoe. The first two lines assign the already existing vertices to
variable names for use in the addE()
step.// Get two users to join with an edge
johnDoe = g.V().has('name','John Doe').next()
stephenSmith = g.V().has('name','Stephen Smith').next()
// Create the edge between Stephen and John
g.V(stephenSmith).addE('knows').to(johnDoe)