I have sets of nodes that sometimes have multiple edges of the same type that differ in values for their properties. In such cases I would like to keep one edge based on for instance having the largest value for a specific property of interest while deleting the rest. What would be the best way to do this?
It's similar to the post below but in my case I want to keep one edge based on the edge that has the max or min value between sets of edges between two nodes for a specific property. And this needs to be applied throughout the graph for each set of nodes with multiple edges of the same type
Delete all of the same relationship type between two node but still keep one of them
I tried something like the below but it doesn’t quite work and the result value usually will be unique for each set of nodes.
MATCH (n:Node_A)-[e:edge_B
]->(m:Node_C
)
WITH COLLECT(e) AS edges, MAX(e.property_a) AS result
UNWIND edges as edge
WITH edge
WHERE edge.property_a <> result
DELETE edge