---
title: allShortestPaths
url: https://nexyron.tech/docs/cypher/clauses/pattern-features/allshortestpaths
description: Path pattern helper that asks for all shortest paths of minimum length.
---

# allShortestPaths

## Generic Description

Path-pattern helper that asks for all shortest paths of minimum length.

Simple example:

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

## Consumer-Level Explanation

Use `allShortestPaths` when the query must path-pattern helper that asks for all shortest paths of minimum length 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

`allShortestPaths` differs from `shortestPath` by emphasizing ambiguity rather than collapsing it. It is for cases where multiple shortest alternatives are analytically or operationally important.

What this clause is really for:

-   it defines one concrete stage in the Cypher row pipeline, so variables available before and after `allShortestPaths` must be clear
-   it should make graph structure, temporal filters, document payload shaping, or procedure output explicit instead of relying on client-side interpretation
-   planner tooling depends on this clause boundary to know row grain, variable scope, and whether later expressions are reads, writes, schema operations, or projections

## Advanced Example

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

```cypher
MATCH p = allShortestPaths((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

-   route redundancy inspection
-   showing multiple equivalent explanations or traces
-   graph analysis where path multiplicity matters

## Real Limitations And Tradeoffs

-   can produce many results even when path length is small
-   results can be harder to present usefully to end users
-   should be bounded with good graph scoping and downstream limits
