I have an MLM graph where any customer can share a business with another customer. so I have designed model like Nodes for shares, customers, businesses, and edges for the source(to business), from, to.
Now, whenever customer(c4) made a purchase with business(b3) I have to distribute rewards to the upward network nodes(customers) like
c4 -> c6 -> c5 -> b3
c4-> c3 -> c2 -> c1 -> b2
c1 -> b1
So total nodes: c1,c2,c3,c4,c5,c6,b1,b2,b3 (9 nodes including c4)
I've tried with bellow query
match(:Customer{name:"c4"})<-[:to]-(s:Share)<-[:from]-(f),(s)-[:source]->(b) return f,b
but it doesn't work recursively.
Please help me to extend this query to get the correct output.
Thanks