1

I want to write a query to receive all parents till root node from any child node, ordered:

Here is the graph: enter image description here

I found some solutions, but result have some duplications or nodes weren't ordered. Thanks in advance.

1 Answer 1

0

Solution that I came:

MATCH p=((s:storage)-[*]->(n:item {id: 1003}))
WITH nodes(p) AS nodes, length(p) AS distance
UNWIND nodes[0..size(nodes)] AS node
RETURN DISTINCT node.id, head(labels(node)) AS mainLabel

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.