Traverse directed edges recursively with OrientDB

谁说我不能喝 提交于 2019-12-23 18:13:17

问题


I am trying to recursively traverse outbound edges from a given node, but not the inbound ones. I want both out edges and out vertices in the result of my query.

In the following graph, starting from (a), I need (a), (b), (c), (d), (e), including the edges, but not the part after (c), which is <-- (x)

(a) -->  (b) --> (c) <-- (x)
 ˙-->  (d) --> (e)

If I try doing the following, then it traverses everything recursively, irrespective of edge direction, thus also returning (x):

TRAVERSE * FROM (SELECT FROM a) LIMIT -1` 

If I dont traverse *, butoutE()`, it only retrieves the starting node and its direct neighbours: (a), (b), (d), so it does not do recursion.

traverse outE() from (SELECT FROM a) LIMIT -1

I also tried to follow the documentation at here, and traversed V.out, E.in but it only returns (a) without traversing.

traverse V.out, E.in from (SELECT FROM a) LIMIT -1`

Also tried playing with variants, like WHILE $depth < 10, but that hasn't made any difference and now I'm stuck.

Running OrientDB 2.0.12


回答1:


Graph :

Traversal query to get only the outgoing edges recursively starting from #33:289990 :

traverse out('IsFriendsWith') from #33:289990

Traversal query to get more then one edge class outgoing vertices recursively :

traverse out('IsFriendsWith'), out('secondEdgeClassName') from #33:289990

Traversal query to get the edge and vertex instances recursively :

traverse out('IsFriendsWith'), outE('IsFriendsWith') from #33:289990


来源:https://stackoverflow.com/questions/31561945/traverse-directed-edges-recursively-with-orientdb

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!