Neo4j 2.1.0-M01中断开节点的轻松删除

Neo4j 2.1.0-M01中断开节点的轻松删除,neo4j,cypher,Neo4j,Cypher,我花了一些时间研究如何轻松删除断开连接的节点,但我无法“抓住”它们 显然不起作用,也不起作用 match (n) optional match (n)-[r]-(m) where r is null delete r 那么,最好的方法是什么 也许是一个解决办法,但我终于做到了 match (n)-[r]-(m) set n.x=1 它为所有相关节点创建属性n 然后 match (n) where n.x is null delete n 删除松散的节点和 match (n) remove

我花了一些时间研究如何轻松删除断开连接的节点,但我无法“抓住”它们

显然不起作用,也不起作用

match (n) optional match (n)-[r]-(m) where r is null delete r

那么,最好的方法是什么

也许是一个解决办法,但我终于做到了

match (n)-[r]-(m)
set n.x=1
它为所有相关节点创建属性n

然后

match (n) where n.x is null delete n
删除松散的节点和

match (n) remove n.x  
清理。我不知道这是否是一个好的做法,不过另一个想法是:

match (n)                     // match all nodes
with n
optional match (n)-[r]-()     // optionally match relationships
with n, count(r) as c
where c=0                     // filter those having no relationships
delete n                      // get rid of 'em
这个怎么样

MATCH (n)
WHERE NOT n--()
DELETE n

做那件事相当昂贵。也仅适用于小图形。
MATCH (n)
WHERE NOT n--()
DELETE n