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.

Query for the co authors problem in CY neo4j

Hi everyone ! I have to write a query about collaboration between authors for my homework. My nodes are "authors" and "articles". I have connected articles and authors as ( ()-[:composedby]->()) and authors between them the same way. I want to write a query so to find the top 5 authors with most distinct collaborations but this one didn't work :
</>
MATCH (a:Author)-[:WORKSWITH]->(b:Author) MATCH (article:Article)-[:COMPOSEDBY]->(a:Author) RETURN a.name AS Name, COUNT(b) AS Collaboration ORDER BY Collaboration DESC LIMIT 5
</>
Any ideas with that ? I wrote COUNT( DISTINCT b) but still no result.

1 REPLY 1

ameyasoft
Graph Maven
Try this:
MATCH (article:Article)-[:COMPOSEDBY]->(a:Author) 
MATCH (a)-[:WORKSWITH]->(b.Author) 
RETURN a.name AS Name, COUNT(distinct b.name) AS Collaboration 
ORDER BY Collaboration DESC LIMIT 5