Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to delete all relationships in neo4j graph?

Tags:

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.

like image 540
roman Avatar asked Oct 15 '12 16:10

roman


People also ask

How to delete a node in Neo4j graph database?

DETACH and DELETE : DETACH keyword remove the relationship between node (detaches the nodes), further based on the DELETE command Neo4J deletes the nodes. Below commandd deletes all the daa present in the Neo4J Graph Database.

How to delete nodes with no relationship in Node JS?

OPTIONAL MATCH DELETE when we donot know that whether an Node has any relationship are not, we go with just delete method as if we give Command to delete Node with relationship, it will not delete the Nodes without relationship. So we use the OPTIONAL MATCH method to delete the Nodes and Nodes with relationships.

How to use set command In Neo4j?

SET in Neo4J command helps user to Update the properties and lebles of Nodes and Relationships. 1. First lets create a Node and edit the properties. For above node we have not created any name, lets update the name using SET Command.

How do I delete a relationship in Raul?

Deleting relationship is as simple as deleting nodes. Use the MATCH statement to match the relationships you want to delete. You can delete one or many relationships or all relationships by using one statement. The above statement will match all Raul nodes that have a relationship type of PLAYER_OF with an Itly node.


1 Answers

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)

like image 190
ulkas Avatar answered Sep 30 '22 17:09

ulkas