Collapse node to relationship
The available procedure is described in the table below:
Qualified Name | Type | Release |
---|---|---|
|
|
Example Usage
The example below will help us learn how to use this procedure.
The following creates a graph containing a
Flight
and origin and destination `Airport`s: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 , error
RETURN input, output, error
If we execute this query, it will result in the following graph:
