Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
06-09-2022 06:47 AM - edited 06-09-2022 06:49 AM
Hello , can you help me with a query that would be able to delete a specific graph (by it's id or name)
my mission is to delete all the nodes and their realtions from my root that is the green "MyGraph" but only them, I do not want to delete all the other nodes that we do not see in the image and their relations in my db
Solved! Go to Solution.
06-16-2022 04:48 PM
Is this is self-contained subgraph, i.e. it does not connect to other nodes you want to keep? If so, you can try this. I used it on the shown subgraph, and it worked fine. Change the match clause predicate to match on your 'black' node. It relies on the APOC library, so you will need to install it if you have not done so already.
MATCH (p) where id(p) = 100
CALL apoc.path.subgraphNodes(p, {})
YIELD node
detach delete node
06-13-2022 02:05 AM
I'm not sure i understand the question. If you have the `<id>` of your node, by clicking it by clicking it and seeing the `Node properties` box, you could do this query to delete node and relationships:
``` MATCH (n) WHERE id(n) = <MYID> DETACH DELETE n ```
Is this what you need?
06-16-2022 01:21 PM
Hello i have entered to <MYID> the relavent id, that from it I wanted to delete all the connected nodes but it didn't work. What did I do wrong? and what I meant was that i try to pick the node I have marked in black and with it's id to delete the whole yellow "graph" that starts from him
06-16-2022 04:48 PM
Is this is self-contained subgraph, i.e. it does not connect to other nodes you want to keep? If so, you can try this. I used it on the shown subgraph, and it worked fine. Change the match clause predicate to match on your 'black' node. It relies on the APOC library, so you will need to install it if you have not done so already.
MATCH (p) where id(p) = 100
CALL apoc.path.subgraphNodes(p, {})
YIELD node
detach delete node
06-18-2022 01:15 AM
It worked 🙂
thank you so much!!
All the sessions of the conference are now available online