Distinct full paths for a given node

Hi everyone,
For the following graph :
Capture d’écran du 2020-10-20 10-47-20

I would like to get all the distinct oriented paths for a given node.
For example, starting from x6, I would have 3 distinct paths :

  • x6 -> x3 -> x2 -> x1

  • x6 -> x3 -> x2 -> x4

  • x6 -> x3 -> x2 -> x5

I have tried this query: MATCH path = ({name:'x6'})-[*]->(n) RETURN path

And I obtained these results:

I think I just have to add clauses in my query, but I can't figure out which ones.

Thanks for your help.

What does this mean?

In your sample output, why wouldn't you also want to see x6 -> x3, x6 -> x3 -> x2, and other "intermediate" paths?

Yes I'm also interested by the "intermediate" paths but is it not possible to simplify by defining that they are included in the next 3 paths ?

  • x6 -> x3 -> x2 -> x1
  • x6 -> x3 -> x2 -> x4
  • x6 -> x3 -> x2 -> x5

I would like to "limit" the research of paths like this:

  • First node of the path -> a given node (x6 for example)
  • End node of the path -> leaf node (like x1 ?) OR a node before the given node (x4 and x5 for x6)

Have a look at this -- this might be what you mean / need, but I'm not sure

This would get you all of the paths, as short as possible, from your starting point to everything else, without replications I think.

Thanks David !
I also think about Shortest Path and Single Source Shortest Path algorithm because I will put cost on my relationship.

I found this code in neo4j documentation :