How to delete all relationships in neo4j graph?

血红的双手。 提交于 2019-12-22 01:52:10

问题


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 neography gem. 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 version is 1.7.2.


回答1:


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)




回答2:


In cypher3.5, start is deprecated.

You can use this cypher to delete all relationships

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


来源:https://stackoverflow.com/questions/12899538/how-to-delete-all-relationships-in-neo4j-graph

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!