Timeboxed Cypher statements

To terminate a cypher statement if it exceeds a given time threshold, use the apoc.cypher.runTimeboxed procedure. The below example calculates the cross product of shortestpaths for each pair of nodes:

CALL apoc.cypher.runTimeboxed(
  "match (n),(m) match p=shortestPath((n)-[*]-(m)) return p",
  null,
  10000
)
YIELD value
RETURN value.p

This will return all results computed within 10000 milliseconds. The statement will be terminated after that period.