我想遍历具有相同关系的图表,但首先是传出,其次是传入(按此特定顺序)。我找到了
traverse(Traverser.Order traversalOrder,
StopEvaluator stopEvaluator,ReturnableEvaluator returnableEvaluator,
RelationshipType firstRelationshipType,Direction firstDirection,
RelationshipType secondRelationshipType,Direction secondDirection)
我还没有找到任何关于如何填充字段traversalOrder stopEvaluator,returnableEvaluator
的示例我的示例代码是:
for (Path position : graphDb.traversalDescription()
.relationships(Wikilections_user.RelTypes.Voted, Direction.OUTGOING)
.relationships(Wikilections_user.RelTypes.Voted, Direction.INCOMING)
.evaluator(Evaluators.fromDepth(1))
.evaluator(Evaluators.toDepth(2))
.evaluator(Evaluators.includeWhereEndNodeIs(node2))
.uniqueness(Uniqueness.RELATIONSHIP_PATH)
//.evaluator(Evaluators.excludeStartPosition())
.traverse(node1)) {
我想更改部分.traverse(node1))以便仅返回路径,首先我遇到传出,其次我遇到传入关系。 怎么可能?
答案 0 :(得分:1)
对于更复杂的行为,您可以使用TraversalDescription.expand()
提供自定义PathExpander
。伪实现可能如下所示:
class MyPathExpander implements PathExpander {
Iterable<Relationship> expand(Path path, BranchState state) {
switch (path.length()) {
case 0:
return path.endNode().getRelationships(Wikilections_user.RelTypes.Voted, Direction.OUTGOING);
case 1:
return path.endNode().getRelationships(Wikilections_user.RelTypes.Voted, Direction.INCOMING)
default:
return Iterables.empty();
}
}
}