Problem: I want to use cypher to return paths where I can specify the start point, and filter by the number of connections coming into a termination point for those paths.
Some dummy example data:
path1: (a1:a)--(b1:b)--(c1:c)--(d1:d)
path2: (a1:a)--(b2:b)--(c2:c)--(d1:d)
path3: (a1:a)--(b3:b)--(c3:c)--(d2:d)
path4: (a1:a)--(b2:b)--(c2:c)--(d3:d)
path5: (a2:a)--(b4:b)--(c4:c)--(d3:d)
Aim: I want to bring back all paths that start with a1, and end with dn, where the count of relationships to dn from paths that begin at a1 is > 1 (or 2, or 3… in the above example we’ll use >1 but I want to be able to change this for real data where relationship counts might be much higher).
In the example above I want to include path 1 and path 2, because they both start with a1 and terminate at d1, and the count of paths starting at a1 and terminating at d1 is 2 (i.e. >1).
paths 3 and 4 will be excluded because although they start with a1, there are no other paths starting with a1 that terminate in d2 or d3. In other words, d2 and d3 are unique in the context of paths starting with a1.
path 5 will be excluded because it does not start with a1, even although there are >1 paths that terminate at d3
All the intermediate nodes are basically irrelevant, aside from being able to specify their labels during the query and get the nodes that make up the path back at the end.
I have looked but I can't find anything addressing this problem elsewhere