在观看 UCSD 视频之后,我正在做 Neo4j 动手练习。我正在剪切和粘贴为练习提供的脚本。我刚刚遇到了为不包含指定节点的直接邻域的图提供的脚本的问题:
match (d {Name:'D'})-[:TO]-(b)
with collect(distinct b.Name) as neighbors
match (n)-[r:TO]->(m)
where
not (n.Name in (neighbors+'D'))
and
not (m.Name in (neighbors+'D'))
return n, r, m;
match (d {Name:'D'})-[:TO]-(b)-[:TO]->(leaf)
where not((leaf)-->())
return (leaf);
match (d {Name:'D'})-[:TO]-(b)<-[:TO]-(root)
where not((root)<--())
return (root)
这将返回:
每个查询只需要一个语句,但得到:3
当我运行前 8 行时,Neo4j 会返回带有预期节点和边的图形。但是当我添加后续查询时,错误消息开始弹出。