I have a node and I need to find all parent relationship to it till root.
So, if I have: A->B->C->D(root) A->E->F->D(root)
A is the node I have and I need all the ancestors of it.
I tried the cypher query:
MATCH (n:yo {name:"foo"})-[:HELLO*1..]->(p:yo) RETURN p
But it shows me a list like this: B,C,D,E,F. So the connection between them is lost. Is it possible to have list like [[B->C->D],[E->F->D]]
I saw this query on a website and it works. But it returns [[A,B],[A,B,C],[A,B,C,D]]. I don't need the subpaths.
start c = node:node_auto_index ( object_id = ‘10179’ )
MATCH path = c <- [ : PARENT_OF* ] – p
return distinct
length ( path ) AS PATH_LENGTH
, extract ( n in nodes ( path ) : n.object_id ) as the_path
order by length ( path )