orientdb icon indicating copy to clipboard operation
orientdb copied to clipboard

Incomplete traverse

Open Dmitry-PlainID opened this issue 10 years ago • 4 comments

In our graph we have 2 different paths between 2 objects. (as showed in image)

https://s12.postimg.org/4f1brhzcd/Screen_Shot_2016_11_24_at_14_50_23.png

Object A RID: 39:504 Object B RID: 53:0

We try to get both of the paths by running: SELECT $path FROM (traverse in(), out() FROM 39:504 WHILE $depth < 5 strategy BREADTH_FIRST) WHERE (@class='Permission' OR @class instanceof 'XResource')

And it returns only one path from object A to object B.

Dmitry-PlainID avatar Nov 24 '16 13:11 Dmitry-PlainID

Hi @Dmitry-PlainID

The TRAVERSE operation does not re-traverse already traversed vertices, this is why you are seeing only one path. I think this explains your results. This behavior was mainly implemented to avoid infinite processing in cyclic graphs.

Thanks

Luigi

luigidellaquila avatar Nov 24 '16 14:11 luigidellaquila

Hi, it's explains the result, this behavior is a technic solution of cycling, but function traverse should return all possible paths. In my case I need know all possible paths between two vertices.

Thanks, Dmitry

Dmitry-PlainID avatar Nov 24 '16 18:11 Dmitry-PlainID

Hi Dmitry,

I'm afraid you have to write your own JS (or Java) function for this. In the roadmap we have the implementation of a shortestPaths() function to calculate all the possible paths between two nodes, sorted by length, but it's not available yet

Thanks

Luigi

luigidellaquila avatar Nov 28 '16 08:11 luigidellaquila

@Dmitry-PlainID, have you managed to solve this issue on your side? I have the same case - I'm migrating graph-like structure from Oracle (CONNECT BY PRIOR query) and reached the same problem. @luigidellaquila there is NO_CYCLE option in Oracle database to avoid cycle problem. Maybe the same could be achieved in OrientDB? It was unpleasant surprise for me to notice that it's not possible to evaluate all paths outgoing from the vertex.

jgrabowski avatar Nov 13 '17 14:11 jgrabowski