### 8.5.8. Collapse node to relationship

This section describes a procedure that can be used to collapse a node into a relationship.

The available procedure is described in the table below:

`call apoc.refactor.collapseNode([node1,node2],'TYPE')` | collapse nodes with 2 rels to relationship, node with one rel becomes self-relationship

#### 8.5.8.1. 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: