1
如何返回節點我有Neo4j的數據庫中包含了一組節點和關係,該節點具有屬性名稱並有不同類型的關係。間接關係相互
,如果我有名字[「A」,「C」,「E」,「Q」,「Z」]的名單,我怎麼能找到這些節點之間的所有直接和間接的路徑?就像A通過一個或多個可能在列表中並且可能不在列表中的節點連接到Z一樣。
這個暗號查詢僅返回其直接連接
MATCH (a)-[r]-(b)
WHERE a.name IN ["A","C","E","Q","Z"] AND
b.name IN ["A","C","E","Q","Z"]
RETURN a,b,r
與該查詢返回不相關的節點
MATCH (a)-[r*0..2]-(b)
WHERE a.name IN ["A","C","E","Q","Z"] AND
b.name IN ["A","C","E","Q","Z"]
RETURN a,b,r