This only deletes the 'thisnode' node and the 'has_situation' relation.
I would like to delete all of the nodes related to the grey 'thisnode', that includes the pink and darkgreen nodes and relations as well.
This query works for me: MATCH path = (:thisnode)--()--()--() DETACH DELETE path
Where the first '--()' selects all lightgreen nodes with any relation to the grey one, the second '--()' all pink nodes with any relation to any of the nodes that have any relation to the grey node.
This solution is not dynamic at all since i need to specify the depth of what nodes need to be deleted by adding a bunch of '--()'.
Idealy i would be able to remove all of the nodes in the picture above with a simple dynamic query regardless of the relation depth. (but not all of the nodes in the database, its not a fully connected graph)
Try this:
MATCH (n:thisnode)
CALL apoc.path.spanningTree(n,{maxLevel:3}) YIELD path
RETURN path
Use RETURN path to check the results, then you can use DETACH DELETE path
Change the maxLevel number according to your needs.