ArangoDB : How to get all the possible paths between 2 vertices?

前端 未结 1 486
南方客
南方客 2021-01-21 12:45

How to get all the possible paths between 2 vertices (eg. X and Y) with maxDepth = 2?

I tried with TRAVERSAL but it is taking around 10 se

相关标签:
1条回答
  • 2021-01-21 13:21

    You can speed up the query a lot if you put the filter for destination right into Traversal via the options filterVertices to give examples of vertices that should be touched by the traversal. With vertexFilterMethod you can define what should happen with all vertices that do not match the example.

    So in your query you only want to match the target vertex "Y" and all other vertices should be passed through but not included in the result, exclude.

    This makes the later FILTER obsolete. Right now the internal optimizer is not able to do that automagically but this magic is on our roadmap.

    This is a query containing the optimization:

    FOR p IN TRAVERSAL(locations, connections, "X", "outbound", { minDepth: 1, maxDepth: 2, paths: true, filterVertices: [{_key: "Y"}], vertexFilterMethod: ["exclude"]})
    RETURN p.path.vertices[*].name
    
    0 讨论(0)
提交回复
热议问题