Java Neo4j重新排列路径

Java Neo4j重新排列路径,java,graph,neo4j,graph-theory,Java,Graph,Neo4j,Graph Theory,Neo4j中是否存在(可能使用PathExpander或RelationshipExpander)根据java中的关系属性(在我的例子中是时间戳)对遍历路径进行重新排序 我搜索了几乎所有的api和社区讨论,但找不到任何提示。您可以创建一个路径扩展程序,根据属性的值扩展路径,类似这样的内容(假设您想要递增的顺序) 您可以创建一个路径扩展程序,该扩展程序根据属性的值扩展路径,如下所示(假设需要递增顺序) public class OrderPathExpander implements PathEx

Neo4j中是否存在(可能使用
PathExpander
RelationshipExpander
)根据java中的关系属性(在我的例子中是时间戳)对遍历路径进行重新排序


我搜索了几乎所有的api和社区讨论,但找不到任何提示。

您可以创建一个路径扩展程序,根据属性的值扩展路径,类似这样的内容(假设您想要递增的顺序)


您可以创建一个路径扩展程序,该扩展程序根据属性的值扩展路径,如下所示(假设需要递增顺序)

public class OrderPathExpander implements PathExpander<String> {

private final RelationshipType relationshipType;
private final Direction direction;

public OrderPathExpander( RelationshipType relationshipType, Direction direction )
{
    this.relationshipType = relationshipType;
    this.direction = direction;
}
@Override
public Iterable<Relationship> expand(Path path, BranchState<String> state)
{
    List<Relationship> results = new ArrayList<Relationship>();
    if ( path.length() == 0 ) {
        for ( Relationship r : path.endNode().getRelationships( relationshipType, direction ) )
        {
                results.add( r );

        }

    }
    else {
    for ( Relationship r : path.endNode().getRelationships( relationshipType, direction ) )
    {
        if ( r.getProperty("timestamp") >= (path.lastRelationship().getProperty("timestamp"))  )
        {
            results.add( r );
        }
    }
    }
    return results;
}
@Override
public PathExpander<String> reverse()
{
    return null;
}
TraversalDescription td = Traversal.description()
        .breadthFirst()
        .expand(new OrderPathExpander(YourRelationshipType, Direction.INCOMING))
        .evaluator(new Evaluator() {...});