In case you are interested, I implemented cycle detection by using Tarjan algorithm, not the traversal. The code is visible in the Italian Wikipedia, I hope it's intelligible although the language. http://it.wikipedia.org/wiki/Algoritmo_di_Tarjan_per_le_componenti_fortemente_connesse#Implementazione_in_Java
Hi Jacopo Farina Il giorno ven, 25/03/2011 alle 13.51 +0100, Mattias Persson ha scritto: > I think you could implement this using RELATIONSHIP_GLOBAL uniqueness, like > (from the top of my head): > > Traversal.description().uniqueness( Uniqueness.RELATIONSHIP_GLOBAL ) > .evaluator(new Evaluator() { > public Evaluation(Path path) { > return path.length() > 0 && endNodeOccursPreviouslyInPath( > path ) ? > Evaluation.INCLUDE_AND_CONTINUE : > Evaluation.EXCLUDE_AND_CONTINUE; > } > > private boolean endNodeOccursPreviouslyInPath(Path path) { > Node endNode = path.endNode(); > int counter = 0; > for ( Node node : path.nodes() ) { > if ( counter++ < path.length() && node.equals( endNode ) ) > return true; > } > return false; > } > } ).traverse(...); > > This should (if it even compiles :) ) return paths containing cycles. > Something like this you're looking for? > > 2011/3/25 Wouter De Borger <w.debor...@gmail.com> > > > Hi all, > > > > I would like to detect all cycles in a traversal. > > > > I know the traversal framework has cycle avoidance built-in, but there > > doesn't seem to be an API for cycle detection! > > > > Has anyone already implemented a cycle detector for traversals? > > > > Thanks in advance, > > Wouter > > _______________________________________________ > > Neo4j mailing list > > User@lists.neo4j.org > > https://lists.neo4j.org/mailman/listinfo/user > > > > > _______________________________________________ Neo4j mailing list User@lists.neo4j.org https://lists.neo4j.org/mailman/listinfo/user