I'm using ArangoDB 3.0 and I want to create an AQL query to get the shortest path from A to B, with depth = 3, filtering on some edge properties.
The "ArangoDB 2.0" version of the query, would like be the following:
FOR e IN GRAPH_SHORTEST_PATH('CityGraph', 'city/rome', 'city/turin',
{
edgeExamples: [{filterProperty: 'FIRST'}, {filterProperty: 'SECOND' }]}
)
I read the documentation about arangoDB 3.0 ( https://docs.arangodb.com/3.0/AQL/Graphs/ShortestPath.html ), and it says:
Conditional shortest path
The SHORTEST_PATH computation will only find an unconditioned shortest path. With this construct it is not possible to define a condition like: "Find the shortest path where all edges are of type X". If you want to do this, use a normal Traversal instead with the option {bfs: true} in combination with LIMIT 1 .
So, can someone tell me what type of AQL query I can do it? According with the suggestions, I write this:
FOR n, e IN 1..3 ANY 'city/rome' GRAPH 'CityGraph' OPTIONS {bfs: true} FILTER e.filterProperty IN ['FIRST', 'SECOND'] LIMIT 1 return {n, e}
But it returns only the first level of graph depth, instead of a depth of n.
Thank you in advance.
Best regards,
Daniele
with LIMIT 1
you specify to limit the result set of your AQL to just get the shortest path.
The translation of the above query should look like this:
FOR n, e, p IN 1..3 ANY 'city/rome'
GRAPH 'CityGraph'
OPTIONS {bfs: true}
FILTER p.edges[*].filterProperty ALL IN ['FIRST', 'SECOND']
FILTER n._key == 'turin'
LIMIT 1
RETURN {n, e}
FIRST
or SECOND
, if an edge without one of those two is passed, this path is discarded. turin
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.