When a path is matched, how to get ids of node and edge in a path

How to get the id of each node and edge in a path, after "match p=()->(), return p".

Hello @ninesunqian :slight_smile:

You should have a look at nodes() and relationships().

MATCH path=()->()
WITH nodes(path) AS n, relationships(path) AS r
RETURN [node in n | id(n)], r 

Be aware you can alo access start and end nodes in the result of relationships(path) for each relation.


1 Like

Thanks you very much!