home shape

New feature: Multi Collection Graphs

This version is deprecated. Download the new version of ArangoDB

With the 2.2 release we proudly announce that we now offer the feature of multi collection graphs. This allows you to group an arbitrary set of ArangoDB collections into one graph. In order to do this grouping you execute the following steps in arangosh or Foxx: 1. Require the general-graph module and create a graph.

var graph_module = require("org/arangodb/general-graph");
var graph = graph._create("myGraph");
  1. Add collections to be used as vertex collections. If the collections are not yet created, ArangoDB will create them for you.
  1. Create edge definitions between your vertex collections. These definitions create edge collections and allow you to store edges where source and target vertices come from the collections written in the definition. If you give vertex collections unknown to the graph they will be added to the graph. You have two options to create such a definition, it is either undirected – the set of source and target vertex collections is identical:
    graph._extendEdgeDefinitions(graph_module._undirectedRelation("friendship", "person"));
    graph._extendEdgeDefinitions(graph_module._undirectedRelation("has_cited", "publication"));

    Or it is directed – the set of source and target vertex collections is different:

    graph._extendEdgeDefinitions(graph_module._directedRelation("has_written", "person", "publication"));
    graph._extendEdgeDefinitions(graph_module._directedRelation("has_worked_for", "person", ["company", "university"]));

    Using this graph module now gives you the following benefits:

No loose ends: If you delete a vertex in the graph, all connected edges of all graphs are removed as well. Everything transactional: All operations within the graph module are transactional. Use graphs in AQL: All graph functions (neighbors, shortest path, traversal, etc.) are easily available in AQL. For instance, you can filter your starting vertices using standard AQL and then do a traversal given your graph name and these vertices in one AQL call. Overlapping Graphs: You can add the same edge definition to several graphs. This allows you to define several “views” of your data. To give you an example:

var academical = graph._create("academical");
academical._extendEdgeDefinitions(graph_module._undirectedRelation("friendship", "person"));
academical._extendEdgeDefinitions(graph_module._directedRelation("has_written", "person", "publication"));
var business = graph._create("business");
business._extendEdgeDefinitions(graph_module._undirectedRelation("friendship", "person"));
business._extendEdgeDefinitions(graph_module._directedRelation("has_worked_for", "person", ["company", "university"]));

Now you have two graphs sharing friendship.

Fluent Query Interface: There is a fluent interface to generate and handle AQL queries. You start by selecting a subset of your graph (edges or vertices) and from there on explore the graph. To give you an example suppose you want to query all papers that have been influenced directly or indirectly by publications of Amazon. 1. You start by selecting the company Amazon.

var query = graph._vertices({name: "Amazon"}).restrict("company")
  1. Next you find all the papers that have been published by employees of the company (two hop neighbors).
query = query.neighbors({}, {minDepth: 2, maxDepth: 2}).restrict("publication")
  1. Select all papers reachable in a path using only inbound “has_cited” edges (1-n hop inbound neighbors)
query = query.neighbors({}, {maxDepth: Infinity, direction: "inbound", edgeCollectionRestriction: "has_cited"})
  1. Finally print the result:

This generates the following AQL:

FOR vertices_0 IN GRAPH_VERTICES("myGraph", {name: "Amazon"}, "vertexCollectionRestriction": ["company"])
FOR neighbors_1 IN GRAPH_NEIGHBORS("myGraph", vertices_0, {"minDepth": 2,"maxDepth": 2,"neighborExamples": {}, "vertexCollectionRestriction": ["publication"]})
FOR neighbors_2 IN GRAPH_NEIGHBORS("myGraph", neighbors_1.vertex, "maxDepth": Infinity, "direction": "inbound", "edgeCollectionRestriction": "e", "neighborExamples": {})
RETURN neighbors_2.vertex

For further information have a look

in our documentation. 5. REST API: Also the functionality to manage the graphs is offered via the endpoint


for it’s features please have a look

<a href="http://docs.arangodb.com/HttpGharial/index.html" title="HTTP Graph Documentation" target="_blank">at our documentation</a>.

6. Web Interface: Manage your graphs in the interface and view them using the graph viewer. Some words on

backwards compatibility: If you already have created a graph using the old graph module this graph will be transformed into the new layout during the upgrade procedure. The old module is still available and works as before. In addition the graph can be accessed using the new module. For our API implementors, there are some differences in the HTTP API in addition to the different endpoint: * Creation of graphs now expects different parameters, one vertex and one edge collection are not enough. * Creation of vertices now expect a POST to {graphname}/vertex/{collectionname} as we cannot figure out where to store the vertex otherwise. * Same for creation of edges. * Measurements are no longer offered by the API, they have been included in AQL

Michael Hackstein

Michael is a JavaScript and NoSQL enthusiast. In his spare time he is organising colognejs, the JavaScript user group in Cologne Germany scheduled every second month. In his professional life Michael holds a master degree in Computer Science. As Front End Specialist he is member of the ArangoDB core team, developing the web frontend and graph visualisation for this project. He is conference and user group addicted.


  1. Andrey Belyaevskiy on October 20, 2015 at 11:35 am

    Can I show 2 different graphs in one graph viewer?

    • Haseb Ansari on February 18, 2016 at 3:09 pm

      yes u can do it…..in one graph u can create two sub-graphs

Leave a Comment

Get the latest tutorials, blog posts and news: