Given a forest of trees in a Neo4j REST server, I`m trying to return a single tree given the root vertex.
Being each tree quite large, I need a de-duplicated list of all vertices and edges in order to be able to reconstruct the full tree on the client side.
I tried multiple combinations around MATCH (r:root)-[*]->()
but they return any path starting from the root, thus with lots of duplicates:
MATCH p = (r:root)-[*]->(x)
RETURN nodes(p) AS Vertices, rels(p) AS Edges";
this returns each and every path as follows, repeating each node every time:
a->b
a->b->c
a->b->c->d
etc...
Instead, I need a result having
{
Vertices: [a, b, c, d],
Edges: [[a, b], [b, c], [c, d]]
}
I'm using Node.js with Seraph, if relevant, but I`m not strictly bound to that library.