java - How to count number of nodes per depth in a breadth_first search in Neo4j -


i trying design mlm application. operates person sponsors 3 persons , b, c, d , each of b, c, , d sponsors 3 more , on.

to calculate payouts, client wants graph traversed based on last person of 3, d , total payout based on number of people under d multiplied specific amount. challenge me constraint whereby each level, need count n-1 persons n maxes out @ 3 mlm strategy.

i using embedded neo4j project far know can traverse based on relationship , perhaps bread_first search , current depth how count number of persons minus 1 each level in traversal? seems, may have implement custom method need pointed in right direction.

well, long know depth you're at, can use depth index collection (an array example). every time visit node @ given depth, increment value @ index in collection.

once you're finished traversal, can apply ever rules , constraints array of data.


Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

javascript - addthis share facebook and google+ url -

ios - Show keyboard with UITextField in the input accessory view -