java 如何删除neo4j图中的所有关系?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/12899538/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-31 10:42:03  来源:igfitidea点击:

How to delete all relationships in neo4j graph?

javaruby-on-railsrubyneo4jneography

提问by roman

I need to delete all relationships between all nodes. Is there any way to delete all relationships in the neo4j graph? Note that I am using ruby bindings - the neographygem. There is no info about that in the wiki of the gem. I've also tried to find a way to do it in the neo4j documentation without any result.

我需要删除所有节点之间的所有关系。有没有办法删除neo4j图中的所有关系?请注意,我使用的是 ruby​​ 绑定 - neographygem。gem 的 wiki 中没有关于此的信息。我还尝试在 neo4j 文档中找到一种方法,但没有任何结果。

Neo4j version is 1.7.2.

Neo4j 版本是 1.7.2。

回答by ulkas

in cypher:

在密码中:

deleting all relationships:

删除所有关系:

start r=relationship(*) delete r;

creating all relationships between all nodes, i'd assume:

在所有节点之间创建所有关系,我假设:

start n=node(*),m=node(*) create unique n-[r:RELTYPE]-m;

but you rather dont want to have too many vertices, since it collapse on low memory (at least in my case i got 1mil vertices and 1gb ram)

但是你不想有太多的顶点,因为它在低内存时崩溃(至少在我的情况下我有 100 万个顶点和 1gb ram)

回答by DachuanZhao

In cypher3.5, startis deprecated.

在 cypher3.5 中,startdeprecated.

You can use this cypher to delete all relationships

您可以使用此密码删除所有关系

match ()-[r]->() delete r;