繁体   English   中英

在OrientDB的shortestPath()中获得访问的边

[英]Get visited edges in OrientDB's shortestPath()

我是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()的输出中提取边缘(在这种情况下,只有一条边缘,因为这两个顶点是直接连接的asString()

[#-2:1{shortestpath:[2]} v0]

OrientDB具有集合和映射类型。 要收集结果集(感兴趣的内容),必须将其展平:

select flatten( shortestpath(" + firstVertex + ", " + secondVertex + ") )

要获得边缘向外的边缘,有很多方法。 下面几个:

select vertices.out from (
   select flatten( shortestpath(" + firstVertex + ", " + secondVertex + ") ) as vertices
)

或者:

select flatten( shortestpath(" + firstVertex + ", " + secondVertex + ").out )

对我来说,但丁或吕卡(Lvca)的解释是行不通的:

select flatten(shortestPath) from (select shortestPath(#12:0,#12:2,'BOTH')

这会导致控制台错误或OrientDB Studio中未返回任何记录。

相反,当我对函数结果使用别名时,它终于可以工作了。 因此,也许尝试以下形式:

select flatten(sp) from (select shortestPath(#12:0,#15:2,'BOTH') as sp)

(注意。我正在使用v1.7.4)

尝试

select expand(shortestPath) from (select shortestPath(" + firstVertex + ", " + secondVertex + "))

您将收到顶点。

暂无
暂无

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

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