fmish
fmish

Reputation: 131

get edges and vertices from shortest path i OrientDb

Im trying to get the shortest path between two vertices in OrientDb problem is Im only getting vertices. I need the edges as well to display in JavaScript.

I can see the Graph in Studio shows the edges as well, but when I run the query using the Studio Browse I only get the vertices.

What am I missing?

This is my query:

SELECT expand(path) FROM ( SELECT shortestPath($from, $to) AS path LET $from = (SELECT FROM v WHERE entity_id='person_6'), $to = (SELECT FROM v WHERE entity_id='cdr_22') UNWIND path )

Upvotes: 0

Views: 140

Answers (1)

fmish
fmish

Reputation: 131

Answering my own question, this query gets in and out edges of the vertices, intersect them (to get only edges that are both in and out), and does union with vertices.

SELECT expand(path) FROM (
select unionall( intersect(shortestPath($from, $to).inE(), shortestPath($from, $to).outE()), shortestPath($from, $to).inE(), shortestPath($from, $to).outE()) AS path LET
$from = (SELECT FROM v WHERE entity_id='person_6'),
$to = (SELECT FROM v WHERE entity_id='cdr_22')
UNWIND path )

Upvotes: 2

Related Questions