I have a linked list that is modeled in a circular fashion, for example:
(u:User)
-[:LINK]->(a:NODELINK {linkId: 'aa'})
-[:LINK]->(b:NODELINK {linkId: 'bb'})
-[:LINK]->(c:NODELINK {linkId: 'cc'})
-[:LINK]->(d:NODELINK {linkId: 'dd'})
-[:LINK]->(u)
When I request it starting with node (b:NODELINK {linkId: 'bb'}), I would like to combine all the nodes until I reach the end / beginning of the list. (User node)
When I run the following query:
MATCH (u:USER)
WITH u
MATCH (nl:NODELINK)-[:LINK*]->(m)
WHERE nl.linkId = 'bb' AND m <> u
RETURN m
He returns me the following nodes
(3:NODELINK {linkId:'cc'})
(4:NODELINK {linkId:'dd'})
(1:NODELINK {linkId:'aa'})
(2:NODELINK {linkId:'bb'})
As you can see, my query wraps around and starts returning nodes from the very beginning of the list. I would like to end the node user and only return the nodes to the end of the list
(3:NODELINK {linkId:'cc'})
(4:NODELINK {linkId:'dd'})
I created a graph that demonstrates the problem here
How do I request to start with a node of interest to the link and return all the nodes before it reaches the node user?