apoc.refactor.invert
Procedure APOC Core
apoc.refactor.invert(rel) inverts relationship direction
Signature
apoc.refactor.invert(relationship :: RELATIONSHIP?) :: (input :: INTEGER?, output :: RELATIONSHIP?, error :: STRING?)
Usage Examples
The examples in this section are based on the following sample graph:
CREATE (mark:Person {name: "Mark", city: "London"})
CREATE (jennifer:Person {name: "Jennifer", city: "St Louis"})
CREATE (mark)-[:FOLLOWS]->(jennifer);
The following reverses the direction of the FOLLOWS relationship:
MATCH ()-[rel:FOLLOWS]->()
CALL apoc.refactor.invert(rel)
YIELD input, output
RETURN input, output;
| input | output | 
|---|---|
0  | 
[:FOLLOWS]  | 
We can list all the Person nodes by running the following query:
MATCH path = ()-[rel:FOLLOWS]->()
RETURN path;
| path | 
|---|
(:Person {name: "Jennifer", city: "St Louis"})-[:FOLLOWS]→(:Person {name: "Mark", city: "London"})  |