neo4j - Find the nodes with the most mutual connecting nodes? -


i'm working data set contains customers, purchases , businesses purchased from, , i'm trying determine businesses share highest number of mutual customers. ideally output table lists connected businesses , number of mutual customers. i.e.:

| business_1 - business_2 | 4 | | business_1 - business_5 | 3 | | business_3 - business_7 | 2 | | business_4 - business_9 | 2 | 

i don't have @ point, query i'm working looks this:

match (c:customer)<-[:trans_cust]-(t:transaction)-[:trans_business]->(b:business) return c, t, b 

thanks in advance

i guess should trick, maybe provide sample dataset on http://console.neo4j.org help.

match (b:business) match (b)<-[:trans_business]-(t:transaction)-[:trans_cust]->(c:customer) match (c)<-[:trans_cust]-(:transaction)-[:trans_business]->(other:business) b <> other b, other, collect(distinct(customer)) customers return b, other, size(customers) sharedcustomers order sharedcustomers desc 

Comments

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

php - .htaccess mod_rewrite for dynamic url which has domain names -

Website Login Issue developed in magento -