0

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?

Bugs
  • 4,491
  • 9
  • 32
  • 41
Muna arr
  • 353
  • 2
  • 13

1 Answers1

1

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
Bruno Peres
  • 15,845
  • 5
  • 53
  • 89
  • Any clue to optimized as it is large dataset ? the browzer bugs – Muna arr Jul 03 '17 at 12:05
  • You can try specifying a known label in `n` and `m` nodes (something like `MATCH(n:NodeTypeA)-[Rel1*1..3]->(m:NodeTypeB)`). Creating an index in the n.NID property is a good idea too. – Bruno Peres Jul 03 '17 at 12:08
  • A unique constraint is already created and adding the labels make it bug – Muna arr Jul 03 '17 at 12:53
  • What "bug" are you getting? – Bruno Peres Jul 03 '17 at 12:54
  • the browzer is blocked saying neio4j do not response – Muna arr Jul 03 '17 at 12:55
  • Well, this is not a bug. This probably is related with the size of your graph and the amount of memory that you have available... Take a look in the [memory tuning](https://neo4j.com/docs/operations-manual/current/performance/#memory-tuning) section. – Bruno Peres Jul 03 '17 at 12:59
  • I already did , that's why I'm asking for a tric to optimize graph traversal on large sets – Muna arr Jul 03 '17 at 13:00
  • Hard to provide advice without more info. Can you EXPLAIN the query and paste the exported image (after all elements are expanded) of the query plan to your description? – InverseFalcon Jul 04 '17 at 02:30