ArangoDB v3.2 reached End of Life (EOL) and is no longer supported.

This documentation is outdated. Please see the most recent version here: Try latest

Graphs

This chapter describes the general-graph module. It allows you to define a graph that is spread across several edge and document collections. This allows you to structure your models in line with your domain and group them logically in collections giving you the power to query them in the same graph queries. There is no need to include the referenced collections within the query, this module will handle it for you.

Three Steps to create a graph

  • Create a graph
arangosh> var graph_module = require("@arangodb/general-graph");
arangosh> var graph = graph_module._create("myGraph");
arangosh> graph;
Show execution results
{[Graph] 
}
Hide execution results
  • Add some vertex collections
arangosh> graph._addVertexCollection("shop");
arangosh> graph._addVertexCollection("customer");
arangosh> graph._addVertexCollection("pet");
arangosh> graph;
Show execution results
{[Graph] 
  "shop" : [ArangoCollection 17897, "shop" (type document, status loaded)], 
  "customer" : [ArangoCollection 17902, "customer" (type document, status loaded)], 
  "pet" : [ArangoCollection 17907, "pet" (type document, status loaded)] 
}
Hide execution results
  • Define relations on the Graph
arangosh> var rel = graph_module._relation("isCustomer", ["shop"], ["customer"]);
arangosh> graph._extendEdgeDefinitions(rel);
arangosh> graph;
Show execution results
{[Graph] 
  "isCustomer" : [ArangoCollection 17963, "isCustomer" (type edge, status loaded)], 
  "shop" : [ArangoCollection 17959, "shop" (type document, status loaded)], 
  "customer" : [ArangoCollection 17961, "customer" (type document, status loaded)], 
  "pet" : [ArangoCollection 17953, "pet" (type document, status loaded)] 
}
Hide execution results