Github user dkuppitz commented on a diff in the pull request: https://github.com/apache/tinkerpop/pull/921#discussion_r213364785 --- Diff: docs/src/recipes/cycle-detection.asciidoc --- @@ -48,6 +48,31 @@ 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(outE().inV().simplePath()). + times(2). + outE().inV().where(eq('a')). + path(). + by(id). + by(label) +---- + --- End diff -- I mean just put the paragraph that starts with > The above case assumed that ... above your new block that starts with > Note that these ... That would make more sense, no?
---