1

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.

enter image description here

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

Jaydipsinh
  • 491
  • 1
  • 9
  • 27
  • How should the "correct output" look like for a specific example? – Graphileon Mar 18 '20 at 13:37
  • If `c4` makes a purchase from `b3`, why does he need to reward people who were not even indirectly involved in sharing `b3` with him? Shouldn't `c4` only pick from people who are connected to a `Share` that is connected to `b3`? – cybersam Mar 18 '20 at 18:42
  • @cybersam yes but as per our product concept, if c4 made a purchase then our platform will distribute reward points to people who shared any business with c4. reward distribution will be upwards from c4 to any businesses. so any other customer like c5 will also get rewarded. – Jaydipsinh Mar 19 '20 at 07:06
  • @Graphileon i have already given expected output in question. in case of c4 it should return 9 nodes which are c1,c2,c3,c4,c5,c6,b1,b2,b3 – Jaydipsinh Mar 19 '20 at 07:08
  • @cybersam you can also suggest another graph model which fulfills all requirements – Jaydipsinh Mar 19 '20 at 07:10
  • @Graphileon you can also suggest another graph model which fulfills all requirements – Jaydipsinh Mar 19 '20 at 07:10
  • @Jaydipsinh the question remains unclear. For instance, in the query you tried, there is no identifier that points to b3. So it seems like distribution seems to be the same, no matter which business c4 is buying from. – Graphileon Mar 19 '20 at 08:37
  • @Graphileon b3 will get rewards because c6 shared business b3 with c4 so c4 will get rewards, and c5 will also get rewards because he shared business b3 with c5. – Jaydipsinh Mar 19 '20 at 09:46

0 Answers0