As described in another question, I am attempting to add several “identity” vertices into a “group” vertex. Based on the recipe recommendation, I’m trying to write the traversal steps in such a way that the traversers iterate the identity vertices instead of appending extra steps in a loop. Here’s what I have:
gts.V(group) .addE('includes') .to(V(identityIds as Object[])) .count().next()
This always returns a value of 1, no matter how many IDs I pass in identityIds
, and only a single edge is created. The profile indicates that only a single traverser is created for the __.V
even though I’m passing multiple values:
Traversal Metrics Step Count Traversers Time (ms) % Dur ============================================================================================================= TinkerGraphStep(vertex,[849e1878-86ad-491e-b9f9... 1 1 0.633 40.89 AddEdgeStep({label=[Includes], ~to=[[TinkerGrap... 1 1 0.915 59.11 TinkerGraphStep(vertex,[50d9bb4f-ed0d-493d-bf... 1 1 0.135 >TOTAL - - 1.548 -
Why is only a single edge added to the first vertex?
Advertisement
Answer
The to()
syntax you are using is not quite right. A modulator like to()
expects the traversal you provide it to produce a single Vertex
not a list. So, given V(identityIds)
only the first vertex returned from that list of ids will be used to construct the edge. Step modulators like to()
, by()
, etc. tend to work like that.
You would want to reverse your approach to:
gts.V(identityIds) .addE('includes') .from(V(group)) .count().next()
But perhaps that leads back to your other question.