Github user dkuppitz commented on a diff in the pull request: https://github.com/apache/tinkerpop/pull/921#discussion_r213065687 --- Diff: docs/src/recipes/cycle-detection.asciidoc --- @@ -48,6 +48,25 @@ the length of the cycle is known to be three and there is no need to exceed that cycle. It returned three, because there was one for each vertex that started the cycle (i.e. one for `A`, one for `B` and one for `C`). This next line introduce deduplication to only return unique cycles. +Note that these traversals won't detect self-loops (vertices directly connected to themselves). +To do so, you would need to `.emit()` a Traverser before the repeat()-loop. + +[gremlin-groovy] +---- +g.addV().property(id,'a').as('a'). + addV().property(id,'b').as('b'). + addV().property(id,'c').as('c'). + addV().property(id,'d').as('d'). + addE('knows').from('a').to('b'). + addE('knows').from('b').to('c'). + addE('knows').from('c').to('a'). + addE('knows').from('a').to('d'). + addE('knows').from('c').to('d'). + addE('self').from('a').to('a').iterate() +g.V().as('a').emit().repeat(out().simplePath()).times(2). + where(out().as('a')).path() --- End diff -- Really just readability. To me `[a,self,a]` looks better than just `[a,a]`.
---