如何从起始节点递归删除节点 [英] How to delete nodes recursively from a start node

查看:104
本文介绍了如何从起始节点递归删除节点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个图,它具有一组节点及其子级。有一个根节点,其余节点从该根节点分支出来。这样的节点集合很少有。

I have a graph which has a set of nodes and its children. There is a root node from where the rest of the nodes branch out. There are few sets of such node collection.

我想选择一个根节点并递归清除其所有连接和节点,而将根节点留作将来添加。

I want to pick a root node and clear all its connections and nodes recursively, leaving the root node for future additions.

       start n=node:DataSpace(DataSpaceName="DS1") match (ds)-[r]-(e) delete e,r

上面的查询绝对是错误的,因为它不考虑递归以及实体具有的条件在删除关系之前要删除。

The above Query is definitely wrong, as it does not consider recursion and also the condition that entities have to be deleted before deleting the relations.

关于如何实现相同目标的任何建议。

Any suggestions on how to achieve the same.

此外,由于我将使用neo4JClient,它将

Also, since I will be using neo4JClient, it will be great if we have a neo4jClient translation as well.

推荐答案

您想要做类似的事情

MATCH (n:MyLabel)-[r*]-(e)
FOREACH (rel IN r| DELETE rel)
DELETE e

请参见 http://console.neo4j.org/r/8go5i6

这篇关于如何从起始节点递归删除节点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆