简体   繁体   English

如何在neo4j v2.0中使用neo4j核心遍历算法遍历图

[英]How to traverse graph using neo4j core traversal algo in neo4j v2.0

I checked the code in the neo4j manual and changed version to 2.0 The code at this link looks like this: 我检查了neo4j手册中的代码并将版本更改为2.0。此链接上的代码如下所示:

for ( Path position : Traversal.description()
    .depthFirst()
    .relationships( Rels.KNOWS )
    .relationships( Rels.LIKES, Direction.INCOMING )
    .evaluator( Evaluators.toDepth( 5 ) )
    .traverse( node ) ){
output += position + "\n";}

When I write the same code in my program, it gives me deprecation warning for org.neo4j.kernel.Traversal . 当我在程序中编写相同的代码时,它会给我org.neo4j.kernel.Traversal弃用的警告。

My question is for neo4j v2.0 what is the way to do traversals using core java API. 我的问题是对于neo4j v2.0,使用核心Java API进行遍历的方式是什么? I also tried the same using cypher queries but they are slow (takes more than 1 sec) for my queries and I have read in the comparison here that java traversal APIs are faster than cypher ones. 我也试过同样使用暗号查询,但他们是缓慢的(时间超过1秒)我的查询和我在比较时这里说的Java API的遍历比CYPHER更快。

I also want to try out dijkstra algorithm in neo4j but when I try the code given in the manual for dijkstra I again get the deprecation warning. 我也想尝试neo4j中的dijkstra算法,但是当我尝试dijkstra手册中给出的代码时,我再次收到弃用警告。

Where can I find the examples/code illustrating the use of core java traversal API in neo4j v2.0 ? 在哪里可以找到说明在neo4j v2.0中使用核心Java遍历API的示例/代码?

You should use the new TraversalDescription -framework. 您应该使用新的TraversalDescription -framework。 The TraversalDescription-object is accessable via your GraphDatabaseService by calling traversalDescription() on it. 通过在GraphDatabaseService上调用traversalDescription()可以访问TraversalDescription对象。 Defining the traversal then is similar to the old methods. 然后定义遍历类似于旧方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM