1
votes

I am performing a custom traversal in Neo4J, using my own evaluator. In the traversal are two nodes, connected by two different relationships. What I'm seeing is that only one of the two relationships will be walked during the traversal.

However, my custom evaluation changes its behavior based on whether both relationships are present.

It seems like during a traversal, Neo4J maintains a set of visited nodes, and if a candidate path ends at a node that has already been visited, then that path is never sent to my evaluator. Is there a way around this? How can I have a custom evaluator examine every possible path to the nodes?

Here's a quick example:

Say that the graph looks like this:

             E----D----A====B----C

The traversal begins at A. A has two different relationships tying it to B (of two different types). All of the remaining nodes are connected by only 1 relationship. The goal of the evaluator is to return A-D, A-B, and B-C, but not D-E. The determination that B-C is valid comes from the fact that there are two relationships between A and B.

How can this be solved?

1

1 Answers

3
votes

You may need to think your use case through a bit more carefully.

One suggestion is that when you use the traversal framework in java, basically you can build a TraversalDescription and then iterate through what comes back from it by relationships, rather than by Paths or by Nodes. If your primary complaint is that each node is visited only once, you can change the TraversalDescription to specify RELATIONSHIP_GLOBAL guaranteeing that all relationships will be followed, whether or not that causes you to hit a node more than once.

More broadly, traversers don't tend to go over the same material more than once because if they did, you'd need to be ultra careful about specifying a termination condition. If hitting certain nodes or relationships more than once is OK, when do you know that you're done?