Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
03-07-2021 12:03 AM
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:
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
03-07-2021 11:48 PM
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
03-08-2021 05:16 AM
Not sure if this is what you want, but I've tried to help as much as i could. Hope this helps you
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
All the sessions of the conference are now available online