简体   繁体   English

找到两个顶点之间的所有路径

[英]Find all paths between two vertices

How can I get all paths between two vertices with a depth of n in arangodb 3.1? 如何在arangodb 3.1中获得深度为n的两个顶点之间的所有路径? The only possibility that I found in the AQL documentation was the shortest path. 我在AQL文档中找到的唯一可能性是最短路径。 But I would like to get all paths, not only the shortest one. 但我想得到所有的路径,而不仅仅是最短路径。

Thanks for your help! 谢谢你的帮助!

In order to get all paths with exactly length n between to vertices with known _id values you can use the following AQL statement: 为了获得具有已知_id值的顶点之间具有正好长度n所有路径,您可以使用以下AQL语句:

FOR target, unused, path IN @depth ANY @source edgeCollection
  FILTER target._id == @target
  RETURN path

Let me shortly explain the parts: 让我简要解释一下这些部分:

  • FOR target, unused, path => defines return values: target = vertex you search for, unused = last edge pointing to it, path = the complete path in format: {edges: [edge1, edge2, ..], vertices: [vertex1, vertex2, ...]} FOR target, unused, path =>定义返回值: target =你搜索的顶点, unused =指向它的最后一个边, path =格式的完整路径: {edges: [edge1, edge2, ..], vertices: [vertex1, vertex2, ...]}
  • IN @depth => Define the exact depth n no shorter and no longer paths will be returned. IN @depth =>定义精确的深度n不短,不再返回路径。 Can also be @min..@max than all paths with length min to max will be returned. 也可以是@min..@max ,将返回长度为min到max的所有路径。
  • ANY => Search direction, this will ignore direction of edges, can also be INBOUND or OUTBOUND ANY =>搜索方向,这将忽略边的方向,也可以是INBOUNDOUTBOUND
  • @source => The target vertex id @source =>目标顶点id
  • edgeCollection => name of the edge collection, can also be GRAPH "graphName" edgeCollection =>边集合的名称,也可以是GRAPH "graphName"
  • FILTER target._id == @target => Here we validate that we find the correct vertex. FILTER target._id == @target =>这里我们验证我们找到了正确的顶点。
  • RETURN path => Well return the Path ;) RETURN path =>好了返回路径;)

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

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