Get visited edges in OrientDB shortestPath ()

I am new to OrientDB and I want to use the new shorttestPath () method to get edges that are between two vertices.

What I am doing is:

OSQLSynchQuery<T> sql = new OSQLSynchQuery<T>("select shortestpath(" + firstVertex + ", " + secondVertex + ").asString()");

List<ODocument> execute = db.query(sql);

and what I can only get [#-2:1{shortestpath:[#8:1, #8:3]} v0].

So, I wanted to know how I can extract edges (well, in this case, only one edge, because these two vertices are directly connected) from this output or from the output that I get without asString():

[#-2:1{shortestpath:[2]} v0]
+6
source share
3 answers

OrientDB has types of collections and maps. To create a collection of a result set (which you are interested in), you should flatten it:

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

There are so many ways to get the edges of outgoing edges. Below are some of them:

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

:

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

, Lvca:

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

, Studio OrientDB.

, , . , , :

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

(. v1.7.4)

+1

Try

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

You will get the tops.

0
source

All Articles