I have the below graph. A league (l1) starts with LEVEL r1 and the NEXT levels are related using NEXT relationship as shown.
league-[:LEVEL]->r1-[:NEXT]->r2-[:NEXT]->r3-[:NEXT]->r4
What I am looking for is to find all the levels for a given league and in the order. So, for the above graph the expected output is r1, r2, r3, r4
. I've the below query but it is returning all the paths.
start l1=node(9) match l1-[:level]->(level) with level match p=level-[:next*]->(remainingLevels) return p;
Cyphers for creating this graph. This is already setup on console.neo4j.org (make sure to change the id's)
CREATE (l1 {name: 'l1'}) return l1;
CREATE (r1 {name: 'r1'}) return r1;
START l1=node(9), r1=node(10) CREATE l1-[r:level]->r1;
CREATE (r2 {name: 'r2'}) return r2;
START r1=node(10), r2=node(11) CREATE r1-[r:next]->r2;
CREATE (r3 {name: 'r3'}) return r3;
START r2=node(11), r3=node(12) CREATE r2-[r:next]->r3;
CREATE (r4 {name: 'r4'}) return r4;
START r3=node(12), r4=node(13) CREATE r3-[r:next]->r4;