Github user mpollmeier commented on the issue: https://github.com/apache/tinkerpop/pull/715 `emit` modifies the behaviour of the repeat traversal, and I am unsure why that is. Let me explain what I know and hopefully you or someone else can fill the blanks. Let's take my toy graph `v5 <- v3 <- v1 <- v0 -> v2 -> v4 -> v6` since it's easier to see where you are with a simple println of the vertex. Without emit, this PR does what it's supposed to do: DFS. First the even numbers, then the odds. ``` graph = TinkerGraph.open() v0 = graph.addVertex("l0") v1 = graph.addVertex("l1") v2 = graph.addVertex("l1") v3 = graph.addVertex("l2") v4 = graph.addVertex("l2") v5 = graph.addVertex("l3") v6 = graph.addVertex("l3") v0.addEdge("e", v2) v2.addEdge("e", v4) v4.addEdge("e", v6) v0.addEdge("e", v1) v1.addEdge("e", v3) v3.addEdge("e", v5) graph.traversal().V(v0).repeat(sideEffect{println("inside repeat at " + it)}.out()).times(3) inside repeat at v[0] inside repeat at v[2] inside repeat at v[4] ==>v[6] inside repeat at v[1] inside repeat at v[3] ==>v[5] ``` However if I add an `emit()` it becomes BFS again: ``` graph.traversal().V(v0).emit().repeat(sideEffect{println("inside repeat at " + it)}.out()).times(3) ==>v[0] inside repeat at v[0] ==>v[2] inside repeat at v[2] ==>v[1] inside repeat at v[1] ==>v[4] inside repeat at v[4] ==>v[6] ==>v[3] inside repeat at v[3] ==>v[5] ``` I tried to understand it in the debugger, and the core difference seems to be the behaviour of `this.starts.hasNext()` in `RepeatEndStep.standardAlgorithm`, which is an `ExpandableStepIterator`. * without emit, `hasNext` finds that `this.hostStep.getPreviousStep().hasNext()` is true, because it asks it's `previousStep` (which is a `VertexStep(OUT)`), which in turns has some results for `processNextStart`. * with emit, the above chain returns false, which in turn leads to a NoSuchElementException, which short-circuits and `while (true)` loop, which results in losing DFS semantics. I don't know where these different semantics derive from.
---