apoc.refactor.collapseNode
Syntax |
|
||
Description |
Collapses the given |
||
Input arguments |
Name |
Type |
Description |
|
|
The nodes to collapse. Nodes can be of type |
|
|
|
The name of the resulting relationship type. |
|
Return arguments |
Name |
Type |
Description |
|
|
The id of the given relationship. |
|
|
|
The id of the new relationship with the updated type. |
|
|
|
The message if an error occurred. |
Usage Examples
The examples in this section are based on the following sample graph:
CREATE (flight:Flight {number: "BA001"})
CREATE (origin:Airport {code: "LHR"})
CREATE (destination:Airport {code: "AMS"})
CREATE (flight)<-[:OUT]-(origin)
CREATE (flight)-[:IN]->(destination);
The following query collapses the Flight
node, replacing it with a CONNECTED
to relationship:
MATCH (flight:Flight {number: "BA001"})
CALL apoc.refactor.collapseNode([flight],'CONNECTED_TO')
YIELD input, output
RETURN input, output;
input | output |
---|---|
10 |
[:CONNECTED_TO {number: "BA001"}] |
If we execute this query, it will result in the following graph: