Reduce a graph to a DAG

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

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 :)

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

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

You can try with virtual nodes. Check this link: