Extract node from relationships

The available procedure is described in the table below:

Qualified Name Type Release

apoc.refactor.extractNode

apoc.refactor.extractNode([rel1,rel2,…​], [labels],'OUT','IN') extract node from relationships

Procedure

APOC Core

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