Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
03-16-2022 05:37 AM
Is there any method to set a property to relationships between those two nodes?
(I need to invert those edges).
The nodes in orange boxes have distinctive properties.
(The path can be of a different length, this is just an example).
03-16-2022 12:04 PM
You could experiment with the following. It will find the directed path between to specified nodes, and reverse the relationships between each set of nodes. You will need to change the node labels and relationship type, and the criteria for the 'n' and 'm' nodes.
match (n:Client) where id(n) = 0
match (m:Client) where id(m) = 3
match p = (n)-[*]->(m)
unwind relationships(p) as relationship
with startNode(relationship) as start, endNode(relationship) as end, properties(relationship) as prop, relationship
create (end)-[r:REL]->(start)
set r = prop
delete relationship
03-19-2022 01:36 AM
Hello @marcelix161
You can use the APOC function apoc.refractor.invert() to reverse the direction of the relationship.
MATCH ()-[r:MINST2]->()
CALL apoc.refactor.invert(r)
Regards,
Cobra
All the sessions of the conference are now available online