从教程开始:
MATCH p=shortestPath( (keanu:Person)-[:KNOWS*]-(kevin:Person) ) WHERE keanu.name="Keanu Reeves" and kevin.name = "Kevin Bacon" RETURN length(p)想象一下,每个人"节点都有一个年龄属性和一个职业.每个KNOWS边都有一个length of acquaintance属性.
Imagine each Person node has an age property and an occupation. Every KNOWS edge has a length of acquaintance property.
什么Cypher查询将返回最短路径,例如,
What Cypher query would return a shortest path with, for instance,
age > 40 years not (occupation = ACTOR) lengthOfAcquaintance > 10 years在分子生物学相互作用数据中,我们希望进行更复杂的查询-可能是密码处理得很好的那种查询,但又使我难以理解.例如:
In molecular biology interaction data, we wish to make yet more complex queries - probably of the sort which cypher handles well, but just how eludes me. For example:
找到受体分子A和转录因子B之间的最短路径,其中大多数边缘来自小规模实验,大多数基因被标记为激酶,并且边缘的证据(权重)为greater than 0.5
Find the shortest paths between receptor molecule A and transcription factor B, where most edges are from small-scale experiments, most of the genes are annotated as kinase, and evidence (weight) for the edges is greater than 0.5
这些查询可能在许多设置中出现.谁能指出我的阅读和例子,这将有助于我理解其完成方式?也许可以提供培根数"查询的适度扩展,以容纳一个节点和一个边缘属性?
These queries probably come up in lots of settings. Can anyone point me towards readings and examples which will help me understand how this is done? And maybe provide a modest extension of the "Bacon Number" query which accommodates one node and one edge property?
谢谢!
- Paul
我认为您正在寻找的是所有谓词.
I think that what you are looking for is the ALL predicate.
以下是一些使用它的示例:
Here are a couple of examples using it :
ShortestPath,路径中的所有参与者都应具有age > 40:
ShortestPath where all actors in the paths should have an age > 40 :
MATCH p=shortestPath( (keanu:Person)-[:KNOWS*]-(kevin:Person) ) WHERE keanu.name = "Keanu Reeves" AND kevin.name = "Kevin Bacon" AND ALL(x IN nodes(p) WHERE x.age > 40) RETURN pShortestPath,其中所有边缘都应具有lengthOfAcquaintance > 10
ShortestPath where all edges should have a lengthOfAcquaintance > 10
MATCH p=shortestPath( (keanu:Person)-[:KNOWS*]-(kevin:Person) ) WHERE keanu.name = "Keanu Reeves" AND kevin.name = "Kevin Bacon" AND ALL(x in rels(p) WHERE x.lengthOfAcquaintance > 100 RETURN p您当然可以将两者结合在一起:
Of course you can combine the both :
MATCH p=shortestPath( (keanu:Person)-[:KNOWS*]-(kevin:Person) ) WHERE keanu.name = "Keanu Reeves" AND kevin.name = "Kevin Bacon" AND ALL(x in rels(p) WHERE x.lengthOfAcquaintance > 10) AND ALL(x in nodes(p) WHERE x.age > 40) RETURN p更多推荐
neo4j:受节点和rel属性约束的最短路径
发布评论