Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
05-12-2020 06:37 PM
I am trying to visualize which Institutions share a common Publication together and have been really struggling with how to do this with Cypher
05-13-2020 01:08 AM
Hi @athahireen.
You can try below
Match(p:Publication)-[:AUTHORED]->(a:Author)-[:AFFILIATED_WITH]->(i:Institution)
With p, collect(distinct i) as institutions
CALL apoc.nodes.link(institutions , 'SAME_PUB')
Return p
05-13-2020 09:20 AM
Hi! Thank you for the help, but the direction of the relationship between Author and Publication goes Author - AUTHORED -> Publication which is what I'm struggling with
05-13-2020 09:28 AM
What is happening when you try
Match(p:Publication)<-[:AUTHORED]-(a:Author)-[:AFFILIATED_WITH]->(i:Institution)
With p, collect(distinct i) as institutions
CALL apoc.nodes.link(institutions , 'SAME_PUB')
Return p
05-19-2020 12:44 PM
Off the top of my head, you could try:
MATCH(i1:Institution)<-[:AFFILIATED_WITH]-(a1:Author)-[:AUTHORED]->(p:Publication)<-[AUTHORED]-(a2:Author)-[:AFFILIATED_WITH]->(i2:Institution)
WHERE id(i1) <> id(i2)
RETURN i1, i2, p, a1, a2
The WHERE will ensure that the query doesn't go back to the same publication if more that one author has worked on it.
As I said, this is off the top of my head. I haven't tried it out, so:
a) it may not work
b) it might take forever to run, depending on how much data you have
All the sessions of the conference are now available online