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"
]
}
]