1
votes

I am doing an AQL traversal with ArangoDB 3.2 in which I retrieve the nodes connected to my vertexCollection like this:

For v, e, p IN 1..10 ANY vertexCollection GRAPH myGraph OPTIONS {uniqueVertices: "global", bfs:true}
    RETURN v._id

and now I want to skip the nodes from paths where a particular edge collection is used. I know I can filter for particular attributes in lists, like FILTER p.edges[*].type ALL == 'whatever' but I do not find how to apply this into IS_SAME_COLLECTION() to filter by collection.

I discard the option of specifying exactly the edgeCollection in the traversal instead of the GRAPH because it's just one particular edgeCollection that I want to skip vs. many that I want to go through.

I don't know whether there is already an implementation for 'skip edge collection' or something like that in a graph traversal, so far I could not find it.

Note:

I tried to filter like this

For v, e, p IN 1..10 ANY vertexCollection GRAPH myGraph OPTIONS {uniqueVertices: "global", bfs:true}
    FILTER NOT IS_SAME_COLLECTION('edgeToSkip', e._id) 
    RETURN v._id

But here I simply skip the nodes directly connected with edge 'edgeToSkip' but not all nodes within the path where 'edgeToSkip' is present. So I need, not only to exclude that particular edge, but stop traversing when it is found.

Thanks

UPDATE:

I found a workaround, basically I gather all edges present in a 'path' and then filter out if the edge I want to skip is in the 'path'. Note I change from uniqeVertices: "global" to uniqueVertices: "path". .

For v, e, p IN 1..10 ANY vertexCollection GRAPH myGraph OPTIONS {uniqueVertices: "path", bfs:true}
    # collect edge names (collection name) in the current path
    LET ids = (
                FOR edge IN p.edges
                    RETURN PARSE_IDENTIFIER(edge)["collection"]
                   )
    # filter out if edge name (edgeToSkip) is present
    FILTER 'edgeToSkip' NOT IN ids
    RETURN v._id

This way, once the edgeToSkip is found in the path, no vertex is returned, but vertices before the 'edgeToSkip' yes

If the graph is like this:

vertexA --edge1--> vertexB --edge2--> vertexC --edgeToSkip--> vertexD --edge3--> vertexE

Will return:

vertexA, vertexB and vertexC (but not vertexD and vertexE)

1
Hi even i am looking solution for the same scenario. Did you find it out -Dovikrishna
I found a workaround, I've updated the post and added the answer.Dovi

1 Answers

0
votes

I found a workaround, basically I gather all edges present in a 'path' and then filter out if the edge I want to skip is in the 'path'. Note I change from uniqeVertices: "global" to uniqueVertices: "path". .

For v, e, p IN 1..10 ANY vertexCollection GRAPH myGraph OPTIONS {uniqueVertices: "path", bfs:true}
    # collect edge names (collection name) in the current path
    LET ids = (
                FOR edge IN p.edges
                    RETURN PARSE_IDENTIFIER(edge)["collection"]
                   )
    # filter out if edge name (edgeToSkip) is present
    FILTER 'edgeToSkip' NOT IN ids
    RETURN v._id

This way, once the edgeToSkip is found in the path, no vertex is returned, but vertices before the 'edgeToSkip' yes

If the graph is like this:

vertexA --edge1--> vertexB --edge2--> vertexC --edgeToSkip--> vertexD --edge3--> vertexE

Will return:

vertexA, vertexB and vertexC (but not vertexD and vertexE)