Muna arr
Muna arr

Reputation: 353

Neo4j Graph depth traversal Cypher

I'm using neo4j as a graph database and I want to return from a starting node neighbors of that node, and all the related neighbors to a depth varying from 1 to 3. I'm Doing this but it gets stuck: Note that it is a large graph.

start n = node(*) where n.NID contains "9606.ENS3" 
MATCH (n)-[Rel1*1..3]-(m) RETURN m;

Anyone have a clue of how to do traversals on a graph, and getting a result?

Upvotes: 0

Views: 573

Answers (1)

Bruno Peres
Bruno Peres

Reputation: 16365

Your question shows an old Cypher syntax. The docs says about the START clause:

The START clause should only be used when accessing legacy indexes. In all other cases, use MATCH instead (see Section 3.3.1, “MATCH”).

I believe this should work:

MATCH(n)-[Rel1*1..3]->(m)
WHERE n.NID contains "9606.ENS3"
RETURN m

Upvotes: 1

Related Questions