Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
12-05-2018 01:35 AM
Hello
We have a requirement to clone a tree from a given root node into exactly the same tree structure from a newly created Root node. The cloned tree only has to traverse down to level "n" and only traverse certain relationships.
Does anyone have any suggestions for the most efficient way of doing this? Our initial experiments have taken somewhere in the region of "minutes" and have put a medium-large load on the server.
12-07-2018 07:00 PM
Hi!
Can you share your query are you are running it now? And tell me a bit more about the scope, how many nodes on avg ect.
12-08-2018 01:32 PM
I answered a similar question on Stack Overflow recently, are you the same one who asked that question?
If not, then my answer may be helpful for you.
If so, then it would help to know what's going on in the query, and I'd request you PROFILE your query and add the query plan (after expanding all elements of the plan) to your question.
02-04-2019 03:07 AM
There is also a apoc procedure for that:
apoc.refactor.cloneNodesWithRelationships
02-04-2019 04:17 AM
I think this gets messy, as the cloned relationships attach to all outside nodes as well as to the original nodes, leaving an exercise for the caller on how to delete all the relationships between the clones and the originals.
I've added an APOC feature request for a new procedure apoc.refactor.cloneSubgraph()
that is aimed at this particular use case: cloning nodes and the relationships between them, only creating relationships between the clones and not to any of the originals, and allowing a means to define a replacement or standin for nodes when it comes to relationship creation. For this example, it could be used to clone a branch and attach the branch to a different root node instead of the old root (or instead of cloning the old root).
02-07-2019 02:11 AM
As an update, I have a PR open with a new APOC procedure for doing exactly this:
All the sessions of the conference are now available online