Extract node from relationships
The APOC library contains a procedure that can be used to create nodes from relationships.
Procedure for creating nodes from relationships
Qualified Name | Type |
---|---|
|
Procedure |
Example
The example below will further explain this procedure.
The following creates a graph containing two nodes connected by a relationship:
CREATE (f:Foo)-[rel:FOOBAR {a:1}]->(b:Bar)

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 the above query is run, it will result in the following graph:
