简体   繁体   English

AQL:如何取回所有边必须具有属性(数组)并且该数组必须具有至少一个特定值的路径

[英]AQL: How to get back the path that all edges must have an property(array) and that array must have at least one certain value

Suppose I have an graph like this:假设我有这样的图表:

A---edge1---B property P [P1,P2] A---edge1---B 属性 P [P1,P2]

B---edge2---C property P [P2,P3] B---edge2---C 属性 P [P2,P3]

C---edge3---D property P [P2,P3] C---edge3---D 属性 P [P2,P3]

B---edge4---D property P [P1,P3] B---edge4---D 属性 P [P1,P3]

And each edge have an property P which is an array of string [P1,P2,P3].每条边都有一个属性 P,它是一个字符串数组 [P1,P2,P3]。 Each edge has their own value of P Now I would like to return all vertexes that:每条边都有自己的 P 值现在我想返回所有顶点:

  1. For Each vertex, check if exist a path where each edges, all of them must have at least P2 in property对于每个顶点,检查是否存在每个边的路径,所有边的属性必须至少为 P2
  2. Depth smaller or equals then 2深度小于或等于 2

** **

For entity in entities
For v,e,p in Collection in 0..2 ANY entity 
Filter //What should I do here? I tried p.edges[*].P[*] ANY =="P2" 
Collect v._key into groups 
return {key:v._key,group:groups} //Get the vertex that satisfy the condition

** **

p.edges[*].P[*] is an array of arrays. p.edges[*].P[*]是一个 arrays 的数组。 To get ANY == to compare array to individual element would require a flattened array, but then it cannot be determined whether each array has "P2" .要让ANY ==将数组与单个元素进行比较,需要一个扁平数组,但无法确定每个数组是否具有"P2"

One of the following conditions should work however:但是,以下条件之一应该有效:

  • FILTER p.edges[* RETURN "P2" IN CURRENT.P] ALL == true

  • FILTER (FOR arr IN p.edges[*].P RETURN "P2" IN arr) ALL == true

  • FILTER LENGTH(p.edges[* FILTER "P2" IN CURRENT.P]) == LENGTH(p.edges)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM