Neo4j:ACL-主体之间的距离

Neo4j:ACL-主体之间的距离,neo4j,spring-data-neo4j,Neo4j,Spring Data Neo4j,不熟悉图形数据库,并尝试使用Neo4j博客中的示例在Java中创建ACL: 问题在于提供的ruby代码: #Here's our function to check the distance between principals (and to see if they're on the same path at all). def depth_of_principal( principal, reference_principal ) result = reference_princip

不熟悉图形数据库,并尝试使用Neo4j博客中的示例在Java中创建ACL:

问题在于提供的ruby代码:

#Here's our function to check the distance between principals (and to see if they're on the same path at all).
def depth_of_principal( principal, reference_principal )
  result = reference_principal.outgoing( :IS_MEMBER_OF_GROUP ).depth( :all ).path_to( principal )
  return result.nil? ? nil : result.size
end
我应该使用java中的最短路径算法,还是我弄错了?将其移植到java的正确方法是什么

        PathFinder<Path> finder = GraphAlgoFactory.shortestPath(Traversal.expanderForTypes(RelTypes.IS_MEMBER_OF_GROUP, Direction.OUTGOING), maxDepth);
        Path path = finder.findSinglePath(principal, referencePrincipal);
PathFinder=GraphAlgoFactory.shortestPath(Traversal.expanderForTypes(RelTypes.IS_组成员,Direction.OUTGOING),maxDepth);
Path Path=finder.findSinglePath(principal,referencePrincipal);

有一件事不适合maxDepth,但由于我不会有比15更深的路径,我想应该可以吧?

当然,使用最短路径(因为您确实在寻找这两个主体之间的最短路径)是合适的。在这里,你可以将最大深度视为一个安全网,这样你的穿越就不会疯狂。

看起来不错。最短路径算法也使用双向遍历器,应该是最快的距离查找方式。