5

When performing the following traversals:

graph.addVertex("a")
graph.addVertex("b")
graph.addVertex("c")

graph.traversal().V().range(0,2)
graph.traversal().V().range(2,3)

What determines the order in which I get these vertices back when using the range functionality? Am I guaranteed to get all three vertices a, b and c back?

Sheldon
  • 135
  • 9

1 Answers1

4

Without an explicit order().by() you shouldn't expect a guaranteed order.

From the TinkerPop docs:

A Traversal’s result are never ordered unless explicitly by means of order()-step. Thus, never rely on the iteration order between TinkerPop3 releases and even within a release (as traversal optimizations may alter the flow).

Daniel Kuppitz
  • 10,846
  • 1
  • 25
  • 34
  • My unit tests show that this is working at the moment. Does it use something like the vertex id by default or is it just "luck"? – Sheldon Jan 07 '16 at 10:53
  • It's just luck and nobody can guarantee that you'll still see the same default order in TinkerPop's next release. – Daniel Kuppitz Jan 07 '16 at 11:39