Traversals

    Traversals have also been added to AQL.Please read the before you continue reading here.Most of the traversal cases are covered by AQL and will be executed in an optimized way.Only if the logic for your is too complex to be defined using AQL filters you can use the traversal object definedhere which gives you complete programmatic access to the data.

    For any of the following examples, we’ll be using the example collections v and e,populated with continents, countries and capitals data listed below (see Example Data).

    ArangoDB provides the edges, inEdges, and outEdges methods for edge collections.These methods can be used to quickly determine if a vertex is connected to other vertices,and which.This functionality can be exploited to write very simple graph queries in JavaScript.

    For example, to determine which edges are linked to the world vertex, we can use inEdges:

    Note: edges, inEdges, and outEdges return an array of edges. If we want to retrievethe linked vertices, we can use each edges’ from_ and to_ attributes as follows:

    We are using the document method from the db object to retrieve the connected vertices now.