Reputation: 61
I'm using OrientDB Community Edition 2.1.16.
This is the graph of my data:
I'm trying to retrieve all paths for given node using:
select $path from (traverse out('E1') from #13:5)
But what I get it's quite strange:
I would have expected that every path passing through second level nodes (#13:1,#13:2,#13:3) would have reached the root node (#13:0). Something like:
(#13:5).out[0](#13:4).out[0](#13:1).out[0](#13:0)
(#13:5).out[0](#13:4).out[1](#13:2).out[0](#13:0)
(#13:5).out[0](#13:4).out[2](#13:3).out[0](#13:0)
It's that correct or what?
If yes, is there the possibility to get this result? I mean to have a complete path from #13:5 to #13:0 passing through the second levels' nodes.
Thanks
Upvotes: 1
Views: 623
Reputation: 1982
using your query
select $path from (traverse out('E1') from #13:5)
you get the path relative to every result of the traverse, you can verify that by adding the *
select *,$path from (traverse out('E') from #9:5)
In this way you get all the vertexes traversed and the path to get there from starting node.
Upvotes: 0
Reputation: 850
The result you get depends on the strategy has the traverse, you can set two types: DEPTH_FIRST, the default, and BREADTH_FIRST. I think maybe you interests of the two strategies. For more info you can look at this link.
DEPTH_FIRST strategy
This is the default strategy used by OrientDB for traversal. It explores as far as possible along each branch before backtracking. It's implemented using recursion. To know more look at Depth-First algorithm. Below the ordered steps executed while traversing the graph using DEPTH_FIRST strategy:
BREADTH_FIRST strategy
It inspects all the neighboring nodes, then for each of those neighbor nodes in turn, it inspects their neighbor nodes which were unvisited, and so on. Compare BREADTH_FIRST with the equivalent, but more memory-efficient iterative deepening DEPTH_FIRST search and contrast with DEPTH_FIRST search. To know more look at Breadth-First algorithm. Below the ordered steps executed while traversing the graph using BREADTH_FIRST strategy:
Upvotes: 0