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

Hello!
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.

Regards,
Cobra

1 Like

Thanks you very much!