Path Expander Overview

The Cypher query language supports variable-length pattern matching, but path expansion is limited to relationship types. The path expander procedures enable more powerful variable length path traversals, where users can specify the following:

  • the direction of the relationship per relationship type.

  • a list of label names which act as a "whitelist" or a "blacklist".

  • end nodes for the expansion.

This functionality is supported by five procedures:

Procedure Description Documentation

apoc.path.expand()

expands paths using Cypher’s default expansion modes (bfs and 'RELATIONSHIP_PATH' uniqueness).

Expand paths

apoc.path.expandConfig()

expands paths with more flexible configuration of parameters and expansion modes.

Expand paths with config

apoc.path.subgraphNodes()

expands to nodes of a subgraph.

Expand to nodes in a subgraph

apoc.path.subgraphAll()

expands to nodes of a subgraph and also returns all relationships in the subgraph.

Expand to subgraph

apoc.path.spanningTree()

expands to paths collectively forming a spanning tree.

Expand a spanning tree