I have a tree with about 300 nodes. For an arbitrary node, I need to draw a subtree from that node to the root (including all possible paths).
For example if I have this tree (edited):
a
|
-----
| | |
b c d
| |
---
|
e
|
f
and the e
node is selected, I need to draw:
a
|
---
| |
b c
| |
---
|
e
I am using this Cypher query:
start n=node({nodeId}) optional match n-[r:DEPENDS*]->p return n,r,p
Although it works, depending on the depth of the searched node, it is very very slow (more than 10 seconds).
¿How can I achieve this efficiently?