2

Could someone tell me why the edge collection in the HTTP API takes a list of froms and tos?

The JSON to create a new graph is like so:

{ 
  "name" : "myGraph", 
  "edgeDefinitions" : [ 
    { 
      "collection" : "edges", 
      "from" : [ 
        "startVertices" 
      ], 
      "to" : [ 
        "endVertices" 
      ] 
    } 
  ] 
}

This leads me to believe that the system can have multiple edgeDefinitions and that each edgeDefinition can have multiple from and to entries. I don't understand the multiple from and to per definition. I get having multiple edge definitions.

Here's the documentation: ArangoDB Graph Docs

1 Answer 1

3

A graph in ArangoDB can be used for storing either homogeneous relationships or heterogeneous relationships. If all relations are homogeneous and are stored in the same edge collection, a single edge definition is sufficient.

An edge definition contains the name of the edge collection which stores the relationships (attribute collection) as well as the names of the vertex collections that are allowed to store relations in the edge collection (attributes from and to).

The following example defines a graph with a single edge definition, with connections allowed only between vertex collections users and users. The relationships are stored in an edge collection named knows:

  "edgeDefinitions" : [
     {
        "collection" : "knows",
        "from" : [
           "users"
        ],
        "to" : [
           "users"
        ]
     }
  ]

Multiple edge definitions can be declared for storing different types of relations in a single graph with multiple edge collections, e.g.:

  "edgeDefinitions" : [
     {
        "collection" : "knows",
        "from" : [
           "users"
        ],
        "to" : [
           "users"
        ]
     },
     {
        "collection" : "buys",
        "from" : [
           "users"
        ],
        "to" : [
           "products"
        ]
     }
  ]

Note that the it would also be possible to use a single edge definition here and storing all relationships in a single edge collection (now named connections). Note that there are still different vertex collections (users and products) and some restrictions for how they can be connected:

  "edgeDefinitions" : [
     {
        "collection" : "connections",
        "from" : [
           "users"
        ],
        "to" : [
           "users",
           "products"
        ]
     }
  ]

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.