Cypher queries cannot produce the recursive query in tabular data to determine source and target

I have data that is stored in recursion using another object as below


Though there can be some intermediate object(s) as well and the depth is not fixed. Can be one or 5 or 10 as well.



Another scenario is a Source can be linked to multiple Source/Feature and the they will be further linked in same way.



I am using below query to get the data

MATCH(s:Source)-[r:Target-Feature *]->(n:Source)
return s.Name, n.Name;

Though I am able to get the data correctly, I am not able to display that dynamically in a tabular format which clearly shows the Sources at each hop(excluding intermediate Feature objects) including handling the multi to multi linking.

Hi @rabindra.srivastava, welcome to the community!

You will probably find the nodes() and relationships() Cypher functions helpful.

You will probably do something like get your path, i.e.

MATCH path =(s:Source)-[r:Target-Feature *]->(n:Source)

and then, you will do something like nodes() to pull out the nodes, e.g.

RETURN nodes(p)

You can find the documentation to nodes() here. Have bit of a play with this, and hopefully you'll get what you're after.