cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

Need to identify referral chain of users

radhika
Node Link

Hi all,

I have been working on finding links between users through referrals. The basic data that I have is a users node with a relationship "is_parent_of" between these set of users.
Graph looks like this :

I wanted to get the referral tree of a user. So my cypher query is this -

MATCH (c:Users)-[r:IS_PARENT_OF*]->(ref)
WITH DISTINCT c, size(r) as gen, ref
WITH c, gen, collect(ref.name) as referrals
ORDER BY gen ASC
RETURN c.name as Customer, collect({gen:gen, referrals:referrals}) as referrals

and the output is -

However in this I can only see a split of generations starting from the user itself to the nth generations of referrals from him.. However I want to see his previous generations/links of referrals too..like his parent id, his parentid's other referrals (his siblings), his parents parents id. also. Here above I only have generation 1 which is the set of users the user has referred. I want generation 0, -1, -2..-n

Can someone please help me with how i can achieve this? Also I want each generations to be in separate columns instead of this 1 cell..

0 REPLIES 0