简体   繁体   English

ArangoDB Graph-Traversal:排除边缘

[英]ArangoDB Graph-Traversal: Exclude Edges

I'm executing a query similar to: 我正在执行类似于的查询:

FOR v, e IN 1..10 ANY @start GRAPH @graph
    FILTER e.someCondition
    RETURN v

What I expected to happen was that if e.someCondition was false , then the edge in question wouldn't be traversed (and transitively, all other vertexes and edges reachable solely through e would never be visited). 我期望发生的是,如果e.someConditionfalse ,那么将不会遍历所讨论的边缘(并且传递上,所有其他顶点和边缘仅通过e可到达将永远不会被访问)。

However, it seems that what happens is that e is merely skipped and then traversal continues down that path. 然而,似乎发生的事情是e仅被跳过,然后遍历沿着该路径继续。

So, how can I set boundaries on graph-traversal by edge-properties using AQL? 那么,如何使用AQL通过边缘属性设置图遍历的边界?

The query supports v, e and p, where p is the path it takes. 该查询支持v,e和p,其中p是它所采用的路径。

The ArangoDB documentation shows some examples. ArangoDB文档显示了一些示例。

I have used this to exclude specific nodes at specified depths in the path but you have to specify depth of nodes eg p.vertices[0].something != 'value' ). 我用它来排除路径中指定深度的特定节点,但你必须指定节点的深度,例如p.vertices[0].something != 'value' )。

Another thing you might want to look at is working with 'Custom Visitor' functions which are evaluated as the query traverses down a path. 您可能想要看的另一件事是使用“自定义访问者”功能,这些功能在查询遍历路径时进行评估。

This good blog post and this ArangoDB guide show some real world examples of it and it's well worth the read and effort to get a sample working. 这篇优秀的博客文章和这篇ArangoDB指南展示了它的一些真实世界的例子,并且非常值得阅读并努力使样本正常工作。 I've used these functions to summarise data in a path, aggregated by properties on the vertices in the path, but you can also use it to have custom paths followed. 我已经使用这些函数来汇总路径中的数据,通过路径中顶点的属性进行聚合,但您也可以使用它来跟随自定义路径。

This is worth the effort because it gives you huge flexibility over the computation it follows when traversing the graph. 这是值得的,因为它为您在遍历图表时所遵循的计算提供了极大的灵活性。 You can exclude branches, only include branches that meet specific requirements, or aggregate data about the paths it took. 您可以排除分支,仅包括满足特定要求的分支,或汇总有关其所采用路径的数据。

I hope that helps. 我希望有所帮助。

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

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