在OrientDB的shortestPath()中获取访问边 [英] Get visited edges in OrientDB's shortestPath()
问题描述
我是OrientDB的新手,我想使用新的shortestPath()方法来获取两个顶点之间的边。
I am new to OrientDB and I want to use the new shortestPath() method to get the edges that are between two vertices.
我所做的是:
OSQLSynchQuery< T> sql = new OSQLSynchQuery< T>(select shortestpath(+ firstVertex +,+ secondVertex +)。asString());
列表与LT; ODocument> execute = db.query(sql);
我只能得到 [# - 2:1 {shortestpath:[#8:1,#8:3]} v0]
。
所以,我想知道如何提取这个边缘(好吧,在这种情况下只有一条边,因为这两个顶点是直接连接的)来自这个输出,或者来自我没有的输出asString()
:
So, I wanted to know how could I extract the edges (well, only one edge in this case, because these two vertices are directly connected) from this output or from the output that I get without asString()
:
[# - 2:1 {shortestpath:[2]} v0]
提前致谢!
推荐答案
对我而言,dante或Lvca如何解释它并不起作用:
For me, it didn't work how dante or Lvca explained it:
select flatten(shortestPath) from (select shortestPath(#12:0,#12:2,'BOTH')
这导致控制台出错或者没有在OrientDB Studio中返回记录。
This lead to errors in the console or to no records returned in the OrientDB Studio.
相反,当我使用函数结果的别名时,它终于工作了。所以可以试试这个表格:
Instead, when I used an alias for the function result, it worked finally. So maybe try out this form:
select flatten(sp) from (select shortestPath(#12:0,#15:2,'BOTH') as sp)
(注。我正在使用v1.7.4)
(Note. I'm using v1.7.4)
这篇关于在OrientDB的shortestPath()中获取访问边的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!