我是 OrientDB 的新手,我想使用新的 shortestPath() 方法来获取两个顶点之间的边。
我做的是:
OSQLSynchQuery<T> sql = new OSQLSynchQuery<T>("select shortestpath(" + firstVertex + ", " + secondVertex + ").asString()");
List<ODocument> execute = db.query(sql);
而我只能得到的是[#-2:1{shortestpath:[#8:1, #8:3]} v0]
。
所以,我想知道如何从这个输出或没有 asString() 的输出中提取边(好吧,在这种情况下只有一条边,因为这两个顶点直接相连)
:
[#-2:1{shortestpath:[2]} v0]
最佳答案
OrientDB 有集合和 map 类型。要使集合成为结果集(您感兴趣的),您必须将其展平:
select flatten( shortestpath(" + firstVertex + ", " + secondVertex + ") )
要得到出边的边有很多种方法。下面是其中一些:
select vertices.out from (
select flatten( shortestpath(" + firstVertex + ", " + secondVertex + ") ) as vertices
)
或者还有:
select flatten( shortestpath(" + firstVertex + ", " + secondVertex + ").out )
关于java - 在 OrientDB 的 shortestPath() 中获取访问过的边,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16222813/