orientdb的dijkstra函数不适用于tinkerpop API

时间:2016-09-01 09:18:37

标签: orientdb tinkerpop tinkerpop-blueprint

下面的代码没有给出正确的结果,我做错了什么..?

OrientGraph graph = factory.getTx();

for (OrientVertex v : (Iterable<OrientVertex>) graph.command(
                new OCommandSQL("SELECT dijkstra(#97:1334, #97:1335, 'calculated_length') FROM STRUCTURE")).execute()) {
                      System.out.println("Path " + (ORID)v.getId());
                    }

当我直接执行查询时,我得到了正确的结果。感谢。

1 个答案:

答案 0 :(得分:3)

我使用了这段代码并且有效

String query = "select expand(dijkstra) from (SELECT dijkstra(#21:0, #24:0, 'calculated_length') FROM STRUCTURE limit 1)";
Iterable<OrientVertex> it = g.command( new OCommandSQL(query)).execute();
for (OrientVertex v : it) { 
    System.out.println("Path " + (ORID)v.getId());     
}

希望有所帮助