I have three user
vertices. Tom and Mike follow
Bob.
g.addV("user").property(single,"name", "bob")
g.addV("user").property(single,"name", "tom")
g.addV("user").property(single,"name", "mike")
g.V().hasLabel("user").has("name", "tom").as("tom").V().hasLabel("user").has("name", "bob").addE("follow").from("tom")
g.V().hasLabel("user").has("name", "mike").as("mike").V().hasLabel("user").has("name", "bob").addE("follow").from("mike")
I'd like to add an alert
with edges to the users. There should be an edge from Bob to the alert
, and the alert
should have edges out to the users that follow
Bob.
g.V()
.hasLabel("user")
.has("name", "bob")
.as("bob")
.in("follow")
.as("followers")
.addV("alert")
.as("alert")
.addE("alert")
.from("alert")
.to("followers")
.addE("alert")
.from("bob")
.to("alert")
What I end up with is two alert
vertices. Bob has an edge to each of these new alert
vertices, and the alerts have edges out to Tom and Mike (the followers).
I believe this is because when I select the followers, it branches (?) the traversal and starts creating the duplicates but this is not what I want. How do I construct this traversal to make the appropriate selections but only create a single alert
vertex? What I'm trying to get is this:
bob
|
v
alert
| |
v v
mike tom