Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

deleting all single nodes from neo4j

I have several nodes in my database that are not connected to any other nodes and I don’t need them in the database. I have gone through this guide but it does not mention anything regarding deleting all single nodes. Is there any way I could delete all nodes that are not connected to any other nodes?

Example of single nodes in my database.

enter image description here

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

Find any node labels and check if there is no connected nodes, then delete them

 MATCH (n)
 WHERE size((n)--())=0
 DELETE (n)
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading