Orientdb和shortestpath

时间:2016-10-17 11:29:37

标签: orientdb shortest-path

我遇到最短距离的问题。 查询做得很好,但我无法在java控制台中打印输出 有人能帮助我吗?

        String query = "SELECT shortestPath((SELECT FROM V WHERE vertexID = 1), (SELECT  FROM V WHERE vertexID = 4), 'BOTH')";
        Iterable<OrientVertex> res = db.command(new OCommandSQL(query)).execute();
while(res.iterator().hasNext()){
            OrientVertex v = res.iterator().next();
            System.out.println(v.getId());
            }

我在浏览器上找到了这个:

但是在Java控制台中我得到了这个:

1 个答案:

答案 0 :(得分:0)

试试这段代码:

    String query = "select expand(shortestPath) from (select shortestPath((SELECT FROM V WHERE vertexID = 1),(SELECT  FROM V WHERE vertexID = 4),BOTH))";
    Iterable<OrientVertex> res = db.command(new OCommandSQL(query)).execute();
    while (res.iterator().hasNext()) {
        OrientVertex v = res.iterator().next();
        System.out.println(v.getId());
    }

希望它有所帮助。