My Graph Looks like this:
A --1--> B --2--> C --3--> D
|
4
|
V
E
I want to get the shortest paths from A to D. But I do not want the vertices but the edges that make up the path.
From here I ended up with:
select expand(shortestPath) from (select shortestPath(A, D).outE())
But the result does not only contain the correct answers 1, 2, 3 but also 4, so all outgoing edges from the vertices that make up the path.
It would be cool if I could select shortestpath or dijkstra as a traversal strategy. IMO this is where they belong.
OrientDB already has dijkstra function. Howerver to filter only the edges do:
select from (select expand( shortestPath(A, D) ) ) where @this instanceof 'E'
Refer, this post , I have posted a possible solution using SQL along with explanation.
In brief, the SQL is:
SELECT FROM (TRAVERSE * FROM #51:0 WHILE
(@this INSTANCEOF V AND @rid IN (SELECT shortestPath(#51:0, #60:40).asList())) OR
(@this INSTANCEOF E AND (@this.in IN (SELECT shortestPath(#51:0, #60:40).asList()))) );
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.