2
我有一個非常簡單的數據模型與源 - [:鏈接] - >目標。我想找出所有沒有輸入鏈接的節點,例如我的數據模型的「根源」。我如何在Cypher中做到這一點?Neo4j:檢索所有未引用的節點
我有一個非常簡單的數據模型與源 - [:鏈接] - >目標。我想找出所有沒有輸入鏈接的節點,例如我的數據模型的「根源」。我如何在Cypher中做到這一點?Neo4j:檢索所有未引用的節點
您可以篩選空值
START target=node(*)
MATCH target<-[r?:link]-source
WHERE r is null
RETURN target
有關詳細信息,請參閱Cypher where clause documentation
或者,你也可以做
START target=node(*)
WHERE not(target<-[:link]-source)
RETURN target
*注:未測試
start n=node(*)
match n<-[?]-m
with n, count(m) as c
where c=0
return n
我在找這樣的東西。這基本上是他所要做的是整個圖形掃描,除非他索引這些根節點。 – Nicholas 2013-05-06 18:47:27
謝謝,那是做的工作。它也適用於這一個:START target =節點(*) MATCH target < - [?] - 來源 WHERE來源爲空 RETURN目標 – Michael 2013-05-06 19:16:33