I have a Neo4j graph which looks like this
It has a hierarchy of relations using the CHILD_OF relationship.
All the green nodes (see) are entitlements on Books.
All the books which a parent can see are also visible to the child but not the other way round.
Also, there is a possibility for child to see the books directly without involving the parent.
The ask here is to find the shortest path from the Child to the books.
In this case C1 has 2 paths (via entitlements) to Book1 but only 1 to Book2. And none to Book3.
The Neo4j Cypher query should return only the shortest paths from C1 to all the books.
I tried using the Neo4j shortestPath function but it does not work.
MATCH (c:Child {name:'C1'} ),
(b:Book),
p = shortestPath((c)-[*]-(b))
RETURN p
Output of this query returns this:
Desired final graph should look like this: