简体   繁体   English

通过特定节点进行ArangoDB GRAPH遍历

[英]ArangoDB GRAPH TRAVERSAL through specific nodes

Take US cities for example and say I want the traversal of all cities and roads that go through NYC, Chicago and Seattle. 以美国的城市为例,我要遍历纽约,芝加哥和西雅图的所有城市和道路。

This can be done with TRAVERSAL AQL function (using filterVertices). 这可以通过TRAVERSAL AQL函数(使用filterVertices)来完成。 However this function only takes the ID and not the vertex example as in GRAPH_TRAVERSAL. 但是,此函数仅采用ID,而不采用GRAPH_TRAVERSAL中的顶点示例。

The GRAPH_TRAVERSAL doesn't have a filter option, so my question is there a way to filter the results using graph operations? GRAPH_TRAVERSAL没有过滤器选项,所以我的问题是有没有办法使用图形操作过滤结果?

the feature is actually there but was somehow not documented. 该功能实际上在那儿,但是以某种方式没有记载。 I added it to our documentation which should be updated soon. 我将其添加到我们的文档中,该文档应尽快更新。 Sorry for the inconvenience. 抱歉给你带来不便。

filterVertices takes a list of vertex examples. filterVertices包含一系列顶点示例。

  • Note: you can also give the name of a custom AQL function. 注意:您还可以提供自定义AQL函数的名称。 with signature function(config, vertex, path) . 具有签名function(config, vertex, path) For more specific filtering. 有关更具体的过滤。

vertexFilterMethod defines what should be done with all other vertices: vertexFilterMethod定义应该对所有其他顶点执行的操作:

  • "prune" will not follow edges attached to these vertices. "prune"将不会跟随这些顶点的边缘。 (Used here) (在此使用)
  • "exclude" will not include this specific vertex. "exclude"将不包括该特定顶点。
  • ["prune", "exclude"] both of the above. ["prune", "exclude"]以上两种。 (default) (默认)

An example query for your question is the following (airway is my graph): 以下是针对您的问题的示例查询(气道是我的图表):

FOR x in GRAPH_TRAVERSAL("airway", "a/SFO", "outbound", {filterVertices: [{_key: "SFO"}, {_key: "NYC"}, {name: "Chicago"}, {name: "Seattle"}], vertexFilterMethod: "prune"}) RETURN x

Hint: Make sure you include the start vertex in the filter as well. 提示:确保在过滤器中也包含起始顶点。 Otherwise it will always return with an empty array (the first visited vertex is directly pruned) 否则,它将始终返回一个空数组(直接修剪掉第一个访问的顶点)

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

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