3
votes

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).

However, it seems that what happens is that e is merely skipped and then traversal continues down that path.

So, how can I set boundaries on graph-traversal by edge-properties using AQL?

1

1 Answers

3
votes

The query supports v, e and p, where p is the path it takes.

The ArangoDB documentation shows some examples.

I have used this to exclude specific nodes at specified depths in the path but you have to specify depth of nodes e.g. 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. 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.