简体   繁体   中英

Include Entry node in AQL Graph traversal

I'm using AQL to traverse through Graphs, right now that's my statement:

FOR v, e, p IN 1..1 ANY 'Bridges/1004' 
    GRAPH 'S_Graph'
    FILTER not (p.vertices[1].IID != 'null' AND p.vertices[1].cls_name == "Bridge")
    OR p.vertices[1].cls_name == "Node"
    RETURN v

And the result are the Documents my Entry-Document Bridges/1004 , but not the Entry-Document itself.

How is it possible to include the Entry-Document in the Query-Result?

Just change the traversal depth from 1..1 to 0..1 and that should include the initial node.

FOR v, e, p IN 0..1 ANY 'Bridges/1004' 
GRAPH 'S_Graph'
FILTER not (p.vertices[1].IID != 'null' AND p.vertices[1].cls_name == "Bridge")
OR p.vertices[1].cls_name == "Node"
RETURN v

Also note that in your original query, if you return the path, it does include all the nodes in the path including the original node

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM