Extract node from relationships

The available procedure is described in the table below:

call apoc.refactor.extractNode([rel1,rel2,…​], [labels], 'OUT','IN')

extract node from relationships

Example Usage

The example below will help us learn how to use this procedure.

The following creates a graph containing two nodes connected by a relationship:
CREATE (f:Foo)-[rel:FOOBAR {a:1}]->(b:Bar)
apoc.refactor.extractNode.dataset
The following converts the FOOBAR relationship into a node with label FOOBAR that has an incoming FOO relationship and outgoing BAR relationship:
MATCH (f:Foo)-[rel:FOOBAR {a:1}]->(b:Bar)
CALL apoc.refactor.extractNode(rel,['FooBar'],'FOO','BAR')
YIELD input, output
RETURN input, output

If we execute this query, it will result in the following graph:

apoc.refactor.extractNode