3.6. Traversal

Traversing a graph means visiting its nodes, following relationships according to some rules. In most cases only a subgraph is visited, as you already know where in the graph the interesting nodes and relationships are found.

Cypher provides a declarative way to query the graph powered by traversals and other techniques. See Cypher Query Language for more information.

Neo4j comes with a callback based traversal API which lets you specify the traversal rules. At a basic level there’s a choice between traversing breadth- or depth-first.

For an in-depth introduction to the traversal framework, see Chapter 33, The Traversal Framework. For Java code examples see Section 32.7, “Traversal”.