A Cypher examples to unwind and collect
✓ Published0🌍 Public
CCliffordAnderson
Last edited Aug 27, 2014
Created on Aug 27, 2014
This example demonstrates two Cypher queries that find the shortest path between two named nodes, “Daniel” and “Jerry,” in a Neo4j graph and then process the resulting path’s nodes. The first query, `unwind.cypher`, uses `nodes(s)` to extract the path’s vertices, `unwind` to iterate over them, and returns each node’s `name` property as a column. The second query, `collect.cypher`, chains `unwind` into `collect` to aggregate all names into a single list, then `head(m)` retrieves the first element. Both queries rely on Neo4j’s `shortestPath` function to compute the route.
AI-generated description