Shortest path one direction

36 views
Skip to first unread message

Boris Wexler

unread,
Mar 31, 2015, 12:04:02 PM3/31/15
to orient-...@googlegroups.com
Hi - I am currently working on a twitter like application with orient db, where users can follow eachother (one directional relationship). I am trying to find a good way to get the shortest path between two vertices one directionally. In other words, if I have users A, B, C and A follows B who follows C who follows A (but not the other way around), I am looking for something that will tell me that the shortest path from A to C is A->B->C , and not A->C.

I tried using the shortestpath() function but it seems agnostic to direction and returns the same results no matter which vertex is passed as first argument. Does anyone know of a good way to do this?

Thanks 

Natal Kaplya

unread,
Mar 31, 2015, 1:33:28 PM3/31/15
to orient-...@googlegroups.com
Right now tested shortestPath():
select shortestPath(#9:0, #9:2, 'OUT')
returns:
"shortestPath": [ "#9:0", "#9:1", "#9:2" ]
On the contrary this:
select shortestPath(#9:0, #9:2, 'IN')
returns 
"shortestPath": [ "#9:0", "#9:2" ]

On the graph:
#9:0 --> #9:1 --> #9:2 ----> #9:0

So this function is sensible to direction. 
OrientDB 2.0.5

Boris Wexler

unread,
Apr 2, 2015, 9:56:39 AM4/2/15
to orient-...@googlegroups.com
Thanks! I missed the 'In'/'out' parameter
Reply all
Reply to author
Forward
0 new messages