匹配/删除Neo4j中的整个子图 [英] Match/delete whole subgraph in Neo4j

查看:275
本文介绍了匹配/删除Neo4j中的整个子图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

鉴于我的数据库中有一个大图,我想删除该图的整个子图,而我只知道该子图的起始节点.是否可以编写密码查询来匹配和删除整个子图?

Given there is a big graph in my database and I want to delete a whole subgraph of that, where I only know the starting node of this subgraph. Is it possible to write a cypher query to match and delete this whole subgraph?

注意:我不了解子图的更多信息,因为它在哪个节点开始.

Caveat: I don't know more of the subgraph as in which node it starts.

推荐答案

是的,您可以通过APOC过程从单个节点扩展到所有子图节点

Yes, you can expand from a single node to all subgraph nodes via APOC Procedures path expander, optionally with filters on the relationships or nodes to traverse, and with an optional max depth.

您需要使用expandConfig()过程,并使用NODE_GLOBAL唯一性.

You need to use the expandConfig() procedure, and use NODE_GLOBAL uniqueness.

MATCH (s:Node)
WHERE s.name = 'start'
CALL apoc.path.expandConfig(s, {uniqueness:'NODE_GLOBAL'}) YIELD path
WITH LAST(NODES(path)) as subgraphNode
...

最终,将有一个subgraphNodes()过程将其包装以更好地突出功能.

Eventually there will be a subgraphNodes() procedure to wrap this to better highlight the functionality.

这篇关于匹配/删除Neo4j中的整个子图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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