3
我搜索圖的最長路徑,並且想要計算此最長路徑的不同節點的數量。neo4j如何在路徑的節點上使用count(distinct())
我想用count(distinct())
我嘗試了兩種查詢。
首先是
match p=(primero)-[:ResponseTo*]-(segundo)
with max(length(p)) as lengthPath
match p1=(primero)-[:ResponseTo*]-(segundo)
where length(p1) = lengthPath
return nodes(p1)
查詢結果與路徑節點的圖。
但是,如果我試圖查詢
match p=(primero)-[:ResponseTo*]-(segundo)
with max(length(p)) as lengthPath
match p1=(primero)-[:ResponseTo*]-(segundo)
where length(p1) = lengthPath
return count(distinct(primero))
結果是
count(distinct(primero))
2
如何使用count(distinct())
在節點PRIMERO。
節點Primero有一個名爲id的字段。