我正在尝试删除度数等于或小于1的所有节点,但是它不起作用。 我的查询如下
CALL apoc.periodic.commit("
MATCH (n:RoadPoint)-[:ROAD_SEGMENT]-(m:RoadPoint)
WHERE NOT (:Depot)-[:LOCATED_AT]->(n)
WITH n , COUNT(DISTINCT m) AS c
WHERE c <= 1
WITH n limit {limit}
DETACH DELETE n
RETURN COUNT(*)
", {limit:1000})
答案 0 :(得分:1)
您可以尝试以下查询:
CALL apoc.periodic.commit(
"MATCH (n:RoadPoint)
WHERE
NOT (:Depot)-[:LOCATED_AT]->(n) AND
size((n)-[:ROAD_SEGMENT]-(:RoadPoint)) <=1
WITH n LIMIT $limit
DETACH DELETE n
RETURN COUNT(*)",
{limit:1000}
)
由于size
功能,在这种情况下,它应该使用存储在每个节点上的degrree统计信息,这样既可以工作又可以更快。