它們之間可能存在一個NEXT關係,因爲傳入的NEXT可以被視爲「先前」。
而且我想你應該索引你的顏色,然後開始從第一個節點遍歷(在這種情況下,「藍」),並有這樣的使用移動:
String[] colors = new String[] { "Blue", "Red", "Yellow" };
Node start = db.index().forNodes("colors").get("color", colors[0]).getSingle();
Traversal.description().uniqueness(Uniqueness.RELATIONSHIP_GLOBAL).breadthFirst().relationships(Types.NEXT, Direction.OUTGOING).evaluator(new Evaluator()
{
@Override
public Evaluation evaluate(Path path)
{
String currentColor = (String) path.endNode().getProperty("color");
boolean endOfTheLine = path.length()+1 >= colors.length;
return currentColor.equals(colors[path.length()]) ?
Evaluation.of(endOfTheLine, !endOfTheLine) : Evaluation.EXCLUDE_AND_PRUNE;
}
}).traverse(start)
我剛纔砍死你的域和該移動器工作得很好!