Is it possible to access current node in the filter of the shortest path? Or use custom function in filter with current and next node parameters?


There is a filter option in shortest path calculation where we can access and check fields of the node we are about to go.

  path as shortest(from: 0x2, to: 0x5) {
    friend @filter(not eq(name, "Bob")) @facets(weight)
    relative @facets(liking)

Is it possible to check current node values along the next one? Something like this?

    friend @filter(not eq(name, "Bob") and gt(current.age, 16))

Or have a custom function while checking like this?

    friend @filter(custom(current, next))

It is a common case that a path depends on both current and next node values and we have one.

Yes, filters can be applied to path intermediate nodes, see the Constraints section of Shortest Path Queries - Query language