Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
12-07-2021 11:36 AM
Hi,
Here is the scenario: I have graph with a series of documents that reference each other with directed relationships. A given document may reference parents, grandparents, and or great-grandparents. What I am interested in is reducing the graph to bare essence to so that the reference node relationships go through the tree structure. I am looking to pare down the relationships to highlight the the flow through the documents.
For example if a start with this.
My hand trimming reveals this:
Is there a generic cypher strategy to reveal this pattern from the original. I have date properties and document serial numbers as property keys to assist.
How would I go about writing this?
Andy
12-10-2021 09:11 AM
A suggestion:
MATCH (d1:Document)-[:CITES]->(:Document)-[:CITES]->(d3:Document)<-[c:CITES]-(d1)
DELETE c
But please make sure it really does what you want on a backup, before deleting your citations 🙂
12-10-2021 02:15 PM
Thank you I will give a try, though to be safe I might just set a visibility property as a start. The down side of course is that it is not possible to purge unwanted property keys later.
Andy
12-10-2021 02:37 PM
I am not sure if I understood what you wanted to achieve, and I didn't test the query myself, so better test it on a backup first. But maybe you can alter that query to get exactly what you want. Another alternative, yielding a different result, might be:
MATCH (d1:Document)-[c1:CITES]->(:Document)-[c2:CITES]->(d3:Document)<-[:CITES]-(d1)
DELETE c1, c2
12-10-2021 09:16 PM
You can try with virtual nodes. Check this link:
All the sessions of the conference are now available online