Stuck in a query

Hi everyone,
I'm pretty new to neo4j and I got stuck on a query that I could not figure out the best way to do it.

Here is my graph model, where an author has multiple co-authors and writes multiple publications

My need is the following:

  • find the number of publications of authorA with its ID, let's name it nb_pubs1
  • find the number of publications of authorB with its ID, let's name it nb_pubs2
  • find the number of publications that author1 and authorB wrote together, let's name it nb_common_pubs
  • set the value weight= (nb_pubs1+nb_pubs2)/nb_common_pubs in the CO_AUTHOR the relationship (author1:Author)-[:CO_AUTHOR]-(author2:Author)

I'll verily appreciate any help with this concern,
thanks in advance

MATCH (a:Author)-[:WRITES]->(p:Publication)
RETURN a.name AS author, count(p) AS nb_pubs

MATCH (a:Author {name:'A'})-[:WRITES]->(p:Publication)<-[:WRITES]-(b:Author {name:'B'})
RETURN a.name, b.name, count(p)

The Author must have a property name in the examples above

Not sure if this is what you want, but I've tried to help as much as i could. Hope this helps you :blush:

MATCH (:Author {ID:'99db26f49ce6c27bf30ac46490497e2b'})-[:WRITES]->(pub1:Publication)
WITH DISTINCT(pub1.ID) as author1_publications
MATCH (:Author {ID:'856409620675a58f2370e68618a3166c'})-[:WRITES]->(pub2:Publication)
WITH DISTINCT(pub2.ID) AS author2_publications, author1_publications
RETURN 
	COUNT(DISTINCT(author1_publications)) as num_pub_author1,
    COUNT(DISTINCT(author2_publications)) as num_pub_author2,
	apoc.coll.occurrences(collect(ANY(n in author1_publications WHERE n in author2_publications)), true) as num_pub_commun