Sequential edge creation between streamed vertices
I would like to create an edge between vertices as they are streamed in sequence from a traversal. I want to connect each vertex to the next one in the stream, like a linear chain of vertices with a
For example, given this
I'd like to achieve something like
My current approach is to create a "sliding window" of vertex pairs:
Which results in:
Next I add edges between each pair:
This works, but I’m not sure if this is the idiomatic way to do this. I think modeling data where vertices are explicitly ordered through an edge connection is not uncommon, right?
next edge.For example, given this
g.V().hasLabel("person").values("name") produces:I'd like to achieve something like
josh -next-> peter -next-> marko -next-> vadasMy current approach is to create a "sliding window" of vertex pairs:
Which results in:
Next I add edges between each pair:
This works, but I’m not sure if this is the idiomatic way to do this. I think modeling data where vertices are explicitly ordered through an edge connection is not uncommon, right?
Solution
i think that's about as good as most approaches. we're missing a step that coudl simplify this code though. i've long wanted a
partition() step so that you could change all that code to just: