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.

New to ArangoDB? Take the freeArangoDB Graph Coursefor freshers.

Three Steps to create a graph

  • Create a graph
  1. arangosh> var graph_module = require("@arangodb/general-graph");
  2. arangosh> var graph = graph_module._create("myGraph");
  3. arangosh> graph;

Show execution results

  1. {[Graph]
  2. }

Hide execution results

  • Add some vertex collections
  1. arangosh> graph._addVertexCollection("shop");
  2. arangosh> graph._addVertexCollection("customer");
  3. arangosh> graph._addVertexCollection("pet");
  4. arangosh> graph;

Show execution results

  1. {[Graph]
  2. }

Hide execution results

  • Define relations on the Graph
  1. arangosh> var rel = graph_module._relation("isCustomer", ["shop"], ["customer"]);
  2. arangosh> graph._extendEdgeDefinitions(rel);
  3. arangosh> graph;

Show execution results

  1. {[Graph]
  2. }

Hide execution results