문제

I am trying to understand Neo4J java traversal API but after a thorough reading I am stuck on certain points.

What I seem to know:

Difference between PathExpander and BranchOrderingPolicy. As per my understanding, the former tells what relationships are eligible to be explored from a particular position and the latter specifies the ordering in which they should be evaluated.

I would like to know the following things:

  1. Whether or to what extent this understanding is correct or if it can be altered to give the correct understanding.

  2. If correct, how is PathExpander different from Evaluator.

  3. How does PathExpander and BranchOrderingPolicy work. What I intend to ask is, is PathExpander consulted everytime a relationship is added to the traversal and what does it do with the iterable of relationships returned. Similarly with branch ordering.

  4. During traversal how and when do the components Expander, BranchOrdering, Evaluator, Uniqueness come into picture. Basically I wish to know the template algorithm where one would say like first expander is asked for a collection of relationships to expand and then ordering policy is consulted to select one of the eligibles....

  5. If correct, does the ordering policy specified by BranchOrderingPolicy apply on the eligible relationships only(after expander has done). Perhaps it must be.

Please include anything else that might be helpful in understanding the API.

도움이 되었습니까?

해결책

I'll try to describe these parts to the best of my ability.

  1. As to the difference between PathExpander and BranchOrderingPolicy: a PathExpander is invoked for each traversal branch the first time the traversal continues from that branch. (A traversal branch is a node including the path leading up to that node, note that there may be many paths, i.e. many branches to the same node, mostly depending on uniqueness). The result of invoking the PathExpander is an Iterator<Relationship> which will lazily provide new relationships off of that traversal branch when needed. That brings us to BranchOrderingPolicy which looks at all alive traversal branches. By "alive" I mean a branch that has one or more relationships on it such that more branches can be created from it. Given all alive branches it picks one of them, following its next relationship (retreived from the relationship iterator on that branch, potentially if it's the first call initializes that iterator using the PathExpander (as described above).
  2. Difference between PathExpander and Evaluator: that split is very much a matter of convenience and separation of concerns. PathExpander grows the number of branches and Evaluator filters, i.e. reduces the number of branches. An expander creates new branches that are evaluated by the Evaluator. With that said you can write a PathExpander that does both those things and it could be more efficient doing so. But the convenience of having them separated, where there can be multiple Evaluators is quite useful.
  3. See above (1)
  4. Some of this is described in (1), but a broader picture would be that the BranchOrderingPolicy is the driver in the traversal - out of every alive branch it picks one and follows it one relationship out to a new branch. Only branches that comply with the selected uniqueness will be created. The relationships for a branch are retreived on the first time this happens for every branch, in the form of a lazy relationship iterator using the PathExpander. New branches get evaluated the first time they are selected where one result of the evaluation is whether or not this branch is a dead end and the other is whether or not to include it in the result out to the user.
  5. I think the above explains that

Is this sufficient information?

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top