shortestPath

Generic Description

Path-pattern helper that asks for one shortest path.

Simple example:

MATCH p = shortestPath((a:Page)-[:LINK*]->(b:Page)) RETURN length(p) AS hop_count

Consumer-Level Explanation

Use shortestPath when the query must path-pattern helper that asks for one shortest path and the planner needs to see that operation as part of the Cypher row pipeline. Keep the clause explicit because it controls row grain, variable scope, and what later clauses are allowed to reference.

More Detailed Explanation

shortestPath is a pattern-level tool, not a general scalar function. It is for graph queries where route shape matters but you want the concise declarative form rather than a procedure call.

What this clause is really for:

Advanced Example

This example keeps shortestPath inside a complete query pipeline so the clause boundary, visible variables, and returned row shape are clear to planner tooling.

MATCH p = shortestPath((a:Page)-[:LINK*]->(b:Page))
RETURN length(p) AS hop_count, size(nodes(p)) AS node_count, size(relationships(p)) AS relationship_count

Real Use Cases

Real Limitations And Tradeoffs