cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

Creating a subgraph that makes certain neighboring nodes a property of the new node

Hello everyone, this is my first time here. I hope I did things correctly. Apologizes if I did not.

Here is my question. Supposed you have a graph that has this kind of relationship

(DirectorName1) - [:DIRECTED] -> (movie1) -[:SEQUELOF] -> (movie2) <- [:DIRECTED] - (DirectorName2)

And now you want to create a new kind of subgraph or graph that has this relationship:

(movie1 {Director: DirectorName1}) - [:SEQUELOF] -> (movie2 { Director: DirectorName2})

where now the movie nodes have a property "Director" which it was once a neighboring node connected to it.

Is this possible? Currently I know how to extract existing nodes and relationships through something similar to this code:

// exports given nodes and relationships incl. indexes as cypher statements to the provided file
MATCH path = (p1:Person)-[r:KNOWS]->(p2:Person)
WITH collect(p1)+collect(p2) as export_nodes, collect(r) as export_rels
CALL apoc.export.cypher.data(export_nodes,export_rels,'/tmp/export.cypher',{format:'cypher-shell'})
YIELD file, source, format, nodes, relationships, properties, time
RETURN nodes, relationships, time;

Source: https://neo4j.com/developer/kb/export-sub-graph-to-cypher-and-import/

But can I create new nodes on the fly here?

Thank you so much!

0 REPLIES 0