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

Luc*_*rin 6 java graph-theory graph-databases orientdb

我是OrientDB的新手,我想使用新的shortestPath()方法来获取两个顶点之间的边.

我所做的是:

[#-2:1{shortestpath:[#8:1, #8:3]} v0]

asString()

而我只能得到的是[#-2:1{shortestpath:[#8:1, #8:3]} v0].

所以,我想知道如何从这个输出或我得到的输出中提取边缘(好吧,在这种情况下只有一条边,因为这两个顶点是直接连接的)asString():

[#-2:1{shortestpath:[#8:1, #8:3]} v0]

提前致谢!

Lvc*_*vca 1

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

select flatten( shortestpath(" + firstVertex + ", " + secondVertex + ") )
Run Code Online (Sandbox Code Playgroud)

要获得边缘的传出边缘,有很多方法。下面是其中的一些:

select vertices.out from (
   select flatten( shortestpath(" + firstVertex + ", " + secondVertex + ") ) as vertices
)
Run Code Online (Sandbox Code Playgroud)

或者也可以:

select flatten( shortestpath(" + firstVertex + ", " + secondVertex + ").out )
Run Code Online (Sandbox Code Playgroud)