[英]ArangoDB 3.2 traversal: exclude edge collection
我正在使用ArangoDB 3.2进行AQL遍历,在其中检索与我的vertexCollection连接的节点,如下所示:
For v, e, p IN 1..10 ANY vertexCollection GRAPH myGraph OPTIONS {uniqueVertices: "global", bfs:true}
RETURN v._id
现在我想从使用特定边缘集合的路径中跳过节点。 我知道我可以过滤列表中的特定属性,例如FILTER p.edges[*].type ALL == 'whatever'
但我找不到如何将其应用于IS_SAME_COLLECTION()
进行按集合过滤的方法。
我舍弃了在遍历中精确指定edgeCollection而不是GRAPH的选项,因为它只是我要跳过的一个特定edgeCollection与我想通过的许多edgeCollection。
我不知道是否已经有“跳过边缘集合”的实现或图形遍历中的类似实现,到目前为止,我找不到它。
注意:
我试图这样过滤
For v, e, p IN 1..10 ANY vertexCollection GRAPH myGraph OPTIONS {uniqueVertices: "global", bfs:true}
FILTER NOT IS_SAME_COLLECTION('edgeToSkip', e._id)
RETURN v._id
但是在这里,我只是跳过直接与边缘“ edgeToSkip”连接的节点,而不是跳过存在“ edgeToSkip”的路径中的所有节点。 因此,我不仅需要排除特定的边,而且还需要在找到该边时停止遍历。
谢谢
更新 :
我找到了一种解决方法,基本上我收集了“路径”中存在的所有边缘,然后过滤掉是否要跳过的边缘在“路径”中。 注意,我从uniqeVertices:“ global”更改为uniqueVertices:“ path”。 。
For v, e, p IN 1..10 ANY vertexCollection GRAPH myGraph OPTIONS {uniqueVertices: "path", bfs:true}
# collect edge names (collection name) in the current path
LET ids = (
FOR edge IN p.edges
RETURN PARSE_IDENTIFIER(edge)["collection"]
)
# filter out if edge name (edgeToSkip) is present
FILTER 'edgeToSkip' NOT IN ids
RETURN v._id
这样,一旦在路径中找到edgeToSkip,就不会返回任何顶点,而是在“ edgeToSkip”之前的顶点
如果图形是这样的:
vertexA --edge1--> vertexB --edge2--> vertexC --edgeToSkip--> vertexD --edge3--> vertexE
将返回:
vertexA
, vertexB
和vertexC
(但不包括vertexD
和vertexE
)
我找到了一种解决方法,基本上我收集了“路径”中存在的所有边缘,然后过滤掉是否要跳过的边缘在“路径”中。 注意,我从uniqeVertices:“ global”更改为uniqueVertices:“ path”。 。
For v, e, p IN 1..10 ANY vertexCollection GRAPH myGraph OPTIONS {uniqueVertices: "path", bfs:true}
# collect edge names (collection name) in the current path
LET ids = (
FOR edge IN p.edges
RETURN PARSE_IDENTIFIER(edge)["collection"]
)
# filter out if edge name (edgeToSkip) is present
FILTER 'edgeToSkip' NOT IN ids
RETURN v._id
这样,一旦在路径中找到edgeToSkip,就不会返回任何顶点,而是在“ edgeToSkip”之前的顶点
如果图形是这样的:
vertexA --edge1--> vertexB --edge2--> vertexC --edgeToSkip--> vertexD --edge3--> vertexE
将返回:
vertexA
, vertexB
和vertexC
(但不包括vertexD
和vertexE
)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.