备份:多条查找所哟的依赖结构
SQL:
match (n)-[r:Target_To*1..]->(m)
where all(a in r where a.targetFramework contains "framework")
return n,m
match p=(n:TestNode{name:"A"})-[r:to*1..3]-(m:TestNode)
WHERE size(apoc.coll.duplicates([x in relationships(p) | type(x)]))=0 AND size(apoc.coll.duplicates(apoc.coll.flatten([x in nodes(p) | labels(x)])))=0
RETURN p
最终查询结果:
match p=(a:TestNode{name:"A"})-[r:to*1..2]->(x:TestNode)
WHERE( NOT (x)-[:to]->()) or ((x)-[:to]->(a))
WITH length(p) AS size, p
ORDER BY size DESC
RETURN reduce(node_ids = [], n IN nodes(p) | node_ids + [n.name]),p
结果:
备忘:最终整合的结果:
match p=(n:Package{packageID:"newtonsoft.json@@13.0.1"})<-[r:Target_To*1..6]-(m:Package)
where all(a in r where a.targetFramework contains "framework")
WITH length(p) AS size, p
ORDER BY size DESC
RETURN reduce(node_ids = [], n IN nodes(p) | node_ids + [n.packageID]) as result