Database Reference
In-Depth Information
When either NODE_GLOBAL or RELATIONSHIP_GLOBAL is set, the traversal can be
memory-hungry, especially in very connected, large graphs. Each node (in the case of
NODE_GLOBAL ) or relationship (in the case of RELATIONSHIP_GLOBAL ) must be
remembered for uniqueness constraint reasons. This is where the NODE_RECENT and
RELATIONSHIP_RECENT settings come into play. When using these settings, the
uniqueness constraint is loosened slightly.
With NODE_RECENT , there's a cap to the number of visited nodes that are remembered.
Theruleisthesameasfor NODE_GLOBAL —anodecanbevisitedonlyonce—butonlythe
collection of recently visited nodes are remembered for comparison. The number of recent
nodes to be remembered can be passed as the second argument to the uniqueness method,
as in the following snippet:
TraversalDescription description = Traversal.description()
.uniqueness(Uniqueness.NODE_RECENT, 1000)
With RELATIONSHIP_RECENT , the same rule as RELATIONSHIP_GLOBAL applies,
so relationships can be visited only once. But during the traversal, only a specified number
of relationships are remembered for comparison. The number of recent relationships that
are remembered can be configured using the second argument to the uniqueness method,
as in the following snippet:
TraversalDescription description = Traversal.description()
.uniqueness(Uniqueness.RELATIONSHIP_RECENT, 1000)
Since Neo4j version 1.8, the Traversal API has included two more settings:
NODE_LEVEL —Guarantees that nodes on the same level (nodes that have the
same distance from the starting node) are only visited once during traversal
RELATIONSHIP_LEVEL —Guarantees that relationships on the same level
(from nodes that have the same distance from the starting node) are visited only
once during traversal
In the next section we're going to look at bidirectional traversals, which allow you to sig-
nificantly increase the performance of one type of traversal.
Search WWH ::




Custom Search